Little's Law: Understanding how much tour system can handle
Source: Dev.to
Introduction
Little’s Law is a simple formula that connects the number of items in a system, the arrival rate, and the average time an item spends in the system. It’s used when you need to know how many items per unit of time your system can handle.
The Formula
The formula is straightforward:
[ L = \lambda , W ]
- L – average number of items in the system
- λ – arrival (entry) rate
- W – average time an item spends in the system
In summary: quantity = rate × time.
Example: API Requests
Suppose an API has the following metrics:
- 10 requests per second (arrival rate)
- Each request takes 2 seconds to complete (average time)
Applying Little’s Law:
[ L = 10 \times 2 = 20 ]
So the API can handle 20 simultaneous requests.
Conclusion
Applying Little’s Law 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.