Blog

Miroslav Renda

Miroslav Renda

Senior Test Manager

Spike testing

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

How does your application behave during sudden load fluctuations? In today's article, we focus on spike testing – a key method of performance testing. You'll learn how the application responds to abrupt changes in the number of users and how quickly it recovers between spikes.

Spike testing is a form of performance testing where an application experiences sudden and extreme fluctuations in load. The objective of spike testing is to observe how a software application behaves under these abrupt changes in traffic. It not only assesses the application's capacity to handle maximum load but also examines its recovery time between these spikes in activity. The term 'spike' denotes the rapid increase or decrease in traffic. 

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

Spike testing

Spike testing: practical example with k6 

To demonstrate effective spike testing, let's explore a practical example using the open-source tool k6. This example will guide you through setting up a basic spike test script and running it to evaluate your application's performance under sudden load variations. 

Begin by installing k6 according to the instructions on the k6 official website. 

Next, create a new file for your spike test script, such as spike-test.js, and add the following code: 

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

// init
export let options = {
  stages: [
    { duration: "20s", target: 120, }, // ramp-up fáze
    { duration: "40s", target: 120, }, // stabilní zátěž 120VU
    { duration: "25s", target: 400, }, // náběh první špičky
    { duration: "25s", target: 120, }, // sestupná hrana první špičky
    { duration: "70s", target: 120, }, // stabilní zátěž 120VU
    { duration: "25s", target: 400, }, // náběh druhé špičky
    { duration: "25s", target: 120, }, // sestupná hrana první špičky
    { duration: "20s", target: 0, },    // ramp-down fáze 
  ],
};

// test script
export default function () {
  http.get("https://test.k6.io");
  sleep(1);
}

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

k6 run spike-test.js 

Conclusion 

Spike testing is a crucial non-functional testing technique that evaluates an application's behavior and stability under sudden, extreme load conditions. By simulating abrupt increases or decreases in concurrent users or transactions, it measures key performance metrics such as response time, throughput, and system resilience. 

Implementing best practices and utilizing effective tools for spike testing ensures that your applications are robust, scalable, and capable of maintaining performance during unexpected traffic spikes. This enhances customer satisfaction, safeguards your brand reputation, and prepares your system for high-demand scenarios. 

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.