Skip to content

Instantly share code, notes, and snippets.

@vinhnglx
Last active January 26, 2024 19:17
Show Gist options
  • Save vinhnglx/8d902347ee5330c7913c4698ee3f182c to your computer and use it in GitHub Desktop.
Save vinhnglx/8d902347ee5330c7913c4698ee3f182c to your computer and use it in GitHub Desktop.
Little's law

How many instances do you need?

There's a theoretical tool we can use, the number of instances must obey Little's Law. The definition from Wikipedia is so hard to understand. So, basically, we just need to know the formula

Number of application instances = Average number of requests per second (requests/second) * Average response time (second)

Application Instances, its job is process a single request dependently and send it back to client. When using Puma in threaded mode, application instance is the entire Puma process, when using MRI, JRuby,each thread counts as an application instance. When using Unicorn, Puma (clustered) or Passenger, your application instance is each worker process.

For example:

My application haves:

  • Average rps (request per second): 153
  • Average response time: 300ms

So the application instance: 153 * 0.3 =~ 46 instances

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment