Skip to content
  • ZipCode Api
  • Blog
  • About RedLine13
RedLine13
RedLine13
Primary Navigation Menu
Menu
  • Start Testing
  • Demo
  • Pricing
  • JMeter
  • Partners
  • Docs
    • Documentation Home
    • AWS Set Up for load testing
    • AWS Approval for Large Tests
    • PHP, NodeJS, Python Load Tests
    • Scalability
    • Jenkins Plugin Setup
    • Premium Features
    • Knowledge Base

Ramping VUs in k6

By: David Koziel

Ramping VUs in k6

When creating a load test, it is sometimes desirable to control how the rate of requests are scaled over time. k6 provides this behavior through the ramping-vus executor, which allows gradual scaling of virtual users over a specified duration. This enables realistic simulations of user traffic patterns as expected in real-world use cases. In this brief post, we will outline the basics of using this feature in k6.

Example Script of Ramping VUs

The following k6 script outlines the syntax and usage of the ramping-vus executor. You can also find a similar script example in the official k6 documentation pages:

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

export const options = {
  discardResponseBodies: true,
  scenarios: {
    contacts: {
      executor: 'ramping-vus',
      startVUs: 0,
      stages: [
        { duration: '300s', target: 100 },
        { duration: '60s', target: 0 },
      ],
      gracefulRampDown: '30s',
    },
  },
};

export default function () {
  http.get('https://test.k6.io/contacts.php');
  sleep(0.5);
}

In this two-stage example, the parameters specified tell k6 to first gradually ramp up users from zero to 100 simultaneous VUs over 5 minutes (i.e., 300 seconds). From that point, VUs are gradually taken out of rotation to smoothly taper back down to zero over the next 60 seconds. Finally, there is a graceful ramp down period specified of 30 seconds, which gives this additional time for requests to complete without abruptly ending the process.

Ramping VUs Configuration Options

In the above example, there are three options specific to the ramping-vus executor. These are:

  • stages – accepts an array of target number of VUs, and a duration over which ramp up or ramp down occurs
  • startVUs – accepts an integer count of the number of starting VUs
  • gracefulRampDown – specifies a duration of time over which requests already initiated are allowed to complete without terminating the process abruptly

Ideal Use Case

For tests which are intended to simulate real-world scenarios where requests to a target test application follow an expected cohort of users accessing a site over a period of time. This is a pattern which is arguably more realistic than a load test that simply aims to arbitrarily saturate a test endpoint without regard to the rate at which new VUs are instantiated. Testing with the ramping-vus executor can thereby more realistically simulate actual expected user traffic in your tests.


Did you know that RedLine13 offers a full-featured, time-limited free trial? Sign up now, and move your k6 testing into the cloud today!

2024-04-17
Previous Post: Large-Scale and Distributed Load Testing with k6
Next Post: Using X-Forwarded-For in JMeter

Recent Posts

  • JMeter XML Format Post Processor
  • Order of Elements in JMeter
  • The JMeter Synthesis Report
  • Using the JMeter Plugins Manager
  • JMeter Rotating JTL Listener

Related

  • JMeter XML Format Post Processor
  • Order of Elements in JMeter
  • SAML Configuration with Azure AD and RedLine13
  • SAML Configuration with OKTA and RedLine13
  • SAML Configuration with Google and RedLine13
  • The JMeter Synthesis Report
  • Using the JMeter Plugins Manager
  • JMeter Rotating JTL Listener
  • Using Test Fragments in JMeter Tests
  • Step-by-Step Guide to Testing with JMeter

© RedLine13, LLC | Privacy Policy | Contract
Contact Us: info@redline13.com

Designed using Responsive Brix. Powered by WordPress.