{"id":9527,"date":"2017-11-02T05:56:57","date_gmt":"2017-11-02T05:56:57","guid":{"rendered":"http:\/\/abstracta.us\/blog\/?p=9527"},"modified":"2025-05-05T21:20:42","modified_gmt":"2025-05-05T21:20:42","slug":"implement-load-test-scenarios-gatling","status":"publish","type":"post","link":"https:\/\/abstracta.us\/blog\/software-testing\/implement-load-test-scenarios-gatling\/","title":{"rendered":"How to Implement Load Test Scenarios in Gatling"},"content":{"rendered":"<p><!-- Go to www.addthis.com\/dashboard to customize your tools --><script src=\"\/\/s7.addthis.com\/js\/300\/addthis_widget.js#pubid=ra-58d80a50fc4f926d\" type=\"text\/javascript\"><\/script><\/p>\n<h1>Let&#8217;s take a look at two ways to set up load test scenarios in Gatling<\/h1>\n<p><span style=\"font-weight: 400;\">As we discussed in our <a href=\"https:\/\/abstracta.us\/blog\/performance-testing\/gatling-tool-review-performance-tests-written-scala\/\">review of Gatling<\/a><\/span>, Gatling allows us to define a wide variety of performance tests. Regarding load tests, we can implement them in any of the following ways: virtual user based (VUs) or throughput based (RPS \u2013 requests per second).\u00a0<span style=\"font-weight: 400;\"><br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The requirements of your load tests will determine which one is better. Some applications need to be able to handle certain TPS, for example, a financial transaction processor, where clearly a throughput based test suits better. On the other hand, applications that are directly related to the number of users using it concurrently, are more suitable for virtual user based tests.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Virtual_User_Based_Tests\"><\/span>Virtual User Based Tests<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">To run virtual user based tests, you only need to determine how many VUs will run and how you want them to start. Below, how to run a test with 10 VUs is shown:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.34.24-PM-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9528\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.34.24-PM-min.png\" alt=\"Screen Shot 2017-11-01 at 10.34.24 PM-min\" width=\"797\" height=\"80\" \/><\/a><br \/>\n<span style=\"font-weight: 400;\">The following code shows, for example, how to run a test with 10 concurrent VUs that will start in a 10 second ramp-up period:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.36.11-PM-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9529\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.36.11-PM-min.png\" alt=\"Screen Shot 2017-11-01 at 10.36.11 PM-min\" width=\"797\" height=\"81\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">A ramp-up period means that once it concludes, all the defined VUs should be running. When the test starts, each VU will execute the script one time.<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/10vu-Gatling-768x321-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9530\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/10vu-Gatling-768x321-min.png\" alt=\"10vu-Gatling-768x321-min\" width=\"797\" height=\"333\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Ideally, you should also determine how many times each VU should run (repeat), or for how long (duration).<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.41.18-PM-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9533\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.41.18-PM-min.png\" alt=\"Screen Shot 2017-11-01 at 10.41.18 PM-min\" width=\"797\" height=\"221\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Throughput_Based_Tests\"><\/span>Throughput Based Tests<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Next, we will show you how to simulate a throughput based test. This involves defining how many RPS should be reached where a ramp-up period could also be set:<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.45.01-PM-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9535\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.45.01-PM-min.png\" alt=\"Screen Shot 2017-11-01 at 10.45.01 PM-min\" width=\"797\" height=\"105\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">This way we simulate that every second, the load will be increased with 10 more VUs. If each VU has a loop defined, after 20 seconds, there will be 200 VUs running concurrently.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The second line of the below code limits the test load to what is defined in \u201cthrottle\u201d. In the previous example, the RPS was set to 20. This means that, when this value is reached, Gatling will handle VU requests so the RPS does not exceed the throttle value. Next, you see the execution graph, where the RPS stays at 20 once reached.<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/gatling-tps-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9534\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/gatling-tps-min.png\" alt=\"gatling-tps-min\" width=\"797\" height=\"323\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Finally, the holdFor parameter allows you to set how long the test will run. For this example, it was set to 3 minutes.<\/span><\/p>\n<p><a href=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.45.50-PM-min.png\"><img decoding=\"async\" class=\"alignnone wp-image-9536\" src=\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.45.50-PM-min.png\" alt=\"Screen Shot 2017-11-01 at 10.45.50 PM-min\" width=\"797\" height=\"129\" \/><\/a><\/p>\n<p><span style=\"font-weight: 400;\">Gatling\u2019s DSL is very flexible, allowing us to implement many different scenarios<\/span><span style=\"font-weight: 400;\">. The above examples briefly explain how to implement either throughput or virtual user based load tests.Your application requirements will determine which one to implement.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For more examples, check out our related posts below.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Need help with Gatling or running load tests? Let\u2019s <a href=\"http:\/\/www.abstracta.us\/contact-us\">get in touch<\/a><\/span>.<\/p>\n<hr \/>\n<h2><span class=\"ez-toc-section\" id=\"Recommended_for_You\"><\/span><strong>Recommended for You<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"http:\/\/abstracta.us\/blog\/performance-testing\/gatling-tool-review-performance-tests-written-scala\/\">Gatling\u00a0Tool Review for Performance Tests (Written in Scala)<\/a><br \/>\n<a href=\"http:\/\/abstracta.us\/blog\/performance-testing\/gatling-vs-jmeter-findings\/\">Gatling vs JMeter: Our Findings<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s take a look at two ways to set up load test scenarios in Gatling As we discussed in our review of Gatling, Gatling allows us to define a wide variety of performance tests. Regarding load tests, we can implement them in any of the&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,1,61],"tags":[102,50],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Implement Load Test Scenarios in Gatling | Abstracta<\/title>\n<meta name=\"description\" content=\"Let&#039;s take a look at two ways to set up load test scenarios in Gatling. Gatling allows us to define a wide variety of performance tests, including load test\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Implement Load Test Scenarios in Gatling | Abstracta\" \/>\n<meta property=\"og:description\" content=\"Let&#039;s take a look at two ways to set up load test scenarios in Gatling. Gatling allows us to define a wide variety of performance tests, including load test\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AbstractaQA\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-02T05:56:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-05T21:20:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/load-test-scenarios-in-Gatling1-min.png\" \/>\n\t<meta property=\"og:image:width\" content=\"560\" \/>\n\t<meta property=\"og:image:height\" content=\"315\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fltoledo\" \/>\n<meta name=\"twitter:site\" content=\"@AbstractaUS\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/abstracta.us\/blog\/#website\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\",\"description\":\"AI-powered quality engineering\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/abstracta.us\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/abstracta.us\/wp-content\/uploads\/2017\/11\/Screen-Shot-2017-11-01-at-10.34.24-PM-min.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/#webpage\",\"url\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\",\"name\":\"How to Implement Load Test Scenarios in Gatling | Abstracta\",\"isPartOf\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/#primaryimage\"},\"datePublished\":\"2017-11-02T05:56:57+00:00\",\"dateModified\":\"2025-05-05T21:20:42+00:00\",\"author\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/7421e539de0357d3adb0c69ed469a1c2\"},\"description\":\"Let's take a look at two ways to set up load test scenarios in Gatling. Gatling allows us to define a wide variety of performance tests, including load test\",\"breadcrumb\":{\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/\",\"url\":\"https:\/\/abstracta.us\/blog\/performance-testing\/\",\"name\":\"Performance Testing\"}},{\"@type\":\"ListItem\",\"position\":3,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\",\"url\":\"https:\/\/abstracta.us\/blog\/performance-testing\/implement-load-test-scenarios-gatling\/\",\"name\":\"How to Implement Load Test Scenarios in Gatling\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/7421e539de0357d3adb0c69ed469a1c2\",\"name\":\"Federico Toledo, Chief Quality Officer at Abstracta\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6de7ec6536c4028b5c02ad4ec1b9af0d?s=96&d=blank&r=g\",\"caption\":\"Federico Toledo, Chief Quality Officer at Abstracta\"},\"description\":\"Co-founder and COO of Abstracta\",\"sameAs\":[\"https:\/\/twitter.com\/fltoledo\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9527"}],"collection":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/comments?post=9527"}],"version-history":[{"count":9,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9527\/revisions"}],"predecessor-version":[{"id":12040,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/9527\/revisions\/12040"}],"wp:attachment":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/media?parent=9527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/categories?post=9527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/tags?post=9527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}