As web servers can generate relatively high amounts of filesystem I/O I’ve repurposed an old 64 GB USB SSD to help offload some of this traffic.
The Pi is physically hosted at my home and hooked up to the ‘net via a Plus.net Fibre Optic line.
The base system is:
- Linux in the guise of the Debian-based Raspbian distro,
- Apache as the web server software,
- MySQL for the RDBMS,
- PHP for the scripting language.
Out-of-the-box this LAMP mix is not great on the relatively meagre resources of a Raspberry Pi so a fair bit of tweaking will be needed to keep the system stable and optimal.
Hardware & OS
The first obvious area for optimisation is the SD card which drives the whole show:
- The number of read/write cycles to any form of flash memory device is finite. SD cards are best suited to infrequently storing large files e.g. Images from Digital Cameras. Even with an SD card’s built-in wear leveling it’s better to use storage media that’s more suited to the task.
- SSDs are about 10 times faster than SD cards:
Media Read (MB/s) Write (MB/s) Transcend Class 10 SD card 20 17 Kingston SSD 200 110
- SSDs tend to be a little more capacious than SD cards; 64GB vs 8GB in this case.
Things we can offload to the SSD without violating the Filesystem Hierarchy Standard too much:
/srvdirectory. This will include web site files.
/var/lib/mysql; MySQL data directory
/var/swap; The OS’s swap file