Clusters on Raspberry Pi is a trending topic on the Internet (you find tests, tutorial and awesome pictures everywhere).
I also did a tutorial a few months ago on how to create a basic cluster with two Raspberry Pi, but I got many questions about why might we need one.
Read on if you want the answer 🙂
What’s the point of a Raspberry Pi cluster?
The goal of a Raspberry Pi cluster is to combine the performances of several devices into a stack.
Building a cluster is a fun project, and it can also be useful for applications that require many CPU cores, but not so much execution speed.
To go further, I will start by explaining the logic behind a Raspberry Pi cluster, and then give you some inspiration with several cool examples.
By the way, if you don’t have a budget to afford a course for now (if you just got your Raspberry Pi stuff, I completely understand), you can join Skillshare for a free 14-day trial. It includes courses from the best teachers in many categories, including IT (Linux, programming, …) and Raspberry Pi. I highly recommend getting this offer now so that you can already learn a bunch of things in the next fortnight. I’m a fan of their services personally 🙂
When can a Raspberry Pi cluster be useful?
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
Yes, the Raspberry Pi is cheap but the performances are not optimal.
So why could we need a Raspberry Pi cluster?
The first idea can be to build a cluster to get more RAM.
This may be a good idea if your application need a lot of RAM, but the total cost will not be the best choice.
Buying 4x Raspberry Pi 4 8 GB will be expensive for a cluster (8 GB on Amazon).
If you want to keep your money, a 32 GB total memory with compute module will be a lot cheaper than that (check the price on Amazon).
Yes, the memory module solution need a computer to host it, but you can use any old computer, it will probably be better than four Raspberry Pi 4.
The second idea can be to get a powerful CPU with several cheap Raspberry Pi instead of buying a traditional PC or server
Still, not the best reason for building a Raspberry Pi cluster.
As you can see in this benchmark (source: Reddit), the Raspberry Pi CPU are really low in performances. So, any cheap computer will do better in terms of CPU speed:
You will need over 10 Raspberry Pi 4 to match the Intel i3 performances.
The Intel i3 processor from the benchmark cost almost the same price as a Raspberry Pi 4 (check the current price on Amazon).
Yes, that’s only for the processor but you can also use an old computer (the first i3 was released over 10 years ago!)
You can even use an Intel NUC instead. This NUC has 8 GB RAM, a 240 GB SSD and Windows 10 included, so it’s a better deal overall (all details here on Amazon).
Faster disk access?
I will be quick on this one, you already know that a SD card is not the faster way to store or access data.
In general, we consider that recent SSD models are over 10 times faster than any SD card.
Even if Datalight has found a way to increase SD cards speed (check the summary on ZDNet), that’s not the way we use SD cards on our Raspberry Pi. And four SD cards, will never be faster than a SSD.
So if you want a faster disk, plug a SSD drive (it’s cheap now), use a NUC or any computer, but a cluster is not a good idea.
More CPU cores?
The last idea is want to explore is to have a huge amount of CPU cores with a cluster.
And in fact, that’s almost the only reason why you might want to build a Raspberry Pi Cluster.
About all Raspberry Pi models have a quad-cores CPU (the only exception are Raspberry Pi 1 and Zero).
So if you use 4x Raspberry Pi 4 1GB, you’ll get 16 cores available for less than $150 (twice the price on Amazon).
If you count in threads, the equivalent is a high-end Intel i7 (something like this). If not, the only processor from Intel with 16 cores is currently the latest Intel i9 Extreme Edition (ten times more expensive on Amazon).
And it’s even more difficult to find an alternative if you stack more Raspberry Pi (8x Raspberry Pi is 32 cores!).
Note: AMD could be cheaper for cores only, but I don’t really know this brand.
Raspberry Pi 4 vs Compute Module
So yes, the only reasons to build a Raspberry Pi cluster are:
- Looking for many CPU cores (but no performances required)
- Learning how it works
- For fun 🙂
To complete, this part, I want to introduce the Raspberry Pi Compute Module.
I rarely write about it because there is almost no interest for a home user.
The idea behind this product is to allow anyone to use the Raspberry Pi technology on another motherboard. So it looks like a Raspberry Pi zero, with no external ports, similar to a memory module (more details on Pi-Supply).
Except the other usages, it can be an awesome idea to build a Raspberry Pi cluster with compute modules only!
Each module has a quad-core CPU and is cheaper than most Raspberry Pi (check the above link for the current price).
But how to build it has there is no Ethernet port?
You need a specific board, and the Clusterboard is the perfect one to build a cluster (available on Pine64).
You can plug 7 computes modules on it for a total price under $300!
Do you know a computer with 28 cores cheaper than $300?
Not me 🙂
5 Raspberry Pi clusters examples
I will now give you five examples of clusters with Raspberry Pi, so you can get a better idea on how to use them and why.
The first one is just to build your first cluster. There is no specific end goal with it, except to learn how it works.
For example, if you have two Raspberry Pi at home (any models), you can follow my tutorial to try this.
You’ll have a master node and a second node.
In this basic example, I’m using the Python library: MPI4PY
This way you can run any command on both nodes
Running a command two times is not really useful, but if you have any script that can run on several cores, it’s already a good demonstration.
The next two are more technologies than examples, but it’s important to know how it works on the software part.
Docker is a technology allowing you to run an application in an isolated environment on any operating system.
This environment is name a container, it’s a bit like a virtual machine if you want.
You can have several containers on the same computer.
Docker has been created to facilitate the life of developers. It’s easier to code, deploy and run applications with it than to adapt to each system.
But Docker also includes clustering features, that are easy to install on a cluster.
— Alex Ellis (@alexellisuk) August 19, 2017
I don’t have a tutorial about this, but you can read this one that explains everything
Kubernetes is the next step once you master what is Docker and how it works.
In the previous tutorial, you may have seen that we use Docker to manage the application, and Swarm to use it on several nodes.
Kubernetes is like an upgrade to Swarm, with more features for scaling, running and monitoring the applications.
I never tried it yet, so I will not give you more details about this, but you can find plenty of tutorials on the web about this (for Raspberry Pi or Linux in general).
For example, there is a step-by-step tutorial on the official website.
Let’s dive to something more concrete now.
Once you understand and experiment the cluster basics, you can start to think bigger. It’s almost the same process, repeated many times 🙂
On this picture, you can see the Supercomputer from Los Alamos laboratory (source: ExtremeTech). It’s built with not less than 750 Raspberry Pi.
Scientists use this awesome cluster constantly.
The total cost is under $20,000, and above all the power needed is 5,000 times lower than other supercomputers. Yes, it not the same performance, but it’s already 3,000 CPU cores available, and they are happy to have it for “small” tasks.
So for specific needs and low budget, it’s really a good example of what you can do with a lot of Raspberry Pi!
Sale: 10% off today.
Get the eBook.
Do more with your Raspberry Pi, learn the useful concepts and take the shortcuts.
You miss half of the fun of using a Raspberry Pi if you don’t know anything about Python.
It’s not really different example, but as a more concrete example, you can also use a cluster to run a web server.
By the way, it’s exactly what the Raspberry Pi Foundation has done for the Raspberry Pi 4 launch
They use a cluster with 18 Raspberry Pi 4 to demonstrate that a cluster can do the job to host a good part of their web traffic for a launch day.
Nothing fancy in terms of technology, just Apache and PHP for the web part.
Yes, Apache can run on several servers and do some load balancing natively (all details here).
Can I use a Raspberry Pi cluster for gaming? Even if the idea is correct, running a game on a cluster requires the game to be written for it. Currently, most products are not optimized to do this. Even game servers, are mostly using one CPU at a time.
Also, don’t forget that you are on Linux, with a low-end CPU, not so much RAM and no gaming graphic card.
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
That’s it, you now have a better idea of what is a Raspberry Pi cluster, and what you can do with it.
If you are interested, you can follow my tutorial here to build your first one!
Support us: Join the community on Patreon to show your support, get behind-the-scenes content and other awesome perks!
Raspberry Pi Resources
Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now
Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiples projects with step-by-step guides.
Download the e-book
If you just want to hang out with me and show your support, you can also join the Patreon community. I share behind-the-scenes content there and give you early access to my content. You’ll also get a shoutout when you join.
More details here
Need help to build something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now
You can also find all my recommendations for tools and hardware on this page.