Tools for Benchmarking Performance & Load Testing Web Apps

A Benchmark is a set of standard or point of reference against which things may be compared. As a reference point it helps us to know if our software or product is performing well or not. Hence in a way benchmarking is useful for determining and measuring performance. It is useful for setting a baseline

In software engineering, it is a best practice to create a standard / point of reference for the software delivered. This can be done using the concept of load testing.
So what is load testing?

Load testing is the process of putting demand on a structure or system and measuring its response.(wiki). It is the process of measuring how your application will behave and perform when multiple users either concurrently or sequentially are using your application.

In load testing we are mostly interested in performance in relation to

  • Response time: the time it takes for the service to respond to a request sent from the user or another service. Hence we will be checking the number of request sent and the duration of the response.
  • Latency: how long it takes between request and response and how it lags
  • Number of concurrent users and it effect on the system under test
  • Availability: will the system crash or adapt
  • Errors
  • Transactions and Queries made
  • other metrics

Load testing is not the only way to generate benchmarks, we can also create our own standards and even profile our system to know the average and expected number of function calls and CPU time and then use our findings to build our point of reference.

Let us see how to use some tools to test the load of our application and from the result we will build a point of reference as our benchmark.

List of load testing tools for benchmarking response time

  • loadtest
  • ab (apache bench)
  • wrk
  • k6
  • locust
  • jmeter
  • autocannon

Using Apache Bench (ab) for load testing response time

Apache bench (ab) is a tool that comes bundled with apache utils and apache2. It can be used to load test any web services, be it flask, Nodejs, Django, PHP websites.
Apache Bench (ab) is a benchmarking tool that measures the performance of a web server by inundating it with HTTP requests and recording metrics for latency and success. Apache Bench can help you determine how much traffic your HTTP server can sustain before performance degrades, and set baselines for typical response times.
When working with load testing you should also consider the constraints of the CPU and RAM memory of the system on which you are running the load test tool.

 apt-get install -y apache2-utils

The basic usage is as followers

ab -n 100000 -c 1000 <SERVER_ADDRESS>

The key is as below
-n: The number of requests to send
-t: A duration in seconds after which ab will stop sending requests
-c: The number of concurrent requests to make

Interpreting the Results

The most important metrics to look for in our case for benchmarking response time is the

  • Time taken for tests : (also called total time )
  • Time per requests/ concurrency
  • Latency
  • Requests per second
  • Longest request time
  • Errors

You should treat both Time taken for tests and Time per request as rough indicators of web server performance under specific levels of load. Tracking these values over time can help you assess your optimization efforts, and unusually high or low values can point to CPU saturation on the web server, code changes, or other events that you’ll want to investigate in more detail

Using loadtest for benchmarking response time and load testing performance

Loadtest is an npm package for running a load test on the selected HTTP or WebSockets URL. The API allows for easy integration in your own tests.Just like ab, it can also be used for any web application

npm install -g loadtest
loadtest [-n requests] [-c concurrency] [-k keepalive] URL
loadtest -c 10 --rps 200 -k

This also offers similar metrics like ab

Using wrk for benchmarking response time and load testing performance

wrk is a modern HTTP benchmarking tool capable of generating significant load when run on a single multi-core CPU. It combines a multithreaded design with scalable event notification systems such as epoll and kqueue.

wrk -t12 -c400 -d30s
-c, --connections: total number of HTTP connections to keep open with
                   each thread handling N = connections/threads

-d, --duration:    duration of the test, e.g. 2s, 2m, 2h

-t, --threads:     total number of threads to use

-s, --script:      LuaJIT script, see SCRIPTING

-H, --header:      HTTP header to add to request, e.g. "User-Agent: wrk"

    --latency:     print detailed latency statistics

    --timeout:     record a timeout if a response is not received within
                   this amount of time.

There are other tools like locust, k6s, jmeter,etc.We will look into these tools in another post.

Have a wonderful day

Jesus Saves

By Jesse E.Agbe(JCharis)

Leave a Comment

Your email address will not be published. Required fields are marked *