Skip to content

Instantly share code, notes, and snippets.

@shone1991
Forked from vinhnglx/littles_law.md
Created January 26, 2024 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shone1991/64a2a3d24702c47be42f103662030d45 to your computer and use it in GitHub Desktop.
Save shone1991/64a2a3d24702c47be42f103662030d45 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