Building a Raspberry Pi Cluster
Once upon a time…
So this is how this story began…
The Raspberry Pi has fascinated us geeks from the time it was first announced. We were thrilled to hear that Eben will be presenting at WSO2Con, and even more thrilled when Sanjiva suggested that we should host the WSO2Con Conference App backend on a Raspberry Pi cluster. Say what? Sanjiva always comes up with crazy ideas. The initial briefing was on the 23rd of December, 2012, one day before the team went off for the end of year holiday break. At that time, we were not even sure whether it would be possible to run enterprise grade middleware on the Raspberry Pi. But exploring the unexplored is the norm at WSO2, and achieving the impossible is something we do on a regular basis. So a bunch of daredevil WSO2 geeks took up the challenge of building this system. The project officially got off the ground on the 2nd of January this year.
Running Java & WSO2 middleware on Pi?? Are you nuts!
One of the alpha geeks at WSO2, Lakmal, had managed to get Java running on the Raspberry Pi & had even managed to get WSO2 AppServer running. However, a major worry was that it took up to 6 minutes just to start the AppServer on the Pi. This was unacceptable to us & we decided that we had to be able to optimize our middleware to be able to run on resource constrained environments. The Raspberry Pi model B has only 512MB of RAM & a 700 MHz ARM processor. Two Carbon geeks, Sameera & Pradeep took up the challenge of optimizing the Carbon kernel to run on such constrained environments, and were able to introduce the concept of optimized mode to the Carbon kernel in the process of doing so. They were able to get the start up time down to close to 1 minute!
A nasty surprise!
One of the major surprises came in the form of the memory configuration of the Raspberry Pi. Even though we had the model B which has 512MB RAM, raspi-config & free only showed 256MB! We thought that we had hit a brick wall! After all, we had just 3 weeks left for the conference & there was no way that we could get another shipment quickly. But the “never say die” WSO2 team searched for answers on the web, and found that there was a lot of misinformation. Finally we figured out that a full apt-get update followed by an apt-get upgrade & raspi-config update solves the issue. Now all 512MB was available, and using the raspi-config memory split functionality, we reduced the memory allocated to the GPU to 16MB because the GPU was going to be of little use for our application.
I have the power!
Another major challenge we faced was supplying power to the Raspberry Pi cluster. Individual power supplies was going to be too costly & impractical. So we decided to build our own power supply. We built USB power distribution boards which were powered by regulated 5V power supplies. The Raspberry Pi model B draws between 700-1200mA & the voltage between the two test points on the board, TP1 & TP2 has to be maintained between 4.7-5.2V. Initially we ran into a few hiccups where the voltage dropped well below the 4.7V threshold. After analyzing the circuitry, we discovered that the 1-2 Ohm resistance in the wires was causing this voltage drop. We were able to solve that problem by using thicker low resistance wiring, and build the board so that the voltage drop across the power board was less than 0.5V, which is less than the voltage drop across a standard diode. Electronics geek Sumedha is currently building a couple of regulated power supplies. Here are some photos of the board & power supply in action.
For more detail: Building a Raspberry Pi Cluster