LAMP on a Raspberry Pi

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!

Another update to wiringPi

Thanks to Keith Wright for diligently testing it and pointing out bugs for me – fixed some issues in the gpio command, and while I was at it, I added in 2 new functions to it to allow for easy exporting/unexporting of the /sys/class/gpio interface – so now you can write a little script to do the exports for you, then run your own program that uses that interface (e.g.) a Python, shell, or php script, then un-export them afterwards, all without needing to be root (or use the sudo command)

WiringPi – Another bug, another day…

Just uploaded a new version of wiringPi  with a few bug fixes. the main one being in digitalWrite when the range check for the pin number was fine when it was wiringPi pins, but not fine for the newly introduced GPIO pin numbers.

I’ve also added in some additions – a shiftIn/Out module and a serial port access module. These are just handy additions, but I use them myself in other projects, so it’s a handy place to keep them.

As usual, fedback welcome!

-Gordon

Raspberry Pi – Game Port IO?

My little ladder game seems to have generated some interest – or was it my comment about the GPIO port standing for Game Port IO? Who knows, it’s fun anyhow…

But it’s got me thinking – what else can I do with a row of LEDs and a button. The Ladder game isn’t original, it was from a magazine published over 30 years ago, but what else can I think of to use on the same platform…

Some sort of reaction tester? shooter? Will crank up my imagination and see what comes up, but suggestions are welcome!

Cooking…

No updates for a while as I’ve spent most of this week cooking. If every you think that running a little baking hobby business is fun, then great, it is fun! Until you decide to take on doing an afternoon tea for 100 people…

More when I can get more time out of the kitchen… Lost count of the number of scones but I think it’s close to 200. 8 big cakes (Lemon Drizzle, Chocolate, Victoria sandwich and coffee & walnut), 100 mini cup-cakes, and 240 slices of bread into dainty sandwiches!

Then there’s tea, lemonade, lashing of ginger beer (non-alcoholic) and so on…

If only the weather was looking better… Ah well, we do have an indoor hall as well as a big garden!

— Quick update after the event. A huge success with most of the food eaten! If you want photos, they’re over on our Moorbakes site.

UCubed 2012 @ MadLab in Manchester

Friday saw me on a train to Manchester to attend the 2012 UCubed Unconference and what a great time it was too.

I went just because I could! But I also had my Raspberry Pi to demo as well as showing my BASIC interpreter running on it along with all the other stuff that comes with it – The Debian install and LXDE desktop. It generated a lot of interest indeed!

The Raspberry-Pi table at UCubedIt generated so much interest, that I barely had time to see and talk to more people! However I did attend the talk given by Alan O’Donohoe and on my way to the station, Alan put me on the spot for a quick audio-boo on IRC!

Some of Alans photos of the day can be found here

Another chap who caught my eye was Julian Skidmore of the Fignition project. Pretty amazing stuff – he has an Atmel 8-bit chip (same as Arduino chip), displaying video entirely in software and it runs a variant of FIG Forth.

The venue for the event was Manchesters MadLab a pretty fantastic place!

Thanks to Alan, Les and the others for organising it. It certainly made a nice change from sleepy Devon!

Got my Raspberry Pi!

Here we go! My Raspberry Pi has arrived and I’ve been having some fun. First job was to secure the additional bits and pieces for it – USB keyboard, mouse, powered hub and (still on order!) HDMI to DVI adapter.

First impressions? It’s small – but then again, so is the main-board inside your average mobile phone which these days is actually more powerful than the Raspberry Pi, so I really shouldn’t be surprised!

First task was to boot it up – I’d already prepared a 4GB SD card with the latest Debian image on the Raspberry Pi website. I plugged it all together and before long (really, 5 seconds) it was booting up. Part of their boot-up sequence involves a reboot, but that only too a few more seconds and it was there. Login with the published details and that was that. One more Linux box to my collection!