What’s the Point of a Raspberry Pi Cluster?
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?
Yes, the Raspberry Pi is cheap but the performances are not optimal.
So why could we need a Raspberry Pi cluster?
More RAM?
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.
More CPU?
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 256 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.
Need some inspiration for your next Raspberry Pi project? Get access to my personal list here!
Download now
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.
Basic Cluster
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.
Docker
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.
Need some inspiration for your next Raspberry Pi project? Get access to my personal list here!
Download now
I’m writing a blog post on @docker and @Raspberry_Pi – it’s probably never been easier to create a cluster and deploy code pic.twitter.com/KD2MIIrAx9
— Alex Ellis (@alexellisuk) August 19, 2017
I don’t have a tutorial about this, but you can read this one that explains everything
Kubernetes
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.
Supercomputer
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!
Web server
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).
If you are interested in this project, there is a blog post on the Raspberry Pi Blog.
Mythic beats is the host they used. By the way, you can try their services here.
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
Related question
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.
It's a free PDF guide containing every Raspberry Pi Linux command you should know!
Download now
Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.
Conclusion
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!
Whenever you’re ready, here are other ways I can help you:
The RaspberryTips Community: If you want to hang out with me and other Raspberry Pi fans, you can join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
Master your Raspberry Pi in 30 days: 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 multiple projects with step-by-step guides.
The Raspberry Pi Bootcamp: Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.
You can also find all my recommendations for tools and hardware on this page.
Could a raspberry pi cluster like this be used for running a home gaming server like for minecraft or CSGO ?
A Minecraft server would work but I don’t know if CS:GO servers are able to run on a ARM CPU
Thats’ a good question because Raspberry Pi OS comes with minecraft by default now.
Can you build a cluster for crypto mining ? What’s the combined hashrate of a few RPs?
I think it can be, I read a news where some hacker used someone’s (not sure university’s or organization’s ) super-computer to mine Bitcoin. And above it was mentioned that we can built a super-computer using PI and in news it was clear that super-computer can be used for mining , so yeah I am pretty sure we can built a PI cluster as a mining rig .