The Raspberry Pi is an extraordinary single-board computer, useful for many home and educational projects. Although Raspbian is an excellent operating system, there are a few tricks to get the most out of your Raspberry Pi, especially if you plan to use it as a server.
Below is a series of tips to improve the Raspberry Pi’s performance and reduce its power consumption.
These tips do not involve overclocking (either CPU or RAM), as this could damage the Raspberry Pi’s hardware.
1 – Use the right power supply
Although a standard smartphone charger may be enough to power a Raspberry Pi, it is essential to check its output. Some chargers can only supply low current, so they may appear to work correctly while actually severely compromising performance.
Below is what the Raspberry Pi official documentation states:
“The Raspberry Pi 3 is powered by a +5.1V micro USB supply. Exactly how much current (mA) the Raspberry Pi requires is dependent on what you connect to it. We have found that purchasing a 2.5A power supply from a reputable retailer will provide you with ample power to run your Raspberry Pi. You can purchase the official Raspberry Pi Power Supply from our website, and you can learn more about the differing power requirements of the various models of the Raspberry Pi on our FAQ page.
Typically, the model B uses between 700-1000mA depending on what peripherals are connected; the model A can use as little as 500mA with no peripherals attached. The maximum power the Raspberry Pi can use is 1 Amp. If you need to connect a USB device that will take the power requirements above 1 Amp, then you must connect it to an externally-powered USB hub.
The power requirements of the Raspberry Pi increase as you make use of the various interfaces on the Raspberry Pi. The GPIO pins can draw 50mA safely, distributed across all the pins; an individual GPIO pin can only safely draw 16mA. The HDMI port uses 50mA, the camera module requires 250mA, and keyboards and mice can take as little as 100mA or over 1000mA! Check the power rating of the devices you plan to connect to the Pi and purchase a power supply accordingly.”
So make sure you use a suitable power supply, especially if you will be running power-hungry services.
2 – Installing ZRAM
zram, previously called compcache, is a module that creates compressed blocks in RAM.
novaspirit‘s RPI ZRAM improves on this by automatically detecting the number of CPU cores to allocate to ZRAM processing, disabling the existing swap and enabling ZRAM swap.
You can find more information on the ZRAM project’s GitHub page. Below are the instructions for installing RPI_ZRAM:
cd /usr/bin/
sudo wget -O /usr/bin/zram.sh https://raw.githubusercontent.com/novaspirit/rpi_zram/master/zram.sh
sudo chmod +x /usr/bin/zram.sh
Now we need to make this script load at every boot, so edit the /etc/rc.local file
sudo nano /etc/rc.local
and add the following line before exit 0
/usr/bin/zram.sh &
3 – Reduce GPU RAM
The Raspberry Pi shares its RAM with its graphics processor. So if you plan to use your Raspberry Pi as a server, you will probably want to allocate the minimum amount of RAM to the GPU. Here’s how:
Launch raspi-config from the terminal:
sudo raspi-config
Go to Advanced Options -> Memory Split and set it to the minimum value (16).
4 – Disable HDMI
Leaving the HDMI circuitry powered on a Raspberry Pi that you manage over SSH (i.e. without a display and/or keyboard) is a waste of energy. The Raspberry Pi documentation indicates that this circuitry can draw up to 25mA.
As mentioned earlier, power management can be crucial for these boards. You can switch it off with a simple command:
/usr/bin/tvservice -o
If you want this to apply at every boot, add this command to the end of the /etc/rc.local file (before the “exit 0” line).
5 – Use a fast microSD card
SD cards are to the Raspberry Pi what hard disks are to a personal computer. SD cards differ from one another in their read/write speed. Switching to a faster SD card is similar to replacing a PC’s hard disk with an SSD: it is like a generational leap.
Choose at least Class 10 microSD cards.
Enjoy!
