Blog

Miroslav Renda

Miroslav Renda

Senior Test Manager

Load Testing in modern software development

Education Přístupy k testování Performance Testing

How does your application perform under pressure? In today’s article, we focus on load testing – one of the key methods of performance testing. You’ll learn how typical load is defined and what issues can be uncovered through load testing before deployment. Additionally, we’ll explore a practical example using the k6 tool.

Load testing is a crucial non-functional test type that evaluates an application's behavior and responsiveness under expected load conditions. It simulates typical workloads, such as the number of concurrent users or transactions, to assess performance metrics like response time, throughput, and server stability. 

The definition of a 'typical user load' varies by context. For instance, Google may require handling millions of simultaneous searches with sub-second response times, while a small bank might need to support 1000 concurrent users with a 3-second login time. 

By conducting load testing, QA specialists can optimize processes, accurately track system behavior under various conditions, and identify potential issues before new features go live. This testing is vital in today's fast-paced environment, where first impressions matter. 

The following picture shows a typical pattern of the number of concurrent users (often called virtual users, VUs) in time during load test.  

Load Test

In the beginning, there is a ramp-up period during which the number of VUs increases, then period of a steady load and a ramp-down period.  

Load testing: practical example with k6 

To illustrate how load testing can be conducted effectively, let's look at a practical example using the open-source load testing tool, k6. This example will show how to set up a basic load test script and run it to evaluate your application's performance under load. 

First, install k6 by following the instructions at the k6 official website. 

Next, create a new file for your load test script, for example, load-test.js, and add the following code: 

import http from "k6/http";
import { sleep } from "k6";

// Define the stages of the test
export let options = {
  stages: [
    {
      duration: "30s",
      target: 240,
    },
    {
      duration: "290s",
      target: 240,
    },
    {
      duration: "10s",
      target: 0,
    },
  ],
};

// Virtual users script
export default function () {
  http.get("https://test.k6.io");
  sleep(1);
  http.get("https://test.k6.io/contacts.php");
  sleep(2);
  http.get("https://test.k6.io/flip_coin.php");
  sleep(2);
}


To run the load test, navigate to the directory containing your script and execute the following command in your terminal: 

k6 run load-test.js 

After the test completes, k6 provides detailed statistics on various performance metrics such as response times, request rates, and error rates. Analyzing these metrics helps you understand how your application performs under load and identify any potential bottlenecks or performance issues. 

Souhrnné statistiky

Conclusion 

Load testing is a key non-functional testing method in software development, used to check how well an application performs under expected workloads. This involves simulating the typical activities users might do, like the number of users or transactions, to measure important performance metrics such as response time and system stability. 

Implementing best practices and using effective tools for load testing ensures your applications are robust, scalable, and deliver a seamless user experience, ultimately enhancing customer satisfaction and protecting your brand reputation. 

Don't miss out on the latest updates.

Fill in your email address to stay informed about upcoming training sessions, events, and testing know-how.

By submitting this form, you agree to the processing of your personal data in accordance with GDPR and to receiving marketing emails.