Using a Raspberry Pi as a Server

I have an old iMac sitting under my desk, and today’s the first day it’s been turned off in ages.  Until today, I was using it as an application server: it was running a MySQL database and a custom Java application that does Twitter data collection.  But this morning, I moved the last of those tasks to a $35 computer, the Raspberry Pi:

Photo courtesy of Daniel Mietchen, Wikimedia Commons

Photo courtesy of Daniel Mietchen, Wikimedia Commons

The old iMac was a G4 processor — the next to the last of the non-Intel CPUs Apple used.  Because of that, it is stuck on older versions of software: OSX 10.5 (Leopard), a MySQL version from years ago, and a somewhat quirky version of Java.  But it did its job well, and just ran without issue.  Uptime said the last time it was rebooted was over 160 days ago (probably as the result of a software upgrade or mid-summer extended power outage).

So moving to a new server was a bit of a risk — don’t fix what’s not broken.  But the advantages of the Pi were enormous:

  • Size: Having an iMac under your desk is a little junky. My wife asked “can’t you just buy another Mac Mini instead?” (And I did consider that).
  • Modern software: Being able to get current versions of an operating system, database, and Java are reassuring.
  • Power consumption: The iMac pulls on the order of 100 watts.  The Pi, with its external hub and disk drive, probably more like 7.  As we head back into Hurricane Season here in Florida, the lower power profile means that the computer can run a lot longer on battery back-up UPS; it’s not uncommon to get power outages of a half hour during bad thunderstorms.
  • Geek Factor: Using an ARM server is dipping my toes into a platform of the future.

There were a few concerns about limitations:

  • The processor in the ARM is clocked slower than the G4 and is probably not as powerful overall.  
  • The Pi has 512mb of memory while the iMac has 1gb.
  • The boot disk drive of the Pi is an SD card (which tops out at 32gb), and since my database is now over 30gb that means I had to attach an external USB drive to the computer.  USB drives are not the fastest.
  • It doesn’t have native WiFi.  Right now it’s running on a cable connection to the router, so it doesn’t have as much freedom to be moved around as the iMac.  But it’s also so small that sticking it near the router isn’t a big deal.

So how’s it doing?

As far as the memory concern, the Pi is only using about half of its memory to support the Java app and the database (until I expand the buffers in the database to sop up the extra memory, of course). Performance is good enough — it keeps up with the Twitter feeds I’m collecting, so there’s no problem there.  It sits idle much of the time, so I know it’s not struggling to keep up.  All in all, it seems like the performance and capabilities are on a par with the “Micro” virtual server that Amazon charges you $17 a month.

What’s the full configuration?

  • A Raspberry Pi+Case, ordered from Sparkfun for $52 with shipping
  • A four port USB 2 hub I had lying around my junk drawer.
  • A 100gb USB backup disk that was also in the junk drawer
  • A USB power supply with the appropriate connector for the Pi … that was in a junk drawer.  I have a lot of electronics junk.
  • An 8gb SD card I stole from a video camera

So probably the full costs of this, if I had to buy all the pieces new, would have been more in the range of $100 — the $35 computer is still a bit of a “stone soup” kind of thing.  But for $100 for a full functional Linux server that would fit into a Kleenex box, I am impressed!

Recommendations?

If you’re looking for an “under the desktop” server, these seem like a great way to go for a lightweight project.  You have to be comfortable with Linux system administration — very comfortable — but if you are (or feel like now’s the time to learn) it’s a good option for at home or skunk works projects.