How to Load Test Your Application

Aditya Misra
The Startup
Published in
5 min readAug 2, 2020

Frequently used terms in this article:

  • server: a single server where our application is running (or) a setup with multiple servers where our application is running.
  • client: a server that is used for firing/sending requests to our application.

Why Load testing?

Load testing is the process of putting load (user requests) and then checking the response of your application(under test). It is performed to check the system’s behavior under defined load and the peak load conditions.

This testing usually helps in identifying -

  • The maximum operating capacity of an application.
  • Determine whether the current infrastructure is sufficient to run the application.
  • Sustainability of application for peak user load.
  • Number of concurrent users that an application can support, and scalability to allow more users to access it.

What problems does it help us solve?

Prevent the slow performance or even shutdown of the website during a high load.

Long load time

The load test tells you how long it takes the pages to load at different traffic levels. You will get metrics on website speed during normal, peak, and overwhelming traffic load.

Poor response time

Response time is a time a system takes to respond to a user’s requests. Load testing will help you to establish what causes delays in response time and optimize your system accordingly.

Poor scalability

Scalability is the capacity of the app to perform different tasks at the same time. As the number of your users grows, your app must be capable of processing a larger number of requests rapidly, without slowing down the overall performance. Load testing helps you determine whether your application scales when a load grows.

Bottlenecks

There are a lot of types of performance bottlenecks that occur during software development and maintenance. These bottlenecks could be

  • CPU utilization
  • Memory utilization
  • Network utilization
  • Software limitation
  • Disk usage
  • Hardware configuration of the system

Load testing enables us in fixing these bottlenecks before the end-user faces them.

Identify problems before the release

  • The maximum operating capacity of an application.
  • Determine whether the current infrastructure is sufficient to run the application or not.
  • Response time of transactions during peak load.
  • Number of concurrent users that an application can support, and scalability to allow more users to access it.
  • Performance of System components under various loads.
  • Performance of Database components under different loads.
  • Network delay between the client and the server.
  • Software design issues (HLD)
  • Server configuration issues like web server, application server, database server, etc.
  • Hardware limitation issues like CPU maximization, memory limitations, network bottleneck, etc.

Load testing metrics

To estimate every aspect of your application’s performance and measure the success of load testing, the following metrics are used:

  • Latency: the amount of time it takes to send information from one point to another. Measure 90th Percentile Response Time (Industry practices)
  • Request per second: number of requests sent to target server per second
  • Throughput: requests processed during the test (Requests per minute).
  • Errors percentage: percentage of errored requests compared to all requests.
  • CPU utilization: the sum of work handled by the CPU.
  • Memory utilization: the amount of RAM used by the application during testing.
  • Network utilization: the amount of traffic on the network compared to the peak amount that the network can support.
  • Disk usage: the amount of storage needed for the application and its overall operation.

Let the testing begin.

Configuration of the client and server

For the server, make a replica of your production environment:

  • Extrapolating load test results is a very risky business. If you run the test on a one-gigabyte machine with two cores then what will results look like on a two-gigabyte machine with four cores? It’s practically impossible to know.
  • Therefore, you should replicate your production environment in every aspect: machine profile, configuration, database, network architecture, load balancer, firewalls, etc.
  • One method is to create complete images of production machines to be duplicated in your test or staging environment.

For the client, you can have any micro instance.

Tools for Load Testing

I used Apache Bench for testing. You can use JMeter or any other tool in the market.

Apache Bench — need to be installed on the client and it is used for sending requests to the server

  • Start by installing Apache Bench (AB)
install apache2-utils

(or)

yum install httpd-tools
  • Apache Bench (AB) usage -
ab [options] [http[s]://]hostname[:port]/pathab -n [number_of_requests_to_perform] -c [number_of_multiple_requests_to_make [http[s]://]hostname[:port]/path
  • Example -
ab -l -n 100 -c 10 -k -H “Accept-Encoding: gzip, deflate” http://www.example.com/
  • Sample Input -
  • Sample output -

Tools/commands used for measuring the server’s performance

  1. top — command is used to show the Linux processes. It provides a dynamic real-time view of the running system.
  2. htop — similar to top, but a little upgraded version.
  3. mpstat 1 — Used for processor related statistics and reports.
  4. iostat 1 — Used for CPU statistics, input/output statistics for the block devices, partitions, and generate reports.
  5. pidstat -G gunicorn 1 — Used for I/O, CPU, memory statistics for Linux processes and generates a report.
  6. docker stats <docker_name>
  7. Metric beat — set it up on your servers and you see the visualizations on Kibana.

New Relic — used for measuring application performance or we can use any other APM tool.

You can get the following info -

Response time of the api
Time spent in python (tested a python application)
Time spent in cache
Time spent in db
Time spent in external apis

You need to test with different combinations of APIs, read APIs, write APIs, etc.

Load Testing Report

A load testing report should describe these points.

  1. Product KPIs met?
  2. Where is the bottleneck? Should provide areas where teams can invest to get better performance
  3. Is infrastructure sufficient?
  4. Further, invest in performance tuning? Whether to take action on the insights from bottleneck discovery should be done before the go-live or not.

Things to discuss before the release

I was not able to do the formatting as per my expectation, so I moved it to a gist.

My investigation was done on a python application with flask (framework), gunicorn (app server), nginx (webserver), MySQL (database) & everything was deployed on AWS.

After working through these points and taking the necessary steps, we can say that our load testing was a success.

--

--