Blog 53

When a development project gets closer to completion, it needs to go through some serious testing to ensure it functions as intended without breaking or slowing down. This is especially important for a high volume of traffic or transactions to ensure continuous service availability. One of the best ways of finding out how the system will perform is load testing. But what happens when you want to do it on a smaller scale, in a short time and on the cheap? You go for Raspberry Pi.

Our team is currently working on a gambling project that needed to be load tested to find out how it would perform with numerous user interactions and lots of traffic. We needed to do this frequently as we continue to add new features to the system and it’s important to understand how each development affects it.

Generally, we use cloud for our test environments due to the ease of management and a low capital expenditure needed to spin up new environments. However, the cloud is not a place to do load testing as under maximum stress your VM’s CPU is going to run at 100% and this is where the cloud charges a lot. Another deciding factor is the cloud is a shared environment and if you’re neighbour is also maxing their machines out then this will adversely affect your performance.

So we needed a separate environment to hold test simulations and physical hardware. We had limited space in our server room and not enough power to run additional servers. We also wanted to make it as cheap as possible, so we created everything with the help of 20 Raspberry Pis.

Raspberry Pi is one of the smallest, cheapest and most reliable computers for programming. You can easily learn to code or experiment with different projects with it. The cost, size and wide availability of Raspberry Pis beats any other options and they also use a low amount of energy.

The recipe for Raspberry Pi load testing

One of the challenges with using Raspberry Pis was the heat. Because Pis are aimed at home use and rather easy tasks, they generate a lot of heat during something as heavy duty as load testing. To overcome this, we placed two heatsinks onto each of them and attached four USB fans to keep them cool, which did the trick.

We chose jMeter as the tool to run distributed load testing, which requires a JVM (Java virtual machine). Because Oracle, as the official owner of Java had stopped support for ARM-based processors used by Raspberry Pi, we had to try alternative open source JVMs which support the ARM processor and can deliver a high performance.

We used jMeter Master to interact with jMeter Slave running on the Pis, sending various testing commands. This means that each Raspberry Pi acts as a virtual user and jMeter Master controls it to access the system that’s being tested (load environment) and collects results for our testers to analyse. The network diagram looked like this:

The test case we wrote gave the system a number of scenarios to run through. For instance, we could use all 20 nodes (Pis) with 10 threads (users) per node. This meant that the total concurrent simulation was 20x10=100. Based on our testing, we could deliver 10,000 (500 threads per node) from 20 Pis deployed. We could easily add more Pis to the cluster without it costing too much.

The advantages of using Raspberry Pi

The results can be varied and depend on what testers want to measure, such as average speed of the whole system or resource consumption of parts of the system. We can monitor the system in real time or let it run over the weekend to see the results. Once the test is done, we’ll be able to make any necessary changes accordingly and make sure that the end product can withstand traffic when it’s live. We can also add as many features as we can and change test scenarios to determine how everything performs before it goes live.

This experiment shows that you don’t really need expensive equipment or complex processes to carry out load testing. You can scale it according to your needs and create a number of scenarios for the test. Using something as simple as Raspberry Pi can do the job just fine. You can do it as frequently as you like and it takes a lot less time and money to set up. We highly recommend load testing for anyone that has or expects high volume of traffic to their product to make sure everything runs smoothly once it launches

Loading Icon Loading