Load Testing Design & Implementation[Part -1]

Vibhor Pareek
3 min readFeb 17, 2021

Introduction

In this era of build and deliver fast, load testing has become an important part of software engineering and often as one of the key component in performance engineering. Mostly as a developer, we tend to think more on functionality and correctness of code and overlook the performance aspects. This leads to increased issues either in QA/Stage or Prod environments.

So, how should load testing be included ? Should it be a part of CI-CD process or carried out on performance env (an exact replica of production env)? Answer is both. You should have both as part of your delivery process and carry out activity on a performance env.

Why Load Testing?

We often see slowness in our application/service or website as we see a sudden spike of users in our system. Why is that? Have you looked at the resource usages at your instance/system level and tried to figure out the root cause? If you look closely, you will see some erratic behaviour either at cpu usage, memory consumption, database call latencies etc. Here are some of the important stats needs to be looked from an application standpoint :

  1. Response time which includes your client side as well as server latencies(average/90th percentile/95th percentile/99th percentile)
  2. Throughput of your system measured in terms of amount of work done per unit time i.e TPS/RPS.
  3. Success & Error percentage.
  4. CPU & Memory usage during the test.
  5. Network usage.

There are other things as well to be looked for number of database connections & datastore latencies during the read and write operations. So, it’s important to measure & monitor all of the above resources and their latency fluctuation over time. Load testing helps you to achieve and mimic exact load of users and prepare for the scale required!

How to do Load Test & Which tool to use?

There are many tools in the market and often people get confused which one to use, here is a distinction among tools for performance in market based on varying criteria’s :

Image from Internet

It totally depends on which language you are comfortable in and protocols you are looking to test out. JMeter is the winner in terms of wider community reach with plethora of plugins available and acceptance of tool over the geography but I personally like Gatling as it provides you control over script creation, vast DSL support in scala and readable report in html format. Overall Gatling is lighter in terms of resource utilisation and lighter as compared to threads in JMeter. Here’s the detail on the gatling site for more info.

Gatling’s architecture is asynchronous as long as the underlying protocol, such as HTTP, can be implemented in a non blocking way. This kind of architecture lets us implement virtual users as messages instead of dedicated threads, making them very resource cheap.

Script creation is one of the major part of performance testing but what most people make mistake is in understanding user behaviours. Ideal way is to understand user journeys for your application i.e create paths for user journeys and separate them based on functionality. One such example would be in an e-commerce application:

  1. Few users would be logging in and viewing a product/product details/pricing.
  2. Few users login->buy product->cart ->checkout->payment
  3. Few users signup->login->view pages

.

.

n.

Similar to that there might be n paths you want to have virtual users in your system and do read/write/update operations during the whole load period. It is also important to have a previous year stats for one of the peak event while understanding user journeys and add a 5–10% increase of users while creating test plan for load. I will not go into details of writing load scripts as it varies based on tool & terminologies pertaining to the tool used.

Distributed Load Testing As you add more and more virtual users/threads into the system, you need to have more load generators and don’t want to choke load generators for resources. Let’s try to build & design a distributed Load testing tool and understand the benefits and challenges in the next section! COMING SOON …

Happy Learning :)

--

--