{"id":38246,"date":"2016-07-27T12:16:52","date_gmt":"2016-07-27T06:46:52","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=38246"},"modified":"2016-07-27T17:31:25","modified_gmt":"2016-07-27T12:01:25","slug":"master-slave-load-testing-using-locust","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/master-slave-load-testing-using-locust\/","title":{"rendered":"Master-Slave Load Testing using Locust"},"content":{"rendered":"<p>In the previous blog\u00a0we have discussed what is locust , why we use locust for load testing and how to implement it. So if you are wondering\u00a0what locust is and how it works or for a better understanding, see <a href=\"http:\/\/www.tothenew.com\/blog\/performing-heavy-load-testing-on-your-website-using-python-based-tool-locust\/\">locust<\/a>\u00a0.Now in this blog we are here to discuss about running locust in distributive way.<\/p>\n<p>For a single machine it is not enough to simulate the number of users we need,so locust supports running load tests using multiple machines i.e in a master-slave setup.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-38272\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/pasted-image-0.png\" alt=\"pasted image 0\" width=\"500\" height=\"378\" \/><\/p>\n<h2>Quick Start<\/h2>\n<ul>\n<li>To start locust in a master mode we have to use &#8211;master flag.\n<p>[js]locust -f load.py &#8211;master &#8211;host=http:\/\/example.com[\/js]<\/p>\n<p>This provide us the web interface on master server to start the test and see live statistics:<em><strong><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-38251\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/master-without-slave.png\" alt=\"master without slave\" width=\"1286\" height=\"612\" \/><\/strong><\/em><\/p>\n<p><em><strong><span style=\"color: #000080\">Note:<\/span><\/strong><span style=\"color: #000080\"> Master server do not simulate any user itself. For this we have to start one or more slaves using &#8211;slave flag<\/span><\/em><\/li>\n<\/ul>\n<ul>\n<li>To start locust as a slave machine:<br \/>\nOn the slave-machine use &#8211;slave flag and &#8211;master-host.<\/p>\n<p>[js]locust -f load.py &#8211;slave &#8211;master-host=master-host-ip[\/js]<\/p>\n<p><span style=\"color: #000080\"><em><span style=\"line-height: 1.71429;font-size: 1rem\"><strong>Note:<\/strong> Both master and slave must have copy of locust script<br \/>\n<\/span><\/em><\/span>Here,we have added one slave machine,we can see at the right corner of web interface which is increment on adding and starting slaves:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-38252\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/slave1-adde.png\" alt=\"slave1 adde\" width=\"1271\" height=\"528\" \/><\/p>\n<p>Similarly, for the second slave:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-38253\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/slave-2-master.png\" alt=\"slave 2 master\" width=\"1218\" height=\"618\" \/><\/li>\n<\/ul>\n<p>Now, we are ready with our slaves where can provide the number of users and hatch rate to start generating load on a particular website:<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-38254\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/07\/fianle2.png\" alt=\"fianle2\" width=\"1120\" height=\"319\" \/><\/p>\n<p><strong>Locust Report<\/strong><\/p>\n<p>The load test report can be downloaded from the from the web interface from the\u00a0\u00a0&#8220;Download Data&#8221; option or we can also use &#8211;logfile option to save report in the server itself.<\/p>\n<p>[js]locust -f load.py &#8211;logfile=logfilepath &#8211;master &#8211;host=http:\/\/example.com[\/js]<\/p>\n<p><strong>Optional flags for running Locust:<\/strong><br \/>\n<strong>&#8211;master:<\/strong> use this flag to assign machine as master in a distributed\u00a0setup.<br \/>\n<strong>&#8211;master-host:<\/strong> use this flag to tell the slave about the hostname.<br \/>\n<strong>&#8211;slave:<\/strong> assign machine as slave.<br \/>\n<strong>&#8211;master-port:<\/strong> tell slave on which port the locust master in running.<br \/>\n<strong>&#8211;master-bind-port:<\/strong> use this flag to assign port for master in the master machine (default is 5557).<br \/>\n<strong>&#8211;master-bind-host:<\/strong> use this flag to bind master to particular host.<\/p>\n<p>I hope this will help in understanding how to load test your applications using master slave setup in locust \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous blog\u00a0we have discussed what is locust , why we use locust for load testing and how to implement it. So if you are wondering\u00a0what locust is and how it works or for a better understanding, see locust\u00a0.Now in this blog we are here to discuss about running locust in distributive way. For [&hellip;]<\/p>\n","protected":false},"author":917,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":54},"categories":[2348,1,1816],"tags":[1892,3262,3455,2892,1358],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/38246"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/917"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=38246"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/38246\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=38246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=38246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=38246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}