Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Machine Heart Compilation

Machine Heart Editorial Department
Coding, writing blogs, and making fun projects are common ways for programmers to level up. Many experts have a habit of writing blogs and are quite hands-on. Today, we introduce WILL HO, a machine learning enthusiast who enjoys blogging. He not only registered his own blog site but also built a 28-core Raspberry Pi cluster for self-hosting. During this process, he learned many skills including Linux, Docker, Docker Swarm, Kubernetes, DNS, TLS, and network topology.

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

In a recent blog post, WILL HO introduced his 28-core Raspberry Pi cluster named Kraken, which utilizes seven Raspberry Pi 3B units.
As mentioned, WILL HO built the Raspberry Pi cluster for self-hosting, specifically to host his blog site built with WordPress. WordPress is a blogging platform developed in PHP, allowing users to set up their own websites on servers that support PHP and MySQL databases, or to use WordPress as a content management system.
Previously, he had built a Raspberry Pi cluster named Octopi (one Raspberry Pi 1B+ and four Raspberry Pi 1B units), but he soon discovered that running WordPress on this cluster had significant performance bottlenecks, with a single page of a new WordPress blog taking about 10 seconds to load!

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

To resolve this bottleneck, WILL HO decided to upgrade Octopi, leading to the main character of our article today—Kraken. In the following sections, WILL HO describes his process of building Kraken. If you have a need to build a Raspberry Pi cluster or want to learn tools like Docker, you can refer to the author’s method to set up your own cluster.
Overview of Kraken
Kraken consists of seven Raspberry Pi 3B units powered by a USB charger. WILL HO initially intended to build a cluster with eight nodes, but the maximum number of ports on a consumer-grade network switch is eight, which accommodates seven nodes and one cable to the router.

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Another option was to use a commercial-grade network switch with 16 ports, but that was clearly out of the question considering the price.
The specifications of the Kraken cluster built with Raspberry Pi 3B are shown in the table below:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

The required parts list is shown in the table below:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Notably, the author chose a 32GB MicroSD card as storage for the first node and hopes it will be the master node for Docker swarm setup. The author anticipates needing additional storage space to build and deploy Docker images.

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Kraken (top) and Octopi (bottom)
Gigabit Upgrade for Kraken
The author found that he often reached the 100Mbps bandwidth limit on the built-in Ethernet port of the Raspberry Pi 3B. During the transfer of large files, the transfer speed even hovered at a frustrating 8MB/second.
Inspired by Jeff Geerling’s blog, the author discovered that using a USB Gigabit Ethernet adapter could increase the bandwidth to over 200Mbps. Therefore, he bought a bunch of cheap USB Gigabit Ethernet adapters and a Gigabit switch to start the upgrade.

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Cheap USB Gigabit Ethernet adapters.
Additional parts list:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

After the upgrade, Kraken looks like this:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Gigabit Kraken, Octopi, and my cable management nightmare
If all costs are accounted for, building this Kraken cluster totaled $508.84.
Benchmark Assessment
Running iperf before the upgrade showed a maximum bandwidth of 93.1 Mbps.
~ ❯ iperf -c 192.168.3.11------------------------------------------------------------Client connecting to 192.168.3.11, TCP port 5001TCP window size:  129 KByte (default)------------------------------------------------------------[  4] local 192.168.3.71 port 57041 connected with 192.168.3.11 port 5001[ ID] Interval       Transfer     Bandwidth[  4]  0.0-10.0 sec   111 MBytes  93.1 Mbits/sec
Running iperf after installing the Gigabit adapter showed a maximum bandwidth of 224 Mbps!
~ ❯ iperf -c 192.168.3.11------------------------------------------------------------Client connecting to 192.168.3.11, TCP port 5001TCP window size:  145 KByte (default)------------------------------------------------------------[  4] local 192.168.3.71 port 57298 connected with 192.168.3.11 port 5001[ ID] Interval       Transfer     Bandwidth[  4]  0.0-10.0 sec   268 MBytes   224 Mbits/sec
With this simple module, each node achieved a bandwidth of 131Mbps. However, these are still just theoretical speeds because typical usage scenarios involve writing data received from the network to disk, whereas iperf only receives data from the network without writing it to disk.
Some Considerations
Even in web services, it is unlikely to continuously utilize this new bandwidth fully. It mainly helps to transfer large resources (such as image data) faster during the initial load, after which users’ browsers will cache the images.
Moreover, the notorious shared USB 2.0 bus among Raspberry Pi models 1 to 3 also limits actual bandwidth.
For uninitialized users, the theoretical unidirectional bandwidth of a single USB2.0 bus at 480Mbps is shared among the Ethernet port, SD card slot, and all USB ports.
The bandwidth distribution is shown below:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

Despite the numbers in the table giving the impression that this upgrade did not bring performance improvements, they represent the worst-case scenario. Typically, the major operations expected on a web server are read operations, with very few write operations.
In the real world, bandwidth allocation should typically look like this:

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

The above is the author’s upgrade operation on the second Raspberry Pi cluster, but if you are already familiar with the Docker system or looking for high-performance home setups, this tutorial is not recommended.
Why Choose This Cluster?
If you are interested in Docker and Kubernetes, the author strongly recommends building a cluster like this. He provided two reasons:
First, this cluster is compatible with the latest official Docker images. Additionally, the Raspberry Pi 3B runs on the armv7 CPU architecture. The latest Arm processors (arm64) are backward compatible with all code written and compiled on armv7. In contrast, arm64 processors are not backward compatible with armv6 processors (Raspberry Pi 1 and 2), which are being phased out by the community.
Secondly, for most bandwidth-intensive applications, this cluster would be ideal, such as hosting your own blog, file synchronization services, media library managers, note-taking applications, etc. Considering the USB 2.0 bus bottleneck in the Raspberry Pi 3, if your application requires a lot of continuous writing (such as video encoding), the performance of this cluster may not meet the requirements.
In summary, building a Raspberry Pi 3 cluster is the most cost-effective way to learn Docker and clustering, and it will remain so for the foreseeable future. Therefore, if you just want to get acquainted with Docker, it is highly recommended that you give it a try.
Original link: https://ikarus.sg/how-i-built-kraken/

Amazon SageMaker is a fully managed service that helps developers and data scientists quickly build, train, and deploy machine learning models. SageMaker completely eliminates the heavy lifting of each step in the machine learning process, making it easier to develop high-quality models.

Now, business developers can receive a free service coupon worth 1000 yuan to easily get started with Amazon SageMaker and quickly experience five artificial intelligence application examples.

Building a 28-Core Raspberry Pi Cluster with Docker: A $500 Setup Guide

© THE END

For reprints, please contact this public account for authorization

Submissions or inquiries: [email protected]

Leave a Comment

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