top of page

Open source load testing

Updated: Jul 21, 2023

There are a number of well known open source tools you can start using right away on your project. Here we'll look at how quickly you can get started with some of them.


As a basic requirement:

  • I want to find out how quickly I can get started with the tool

  • I want to generate a basic load of 100 threads ramped up over 10 seconds

  • What kind of skills are required


1. JMeter

Download

Installation

Just unzip into a folder

Open the GUI

Double-click jmeter.bat

Configure

1. Add a thread group - those are the virtual users that will hit the service we're testing:

Here you define the number of users to be created and over what time period they need to ramp-up:

2. Add HTTP Request:

Here you define the actual host and path of the request:

3. Finally add a listener which will collect and save the data:

Here you can define where to store the data to. In our case, we'll store it in a csv file.

Run

Use the Run button (Crtl+R) to run your test plan. The raw data will be saved in the file specified above - ie bin/results.csv.


You should really run the actual in the CLI (command-line interface) aka non-gui mode. Here is how to do it...


.\jmeter -n -t .\TestPlan.jmx -l log.jtl -e

Results

This will run the test and generate the report in bin/report-output/index.html



2. Gatling

Download

Installation

Just unzip into a folder

Open the GUI

There is actually no GUI as such as Gatling is mostly Java/Kotlin or Scala code. You can however record your script first using the Recorder, you can find this in bin/recorder.bat.

Configure

If you are using the recorder, you'll have to first make sure to setup your browser's proxy to point to the recorder. Your browser then uses the recorder as a proxy which then knows about all your actions and can store them in the form of code.

If you're in Windows, go to Settings > Network & internet > Proxy

Once you have setup the proxy, just open your browser and perform the actions you want to record as you would normally do.


Once you have recorded your actions, they will get stored in user-files/simulations/test/MyTest.java. You can use any text editor to edit the code. I've made just one small change in that I want to ramp up the 100 users over 10 seconds, see the highlighted code below.

Run

Run bin/gatling.bat and you'll see:

Choose 1 from the above options. Then you'll see all the available tests you can run:

Choose the one you want to run - in my case 2.

Gatling will ask you for a description of this run and then it will start the test.

Results

The results are located in the file mentioned at the end of the output above. They are organised in a nice report:

3. Locust.io

Download

First, you'll need Python and pip. You can get it from here - https://www.python.org/downloads/. I recommend using virtual environment so that you don't pollute your python with unnecessary libraries. Here is how it works.

Installation

In command line, after you've created and activated your virtual env, just run:

pip3 install locust

Write a test

In Locust, there is no easy way to record a test. There is a round-about way of doing it through converting a har file (your browser log) into a locustfile, but it seems quite convoluted. The basics are quite simple. If you know a bit of Python, you can write a locustfile.py quite easily.

from locust import HttpUser, task
class HelloWorldUser(HttpUser):
    @task
    def hello_world(self):
        self.client.get("/login")

Once you have a locustfile.py in place, you can run locust by just executing the command:

locust

Open the GUI

Once locust is running, you can open the GUI in a browser by going to http://localhost:8089/. Here you can define the number of users to run etc. Don't worry there are more ways generate more complex load shapes if you need to later on.


Run

To run the test just click the Start Swarming button and, you'll start to see the results immediately:



Results

You can download the results from the Download Data page as a html or csv. There are also ways to download the detailed data rather than the stats.

Summary

The approach different tools take are different but you can largely accomplish the limited requirements very quickly using any of the below tools. JMeter is more graphical in its use where Gatling requires more Java knowledge. There is a lot of documentation about both.





.

17 views0 comments

Recent Posts

See All

Comments


> TEST

> PERFORMANCE

©2024 testperformance.co.uk. Registered in England No 06317427.

Registered office: 10A High St, Chislehurst BR7 5AN. 

testperformance.co.uk is a trading style of Marri Jann Ltd

Subscribe to Our Newsletter

Thanks for submitting!

Follow Us On:

  • LinkedIn
bottom of page