How I set up my 3x2 GB cluster computer for only $40

Zolboo Erdenebaatar
6 min readAug 29, 2020

Distributed Systems is fascinating to me. This fascination partially comes from the intricate and systemic interaction between several computers. However, whenever I work on a certain project or do assignments related to distributed systems, it’s not fully satisfying because I only have one machine to run the program on and I have to imagine that threads are machines. Sure, I could have multiple VM’s running on my only laptop but 1. my laptop only has 8 GB of RAM and 2 GB of free storage and 2. I felt like I needed something tangible, something that I can physically touch to really feel like I am learning. I needed a testbed. So, I needed hardware and I needed them cheap. When I was brainstorming, I remembered that old Android phones are extremely cheap second-hand and Android is built on Linux. After one eBay search, I found 3 Android phones for $40. If you look up “a lot of Android phones” on eBay, you can also find similar deals: link. To complete the cluster, you ideally want to use a dedicated local network. Luckily, I already had a router set up from previous projects to complete the network.

Getting the Machines Ready:

Once I had the machines, I wanted them to act as servers. To do that, I ideally needed to run Linux on the phones. Unfortunately, I could not root them but I found a method to simply run a VM on each of the phones to run Debian. Here’s how it works. First, you need to install two applications:

  1. Termux- which will act as a virtual terminal
  2. Andronix- which provides us with various Linux distributions and documentation on how to get them up and running. (Both of them are open-source so please consider contributing)
  3. (Optional) VNC Viewer- which provides a graphical interface for the virtual machines.

All of which will look like:

A $13 phone!

Then, follow the instructions on Andronix and install Debian (or any of the Linux distributions that you prefer and that Andronix has available). Andronix even provides you with the command for Termux to download and start the machine.

The entire cluster installing Debian at the same time.

Once you have Debian downloaded, it gives you a .sh file to just simply run. Quick note though: it is generally a bad practice to run straight from the root so please make an actual user in the machine and then run from that user if possible. I was simply setting up a testbed so there was really no risk but thinking back, I still should have set up a dedicated user for this task. Regardless, when you have the Linux up and running, it will look something like this:

As you can see, we can do simple commands such as ls and apt-get.

Typing on a small experience is not a good experience, though. If I could control these machines from an actual computer, that would be so much better. So, I needed to set up an SSH connection. To SSH, we needed the IP address and we also needed to install OpenSSH on the machines. Read more about SSH at this link. However, if you noticed in the last picture, I can’t figure out my IP address because it is giving me the error that ifconfig command does not exist. To fix this, simply install net-tools by running the command:

$ apt-get install net-tools

We can also install OpenSSH while we’re here:

$ apt-get install openssh-server

Once we have these set, we can get the IP address of the machine. In order to do that, run ifconfig and look at the IP address associated with wlan0:

The spot that I crossed out in red is where your IP address will be.

and start the OpenSSH by running the underlined commands:

Once we start the SSH server, we can simply connect it from any terminal. For example, if I wanted to connect from my Mac laptop, I will simply just run the ssh command which will look like:

where the red tape is where you would put your IP address from the ifconfig command.

Getting the Cluster Ready:

Once we can SSH into each of the machines, I was ready to connect them together to start building the actual cluster. Before we work with the servers, we have to set up the network through a dedicated router. We want to enable DHCP protocol and for simplicity’s sake, use WEP encryption.

Note: When you set up DHCP, most routers will allow you to select a range of IP addresses. Select one and make a note of it. The tradition for LAN is to use is 192.168.0.* with the subnet mask being 255.255.255.0. My router defaulted to this and I did not change it.

Although WEP is easily hacked, since I was not using the cluster for anything valuable, I figured it was enough. Setup process is different for different routers so you might have to read the specific manual associated with your router to set it up. Make sure the network name it something noticeable and to save your passwords so you can actually connect to the network later! For mine, I named mine “40bucks_cluster” and set the security to WEP. Just as an example, my starting setup page look something like:

[This part is partially inspired by OctaPi] Now that I had the router set up, I needed a few things installed:

  1. Python: Dispy is built on Python.
  2. Dispy: is a generic Python framework designed to allow us build programs that requires distributed and parallel computing. The most important part is that it makes communication (such as RPC calls) between nodes on the cluster extremely easy by providing a library of them.
  3. nmap: although it is a security tool, it will help us find open networks around you and join them. It also allows you to quickly identify other nodes that are on the same nodes as your device. This will help us because you want to be able to connect to those nodes.
  4. psutil: provides CPU reports. It is utilized by Dispy.

Now that we have the necessary tools ready, we are ready to start connecting. On each of the machine, to connect to my local dedicated network, I ran:

$ iwconfig wlan0 essid 40bucks_cluster key s:MY_PASSWORD

Where you would put your password where it is stated. Note that this command only work with a network with WEP encryption. Once all of the phones / “servers” are connected to the network, we are ready to set up the client machines and start testing.

Getting the Client Ready:

The client needs the same tools as the servers: python, dispy, and nmap. Once you have those installed, we can use the same iwconfig command to connect to the local network. Once we are connected, get off the internet! We will use the nmap tool to connect to the other servers and if you are connected to the internet, you might get charged for hacking because nmap is a powerful tool.

Now, we will make the client connect to the servers through SSH. In order to connect through SSH, we need the IP addresses of the servers. We can use the nmap to find nodes on the local network:

$ nmap -sP 192.168.0.*

This will give you the list of IP’s of the servers on the network. Now that we have the addresses, we will get the key to authenticate the client in the server:

$ ssh-keygen

and then allow share it with the servers so that they can connect to the client:

$ ssh-copy-id -i ~/.ssh/id_rsa.pub SERVER_IP_ADDRESS

After this, my cluster was ready!

--

--