Building the Raspberry Pi Server

What is the Raspberry Pi

For those who haven’t heard or don’t know what a Raspberry Pi is, it is a small inexpensive single-board computer. There are five generations now, including the Zero, and each generation has a few variants – similar to mid-cycle refresh for a car.

The latest one, at the time of writing, is the Raspberry Pi 8GB, which came out in May 2020.

To give you an idea of what to expect in terms of computing power available, below are the key specs for the Pi 4 from the Raspberry Foundation:

  • Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz
  • 2GB, 4GB or 8GB LPDDR4-3200 SDRAM (depending on model)
  • 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE
  • Gigabit Ethernet
  • 2 USB 3.0 ports; 2 USB 2.0 ports.
  • 2 × micro-HDMI ports (up to 4kp60 supported)
  • H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode)
  • OpenGL ES 3.0 graphics
  • Micro-SD card slot for loading operating system and data storage

The best part? They cost as low as $13 CAD for the Pi Zero W and up to $94 CAD for the Pi 4/4 GB (the highest RAM model available on Amazon).

A basic explanation of the hardware (optional read)

As promised, I will quickly define what some items in the specs are and what they mean. You may skip to the next section if you already know or you just don’t care.

The processor is 64-bit, which is the common design and architecture for modern central processing unit (CPU). A bit is the smallest unit of data a computer uses. 64-bit is an upgrade to older 32-bit CPU’s as it can process 64 bits of data in parallel. Imagine a four lane highway expanding to an eight lane highway, which allows twice the number of cars going from point A to point B. While not entirely accurate, this is the similar concept of bandwidth – how much data can be transferred at one time.

1.5 Ghz is the clock speed. As the computer processes instructions in a cycle, it uses hertz as a unit of measurement used for frequency. One hertz is the computer executing one instruction over one second. A kilo is one thousand (1000), a mega is one million (1,000,000), and a giga is one billion (1,000,000,000). A CPU that is rated at 1.5 Ghz means that it can process 1.5 billion cycles of execution per second.

Quad-core means the CPU has four logical (vs physical) computing units. So it still has just one brain, but the one brain can function as four. This allows for multi-tasking.

Remember how we used to have Intel Pentium 4 CPU’s with 3.8 Ghz? Well, now with quad-core processors, they can do four times the work of a single core processor plus, with the 64-bit architecture, twice the amount (again, not exactly as it is more complicated than that) of data can be processed at the same time. So at 1.5 Ghz, the performance of the Pi is about three times as capable as the top of the line processors from a decade ago.

Random-access memory (RAM) is the fastest (aside from cache) memory and is preferred by the CPU to use for applications. It differs from disk storage (your hard drive or in the case of the Pi, the microSD card) as it is volatile, so it can only hold data when there is power. When your computer is off, the RAM is empty. This is why we cannot store our long-term data in RAM, and use the much slower hard drive instead.

Think of your RAM as your workspace. Now, imagine your workspace as the size of your bathroom. The operating system is like the bath tub, toliet, and sink that restrict how much actual space you have. Your process is to build a bed frame that you have bought from Ikea. Your instructions are the code written by the application developer and they’re inside the washroom so if you want to read the next step, you have to be in the washroom. The bedroom is much bigger, and it is your hard disk, where the bed will end up. At first the pieces are unloaded in the washroom. You go into the washroom with a few pieces and start on building the bed frame. Eventually, you run out of space and have to move some partially built pieces back to the bed room and continue. How many trips you make will depend on how big your washroom is. If it is huge, you can build the whole bed in there and move it to the bedroom as one piece, taking less time. If it is tiny, you can’t build the bed at all.

Now, let’s look at this in the context of the computer.

If you have the same processor but different amount of RAM, you will see a difference in performance when working on a memory-intensive task as the computer will manage the memory differently.

Take the following for illustration purposes only.

CPU1 with 2 GB of RAM, when working with a process that requires 2 GB of memory, will allocate some of its computing power to move data from storage (in the Pi’s case, the microSD card) to RAM, and after using the data, move the data back to the storage. There are not actually “thresholds” but let’s say at 50% of memory used, it starts memory management to free up some memory, and at 70%, it gets a bit worried. At 90%, its in panic mode and drops everything it’s doing to focus all of its processing power on moving data in and out of RAM.

CPU2 with 4 GB of RAM goes through the whole process and finishes before it even needs to consider memory management.

CPU’s are actually much better at memory management than the illustration above and CPU2 would still conduct memory management even if the computer has much more memory than is required for the process. When all available memory is used, however, it does go into something called thrashing, which is the moving of data in and out of RAM and disk storage. Your computer would be unresponsive until the memory situation has been sorted.

By the way, an uppercase B stands for byte, whereas the lowercase b stands for bit. One byte has eight bits. Our data is stored in bytes but data is transferred bit by bit.

802.11ac is the current specification for your wireless fidelity (Wi-Fi). It operates on two frequencies – 2.4 Ghz, and 5.0 Ghz. Higher frequency means higher energy but also shorter wavelengths. 5.0 Ghz allows for higher data speeds, but at the cost of smaller service area. In a large home, you will need a higher-end router or Wi-Fi extenders.

Not all countries allow for Wi-Fi to operate at 5.0 Ghz, which is why later when we setup the Pi, you have to enter a country code for you to connect to a 5.0 Ghz network.

Also, don’t confuse Wi-Fi 5.0 Ghz with 5G – the fifth generation mobile network.

Bluetooth 5.0 is the newest specification for the short-range personal area network. In simpler terms, its a technology for connecting multiple devices wirelessly with a small range (50-ish feet).

The exciting feature of Bluetooth 5.0 is the ability to connect to two audio devices simultaneously. You can now connect to two pairs of headphones to your device to share the music, or you can connect your headphones to two playback devices. For example, you can listen to music on your phone, then you pause the music, and watch a YouTube video on your computer – all without touching the settings/control panel to connect/disconnect.

BLE is Bluetooth Low-Energy, which enables many more devices to be connected than the traditional Bluetooth. It is a separate specification that shares the same name.

Universal serial bus (USB) 3.0 is an update to the widely popular wired connector standard. It allows for data transfers up to 5 Gbps or 625 MBps, while USB 2.0 has a max speed of 480 Mbps or 60 MBps.

The Pi 4 has two micro-HDMI, which requires a fitting cable or adapter to connect with your TV or other display. It allows output at 4K resolution. The most common resolution deemed 4K is ultra high definition (UHD), which is 3840 pixels by 2160 pixels. It is marketed as “four times” the resolution as it has twice the number of vertical and twice the number horizontal pixels as 1080p high definition (HD), which is 1920 x 1080. Realistically, it is only twice the resolution. Only one of the micro-HDMI port may be enabled for 4kp60 – the 60 is the refresh rate of 60 hz. As a reminder, hertz is simply a measurement of frequency per second.

MicroSD is the physically smallest format of the non-volatile memory card in the Secure Digital (SD) family. Most cards these days are in the classes of ultra high-speed (UHS). UHS-I has a minimum write-speed of 10 MBps, and 30 MBps for UHS-III.