{"id":11116,"date":"2024-04-17T15:17:46","date_gmt":"2024-04-17T19:17:46","guid":{"rendered":"https:\/\/www.redline13.com\/blog\/?p=11116"},"modified":"2024-04-17T15:20:02","modified_gmt":"2024-04-17T19:20:02","slug":"ramping-vus-in-k6","status":"publish","type":"post","link":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/","title":{"rendered":"Ramping VUs in k6"},"content":{"rendered":"<p><a id=\"post-11116-_co4u1ycv67ze\"><\/a> <img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-11117\" src=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2024\/04\/word-image-11116-1.png\" alt=\"Ramping VUs in k6\" width=\"293\" height=\"220\" srcset=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2024\/04\/word-image-11116-1.png 400w, https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2024\/04\/word-image-11116-1-300x225.png 300w\" sizes=\"auto, (max-width: 293px) 100vw, 293px\" \/><\/p>\n<p>When creating a load test, it is sometimes desirable to control how the rate of requests are scaled over time. <a href=\"https:\/\/k6.io\/\" target=\"_blank\" rel=\"noopener\">k6<\/a> provides this behavior through the <code><a href=\"https:\/\/grafana.com\/docs\/k6\/latest\/using-k6\/scenarios\/executors\/ramping-vus\/\" target=\"_blank\" rel=\"noopener\"><strong>ramping-vus<\/strong><\/a><\/code> 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.<\/p>\n<h3><a id=\"post-11116-_su2p7rrx7f40\"><\/a>Example Script of Ramping VUs<\/h3>\n<p>The following k6 script outlines the syntax and usage of the<strong>\u00a0<code>ramping-vus<\/code><\/strong>\u00a0executor. You can also find a similar script example in the <a href=\"https:\/\/grafana.com\/docs\/k6\/latest\/using-k6\/scenarios\/executors\/ramping-vus\/\" target=\"_blank\" rel=\"noopener\">official k6 documentation pages<\/a>:<\/p>\n<pre><strong>import http from 'k6\/http';\n<\/strong><strong>import { sleep } from 'k6';\n\n<\/strong><strong>export const options = {\n<\/strong><strong>  discardResponseBodies: true,\n<\/strong><strong>  scenarios: {\n<\/strong><strong>    contacts: {\n<\/strong><strong>      executor: 'ramping-vus',\n<\/strong><strong>      startVUs: 0,\n<\/strong><strong>      stages: [\n<\/strong><strong>        { duration: '300s', target: 100 },\n<\/strong><strong>        { duration: '60s', target: 0 },\n<\/strong><strong>      ],\n<\/strong><strong>      gracefulRampDown: '30s',\n<\/strong><strong>    },\n<\/strong><strong>  },\n<\/strong><strong>};\n\n<\/strong><strong>export default function () {\n<\/strong><strong>  http.get('https:\/\/test.k6.io\/contacts.php');\n<\/strong><strong>  sleep(0.5);\n<\/strong><strong>}<\/strong><\/pre>\n<p>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 (<em>i.e.<\/em>, 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.<\/p>\n<h3><a id=\"post-11116-_brzna5v2jz2t\"><\/a>Ramping VUs Configuration Options<\/h3>\n<p>In the above example, there are three options specific to the<strong>\u00a0<code>ramping-vus<\/code><\/strong> executor. These are:<\/p>\n<ul>\n<li><strong><code>stages<\/code><\/strong> \u2013 accepts an array of target number of VUs, and a duration over which ramp up or ramp down occurs<\/li>\n<li><strong><code>startVUs<\/code><\/strong> \u2013 accepts an integer count of the number of starting VUs<\/li>\n<li><strong><code>gracefulRampDown<\/code><\/strong> \u2013 specifies a duration of time over which requests already initiated are allowed to complete without terminating the process abruptly<\/li>\n<\/ul>\n<h3><a id=\"post-11116-_7oh098ncp96\"><\/a>Ideal Use Case<\/h3>\n<p>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 <strong><code>ramping-vus<\/code><\/strong>\u00a0executor can thereby more realistically simulate actual expected user traffic in your tests.<\/p>\n<hr \/>\n<p>Did you know that RedLine13 offers a full-featured, time-limited free trial? <a href=\"https:\/\/www.redline13.com\/Service\" target=\"_blank\" rel=\"noopener\">Sign up now<\/a>, and move your k6 testing into the cloud today!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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<a class=\"more-link\" href=\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\">Read More &rarr;<\/a><\/p>\n","protected":false},"author":11,"featured_media":11117,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[596,671,318,708,707,424,451,706],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-dkoziel","4":"post-11116","6":"format-standard","7":"has-post-thumbnail","8":"category-blog","9":"category-uncategorized","10":"post_tag-k6","11":"post_tag-k6-load-tests","12":"post_tag-load-testing","13":"post_tag-ramp-down","14":"post_tag-ramp-up-2","15":"post_tag-redline13","16":"post_tag-scaling","17":"post_tag-vus"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Ramping VUs in k6 - RedLine13<\/title>\n<meta name=\"description\" content=\"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Ramping VUs in k6 - RedLine13\" \/>\n<meta property=\"og:description\" content=\"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\" \/>\n<meta property=\"og:site_name\" content=\"RedLine13\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-17T19:17:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-17T19:20:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2024\/04\/word-image-11116-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"400\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"David Koziel\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"David Koziel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\"},\"author\":{\"name\":\"David Koziel\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\"},\"headline\":\"Ramping VUs in k6\",\"datePublished\":\"2024-04-17T19:17:46+00:00\",\"dateModified\":\"2024-04-17T19:20:02+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\"},\"wordCount\":344,\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"keywords\":[\"k6\",\"k6 load tests\",\"Load Testing\",\"ramp-down\",\"ramp-up\",\"RedLine13\",\"scaling\",\"VUs\"],\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\",\"name\":\"Ramping VUs in k6 - RedLine13\",\"isPartOf\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\"},\"datePublished\":\"2024-04-17T19:17:46+00:00\",\"dateModified\":\"2024-04-17T19:20:02+00:00\",\"description\":\"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.redline13.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Ramping VUs in k6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#website\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"name\":\"RedLine13\",\"description\":\"(Almost) Free Load Testing in the Cloud\",\"publisher\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.redline13.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#organization\",\"name\":\"RedLine13\",\"url\":\"https:\/\/www.redline13.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"contentUrl\":\"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg\",\"width\":300,\"height\":68,\"caption\":\"RedLine13\"},\"image\":{\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20\",\"name\":\"David Koziel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g\",\"caption\":\"David Koziel\"},\"url\":\"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Ramping VUs in k6 - RedLine13","description":"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/","og_locale":"en_US","og_type":"article","og_title":"Ramping VUs in k6 - RedLine13","og_description":"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.","og_url":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/","og_site_name":"RedLine13","article_published_time":"2024-04-17T19:17:46+00:00","article_modified_time":"2024-04-17T19:20:02+00:00","og_image":[{"width":400,"height":300,"url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2024\/04\/word-image-11116-1.png","type":"image\/png"}],"author":"David Koziel","twitter_card":"summary_large_image","twitter_misc":{"Written by":"David Koziel","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#article","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/"},"author":{"name":"David Koziel","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20"},"headline":"Ramping VUs in k6","datePublished":"2024-04-17T19:17:46+00:00","dateModified":"2024-04-17T19:20:02+00:00","mainEntityOfPage":{"@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/"},"wordCount":344,"publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"keywords":["k6","k6 load tests","Load Testing","ramp-down","ramp-up","RedLine13","scaling","VUs"],"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/","url":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/","name":"Ramping VUs in k6 - RedLine13","isPartOf":{"@id":"https:\/\/www.redline13.com\/blog\/#website"},"datePublished":"2024-04-17T19:17:46+00:00","dateModified":"2024-04-17T19:20:02+00:00","description":"In this brief post, we will discuss ramping VUs in k6, enabling realistic simulations of user traffic patterns in real-world use cases.","breadcrumb":{"@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.redline13.com\/blog\/2024\/04\/ramping-vus-in-k6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.redline13.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Ramping VUs in k6"}]},{"@type":"WebSite","@id":"https:\/\/www.redline13.com\/blog\/#website","url":"https:\/\/www.redline13.com\/blog\/","name":"RedLine13","description":"(Almost) Free Load Testing in the Cloud","publisher":{"@id":"https:\/\/www.redline13.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.redline13.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.redline13.com\/blog\/#organization","name":"RedLine13","url":"https:\/\/www.redline13.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","contentUrl":"https:\/\/www.redline13.com\/blog\/wp-content\/uploads\/2013\/06\/cropped-rl13-header-logo.jpg","width":300,"height":68,"caption":"RedLine13"},"image":{"@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/51d282221e3230ab35f964f98ada9b20","name":"David Koziel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.redline13.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2babf644e0993fc86893c24d7525f1e3be114a8746c01249797f25587ae1697a?s=96&d=mm&r=g","caption":"David Koziel"},"url":"https:\/\/www.redline13.com\/blog\/author\/dkoziel\/"}]}},"_links":{"self":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/comments?post=11116"}],"version-history":[{"count":4,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11116\/revisions"}],"predecessor-version":[{"id":11121,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/posts\/11116\/revisions\/11121"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media\/11117"}],"wp:attachment":[{"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/media?parent=11116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/categories?post=11116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.redline13.com\/blog\/wp-json\/wp\/v2\/tags?post=11116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}