Colocating a Raspberry Pi Debian server in a data center (follow up)

I mentioned in an earlier post that I’m planning to host this website on a colocated Raspberry Pi. Meanwhile, my RPi has arrived at EDIS’ data center in Graz, Austria. I transferred all relevant files and database tables from this WordPress installation to the new home on the RPi. I had to tweak my LAMP installation to reduce the memory footprint because the default settings for Apache and MySQL tend to eat quite a bit of RAM. When I started testing the WordPress installation, something interesting happened: it took more than 10 seconds to serve a page.

I was able to speed up page loading using the WP-Super-Cache plugin, but any page which wasn’t served from the cache obviously still took a lot of time to load. Even though there was always enough memory available and the CPU load wasn’t that high, it took MySQL quite some time to respond to rather simple queries. Now, if it’s not the RAM, not the CPU, and not the network, the only thing left is storage. I’m using a SanDisk Extreme Pro UHS-1 card on the RPi. On my notebook, this card easily reads/writes sequential data at up to 70 MB/s. Based on my tests it looks like the RPi maxes out at 20 MB/s so using a fast UHS-1 card seems to be a waste of money, in hindsight. However, even just 20 MB/s won’t explain WordPress page loading times of 10 seconds.

I’m not 100% sure here but since SD cards are optimized for sequential data IO (that’s what’s important in cameras) they may be disadvantageous in situations where fast random access IO is needed – like accessing indexes and reading data records from a bunch of database tables. For the time being, this site is going to stay at its old place.

8 thoughts on “Colocating a Raspberry Pi Debian server in a data center (follow up)

  1. @AmmarkoV The solution you provided has worked well for me. You were right tmpfs partition has removed the latency due to SD memory and now its working much faster than earlier. Thanks for sharing it with us.

  2. Hey,

    I was wondering, is the USB port on the Pi is faster than the SDCard? I have thought about getting a Pi and putting it in a datacenter myself with an external USB HDD. Did they charge you full price or give you a deal since it was just a small Pi?


  3. Manuel, I was using php-fcgi.
    Once I open the WordPress admin site there’s not much memory left to use for caching the pages. And one thing you want to avoid is swapping to the swap partition on the memory card. In fact, I pretty much turned off swapping.

  4. @Jan Using cgi the php has to be loaded from the disk for every request. You should go for mod_php or fast cgi for apache and php-fpm in case of nginx.

    Installing a php-cache like apc or eaccelerator will help to (if you still have some spare memory). With apc you can save some reads with apc.stat=0, but you will to flush the opcode cache by hand: apc_clear_cache()

  5. You can try mounting a tmpfs partition ( 64MB would suffice I guess , in RAM memory ) and serving your ( cached ) web pages from there.. It will almost completely remove any SD card related latency

  6. After replacing Apache with Nginx I’m getting a clearer picture of what’s going on. When loading a web page, the php-cgi process shoots up to 97% for a few seconds. It looks like the real bottleneck is the CPU, not the SD card. Oh well, I can’t blame a $25 device for not being able to _smoothly_ run a plugin-loaded WordPress website on it.

    On a different note: looking at the very limited number of write cycles an SD card or USB flash drive can take, I wonder what this means for the lifespan.

  7. And if you put the root of your website, and the sql bases on a USB disk plugged on the pi ?

    With a regular hard disk, maybe it’ll be ok ?

    I’m saying this because I intend my pi to be my web server (owncloud, mail server, xbmc) to replace the actual (it’s an Asus EEE 900, celeron 900 Mhz 1Gb ram, 8Gb SSD + 160 Go of usb space)


Comments are closed.