For the past few years, I have run a few websites on a Raspberry Pi 3B at home. I decided to do this just because I like to do some general tinkering with gadgets, but also because I thought it would be a cheaper way of hosting websites. But is the Raspberry Pi web server performance adequate?
Now I am going to share with you what I have learned whilst using the Raspberry Pi as a web server. You might even want to try setting up your own server.
Raspberry Pi Specifications
First, let’s take a look at the specifications of a Raspberry Pi 3B as listed on the official Raspberry Pi website.
- Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
- 1GB LPDDR2 SDRAM
- 2.4GHz and 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
- Gigabit Ethernet over USB 2.0 (maximum throughput 300 Mbps)
- Extended 40-pin GPIO header
- Full-size HDMI
- 4 USB 2.0 ports
- CSI camera port for connecting a Raspberry Pi camera
- DSI display port for connecting a Raspberry Pi touchscreen display
- 4-pole stereo output and composite video port
- Micro SD port for loading your operating system and storing data
- 5V/2.5A DC power input
- Power-over-Ethernet (PoE) support (requires separate PoE HAT)
As you can see, the Pi as a relatively low spec device, so you will not want to use this for websites with high volume traffic. Similarly, it works best with static websites as these require less grunt to run. I currently have a couple of WordPress websites running and they sometimes struggle to render the web page. Given the importance of website load times on SEO, this can be a problem.
Web server on an SD card?
WordPress and other Content Management Systems read and write to a database. This adds additional work for the Pi to perform before it can render the webpage. These read and writes are being made to the micro SD card, which is a slow-performing storage medium. SD cards are great for storing photos on your camera or maybe some MP3 files. Sadly, they do not perform well on a live web server. Quite simply micro SD cards are just too slow and unreliable. However, reliability can be addressed if you at least purchase a high endurance SD card.
When you can consider why people use WordPress; they want to update content regularly, then you can understand why frequent writes to the card are necessary. If you run a static website then you likely do not want to make changes to the website content often. In this case, you can simply take a backup image after finalising your website content and always have it ready to be reinstalled. However, doing this on a regular basis for a frequently updating WordPress website would just be a pain. You would have to shut down your server, remove the card for imaging and then reboot the server. All this time your website is unavailable. A guaranteed way to be given an SEO penalty by Google.
Furthermore, in my experience, the CPU and memory are not the biggest issues with running a website. I have Ubuntu Server installed on a 32Gb micro SD card. This card is frequently corrupting. Even when using one of the Raspberry Pi foundation’s recommended micro SD cards. Unfortunately, the Raspberry Pi web server performance is seriously inhibited by the use of an SD card for storage.
SD Card Solution?
On Pi forums, it’s often suggested that corruption happens when there is a power cut to the server whilst the writes are being made on the card. This may well be an issue but I have noticed that when the server is under high load corruption occurs. This is caused by the Pi overheating and crashing and could be addressed by using a heatsink. No power cuts involved at all. Admittedly, I do not use a high endurance SD card.
A possible solution to the SD card corruption problems is to try and reduce the number of writes taking place by disabling logging, but if you are running a live server you really need log files to keep on top of any server related issues.
Another solution is to boot the Pi from a USB device rather than an SD card. Thankfully, this can now be done on some models of Pi. The best option here would be to use a powered SSD drive.
To be extra safe you could also add a battery pack to the Pi to protect against power cuts. A simple power pack such as the type you would use to charge your mobile phone on the move might suffice. You just have to make sure it can be plugged into the wall and the Pi at the same time. Also, make sure you buy this battery pack from a reputable manufacturer. We don’t want it bursting into flames if left plugged in. It is always best to check the documentation to ensure it is safe to leave it connected to a power outlet. If in doubt, do not use it.
There is also an official battery module for the Pi. So it’s worth having a look at that too.
The bandwidth of the network ports on the Pi are generally fine for low-ish traffic websites. Obviously, if you are receiving 500k visitors a month it’s best to get dedicated hosting. But for a small business or a personal website, you shouldn’t have any real issues.
I tend to use the Pi 3B to host personal projects. There is no real requirement to place personal projects on a premium web host. It saves money on hosting costs, but I always use dedicated premium hosting for client websites and high-traffic sites.
Recently, I have started using a Raspberry Pi 4 for website hosting using an SSD for storage. This is a superior solution and if you would like to find out how to do this, you can read my in-depth blog post called Running a Live Web Server on a Raspberry Pi from Home.
The Raspberry Pi is a great little, low-cost, low-power consuming minicomputer. It has many different applications but generally not really suited to a live server scenario. However, if you like to tinker and save yourself money on web hosting fees then why not give it a try? You might learn a bit about server maintenance, which is a useful skill to have. You just have to be aware of the Pi’s limitations.
Essentially, the Raspberry Pi web server performance is fine for low traffic, static websites. Your mileage may vary when running a CMS on it. But some of the problems can be negated by adding an external hard drive. Obviously, this will add a little extra to your electricity consumption but is generally worthwhile just to have a more stable server.
You could also consider the newly released Raspberry Pi 4, which has a more powerful CPU and up to 4Gb of memory.