Introduction
Little's Law is a simple formula that connects the number of items in the system, arrival rate, and average time. Its used when you need to know how many items per time your system can handle.
The Formula
The formula is really simple:
𝐿 = 𝜆 𝑊
- L is the average number of items
- λ is the entry rate
- W is the average time an items spends in the system
In summary: quantity = rate × time.
Let's bring it to real world example common to us — an API. Suppose you have an API with the following metrics:
- It gets 10 requests per second.
- Each request takes 2 seconds to be completed.
So, in order to know how many requests are in the system at the same time, I apply the Little's Law formula: L = 10 * 2.
As a result, I get 20. So it's safe to assume that my API handles 20 simultaneous requests.
Conclusion
Applying this formula helps you understand your system's capacity, including latency and throughput. With these insights, you can make better decisions about scaling, introducing queues, or setting timeouts.
Top comments (0)