title: Locust.io: Controlling the request per second parameter
body: <p>I have been trying to load test my API server using Locust.io on EC2 compute optimized instances. It provides an easy-to-configure option for setting the <strong>consecutive request wait time</strong> and <strong>number of concurrent users</strong>. In theory, <strong>rps</strong> = <em>wait time</em> <strong>X</strong> <em>#_users</em>. However while testing, this rule breaks down for very low thresholds of <em>#_users</em> (in my experiment, around 1200 users). The variables <em>hatch_rate</em>, <em>#_of_slaves</em>, including in a <em>distributed test setting</em> had little to no effect on the <strong>rps</strong>.</p>
  <blockquote>
  <p><strong>Experiment info</strong></p>
  <p>The test has been done on a C3.4x AWS EC2 compute node (AMI image) with 16 vCPUs, with General SSD and 30GB RAM. During the test, CPU utilization peaked at 60% max (depends on the hatch rate - which controls the concurrent processes spawned), on an average staying under 30%.</p>
  <p><strong>Locust.io</strong></p>
  <p>setup: uses pyzmq, and setup with each vCPU core as a slave. Single POST request setup with request body ~ 20 bytes, and response body ~ 25 bytes. Request failure rate: &lt; 1%, with mean response time being 6ms.</p>
  <p>variables: Time between consecutive requests set to 450ms (min:100ms and max: 1000ms), hatch rate at a comfy 30 per sec, and <strong>RPS</strong> measured by varying <em>#_users</em>.</p>
  </blockquote>
  <p><img src="https://i.stack.imgur.com/731f7.png" alt="Locust.io throughput graph" /></p>
  <p>The RPS follows the equation as predicted for upto 1000 users. Increasing <em>#_users</em> after that has diminishing returns with a cap reached at roughly 1200 users. <em>#_users</em> here isn't the independent variable, changing the <em>wait time</em> affects the RPS as well. However, changing the experiment setup to 32 cores instance (c3.8x instance) or 56 cores (in a distributed setup) doesn't affect the RPS at all.</p>
  <p>So really, what is the way to control the RPS? Is there something obvious I am missing here?</p>