So after a conversation on IRC where the general gist was that apache was bloated and slow vs. lighttpd, I thought I’d try a little experiment today – see how long it might take to compile up Apache, PHP and MySQL and get it going on a Raspberry Pi… Then stick a wordpress on it.
(And in-case you found this looking for a comparison, sorry – I don’t have one, lighttpd may well be smaller & faster than Apache, but I’ve not done any tests myself – I was just interested in how well or badly my “usual” apache/mysql/php setup I employ on my server fared on the Raspnerry Pi)
So I decided to compile them from sources – which is what I often do anyway rather then use the Debian supplied versions – mostly to see how long it would take doing it that way, but also to try to only compile in the modules/features, etc. that I needed – hopefully to make it as “lean” as possible while still maintaining enough functionality to run WordPress.
My Pi was running Raspbian with a 3.2.21 kernel, and the memory split at 244MB.
Versions of the “AMP” stack are: Apache: 2.2.22, MySQL: 5.1.61 and PHP: 5.3.10.
MySQL took some 2.5 hours to compile and resulted on about 260KB of swap being used. Apache was a bit quicker at 1.5 hours, but surprisingly it used a little more swap – up to 680KB. The configure and compile for PHP took it up to nearly 900KB. (however I did start up MySQL during this phase to finish the installation of it, but shut it down once I’d finialised the installation)
Watching the system with ‘top’ while it was compiling, it seems the GCC compiler doesn’t really need much more than 60-80MB of RAM, so the few little things that got swapped out are really just making more buffer space – so I imagine the compiler and associated programs stay cached in RAM for the duration while will speed things up somewhat. The bottleneck really seems to be the CPU, so I doubt putting the files on USB drive, NFS, etc. would make any difference to it all – the system runs at >95% CPU running gcc for a good few minutes for each file, so optimising the few seconds of disk IO doesn’t really seem worthwhile.
Typical of top during PHP being compiled:
KiB Mem: 222744 total, 185080 used, 37664 free, 10000 buffers KiB Swap: 131068 total, 868 used, 130200 free, 71484 cached PID USER PR NI VIRT RES SHR SWAP S %CPU %MEM TIME+ COMMAND 14053 root 20 0 83580 73m 6904 0 R 98.1 33.6 3:00.28 cc1
The whole process is very reminiscent of installing the LAMP stack on an older server – a PIII/800MHz many years ago. (And I had about the same amount of RAM then too!)
… Some time later and it’s running.
And so what can I say… It’s slow. I’ve tweaked the apache config somewhat and it’s still slow. What makes it slow… It seems to be a conbination of lots of things – PHP is quite large, so that eats up some RAM. MySQL likes to do fflush() operations which make the underlying filesystem somewhat slow. (however using phpMyAdmin on the server was OK, so maybe wordpress really is a bit big and bloaty afterall!)
Next week (if I have the time and enthusiasm!) I’ll start to try some of the newer servers and configurations and so on… Watch this space, but don’t hold your breath!