Load testing with JMeter.

Henrique Pacheco
Apr 21 · 5 min read

Do you know how many users can safely browse through your website without taking it down? To me, it is one of the most important metrics you need to know about your website. But the truth is, more often than not (because of reasons such as “the traffic is usually low”, “we have X servers just in case” (air-quoting here), or simply due to lack of time), we tend not to pay attention to such metrics.

In 2019, a celebrity tweeted a link to one of the platforms Vizzuality develops. Although this was amazing publicity for us, our client, and their website, it also required some fast action from our dev team to keep the website live as thousands of people clicked on the link this celebrity had shared.

Our dev team is usually ready to handle user peaks. 😅

A few months ago, we received news that a press release was being written about one of the features on this same website the celebrity had tweeted about. There was a chance of another spike in user traffic — and this time, we wanted to be prepared for it. So, we decided to load test the website. This way, we would know what our limits are, and we could act on this information if we saw the increase in traffic approaching the limits.

What is load testing?

Load testing is a subset of software testing focused on measuring a system’s response to high-demand input. Load testing can be put into practice in multiple ways, taking into account the system being tested. For example, we could load test:

  • a website to determine how it behaves when facing a spike in traffic;
  • an API to determine performance bottlenecks;
  • a GUI to see how it handles multiple users interacting with it at the same time or how it handles very complex objects (e.g., one could test Google Docs, with the intent of understanding how many people can use the same document at the same time).

There are many tools you can use for load testing. And, as in many other use cases, you can find tools ranging from open-source, free and simple to use, such as Siege and JMeter, to feature-packed, premium tools such as SmartBear’s LoadNinja. For this example, we will use JMeter since it was free, and its features match our use case.

Load testing with JMeter.

JMeter is an open-source tool built with Java that provides a GUI for creating load testing scripts. JMeter might look scary at first since its UI is quite complex, but you’ll be able to find tutorials online to guide you through the process. This one, in particular, is a good place to start.

For our use case, we decided to keep the test case simple. For that, we considered users would access the main page of the website one single time. Then, we consistently incremented the number of concurrent users (Number of Threads, in JMeter lingo) bombarding the website with requests. When the website started having trouble handling all requests, we ended the test.

We were able to understand that our infrastructure was able to handle 8,000 concurrent users accessing the main page in 1 minute without significant issues. With 10,000 concurrent users, we saw a small increase in response times. And with 12,000 concurrent users, we experienced slowness and even some periods of unavailability.

Results of load testing said website.

Things to keep in mind.

Load testing provides useful information for better decision-making. But there are some caveats that you should consider.

Be extra careful when load testing live environments.

If you are load testing a live website or web server, you should be extra careful when testing the limits of your website. Keep in mind that any downtime caused by the tests will also affect users using your platform.

Pingdom detected our website as down during one of the load testing sessions.

Define a flow that mimics what your users usually do on your website.

While load testing, the more your test case reflects actual user behaviour, the more accurate the test results will be. For our use case, a single-page request is a good enough reflection of our users’ behaviour. Most of the time, our users access the platform one time and then spend some time exploring the data they are viewing.

In most cases, though, it’s probably more realistic to have a more complex flow. For such cases, you might want to set up a test case that properly simulates a realistic flow of user interactions on your website. If, for instance, most of the traffic comes from API requests, you can take a HAR snapshot of requests from a user session (navigating and clicking around in the browser as you assume a user would do) and then feed this to a test script that would replay the API requests with the original time gaps.

The main takeaway here is: the more you invest in making your test script realistic, the more accurate the load testing results will be.

Consider the limitations of your own hardware.

While load testing, you are bound to hit some limitation: in many cases, these will be the limits of the server you are load testing, but you might actually reach the limits of your own hardware (as in, your computer can’t make that many requests at the same time).

To avoid such pitfalls, keep an eye on the performance metrics of the servers being load tested (CPU usage, memory usage, etc). You should observe metrics fluctuating, reflecting the execution of the load test. This way, you can tell whether your load testing is hitting the limits of the server or your hardware.

Conclusions.

Load testing allows us to grab valuable information about the limits of the websites we build and share them with our clients. If a major public event is planned, we can prepare for it and give our clients confidence that their website will stay live and online. Knowing our limits also enables us to make more informed infrastructure decisions in the future.

Fortunately, this year, we haven’t experienced any intense spikes in the number of simultaneous users. But, if another celebrity chooses to share a link to one of our websites, we are prepared and ready for any spike in visitors.

Henrique is a backend software engineer at Vizzuality who implements systems that collect, process and analyse data from different sources. Henrique loves hiking, camping and walking on the beach.

Vizzuality Blog

Posts on data design, user research, open data, and…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store