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 two 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.

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 Vilros).
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 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 Amazon).

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.

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.

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.

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!

Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Content