Little’s Law states that:
The average number of customers in a queuing system = ( the rate at which customers enter the system ) x (the average time spent in the system)
Typically this might be applied to things like shoppers in a supermarket, but here we will focus on the application to software development. In a software development world, we often write it the same statement with different words, thinking about tasks:
Average Work in Progress = Average Throughput x Average Leadtime
Little’s law is beautifully general. It is “not influenced by the arrival process distribution, the service distribution, the service order, or practically anything else”. This almost makes it self-evident, and since it is a mathematical theorem perhaps this is correct, since it is true in and of itself. Despite being so simple to describe, the simplest generalised proof that I have been able to find (and which we will not tackle here) is however trickier, since a solid grasp on limits and infinitesimals is required. Instead, we will consider a restricted case, suitable for most practical and management purposes, which is the same equation, with the condition that every task starts and finishes within the same finite time window. The mathematical way of saying this is that the system is empty at time t = 0 and time t = T, where 0<T<∞. A diagram to show this system might look something like this:
For our proof, we start with some definitions
n(t) = the number of items in the system at time t
N = the number of items that arrive between t = 0 and t = T
λ = the average arrival rate of items between t = 0 and t = T. The arrival rate is equal to the departure rate (sometimes called throughput), since the system is empty at the beginning and the end.
L = the average number of items in the system between t = 0 and t = T. This is sometimes called “average Work in Progress (WIP)”
W = the average time items spend in the system between t = 0 and t = T. This is called W as a shorthand for wait time, but in software development we might call this leadtime
A = area under n(t) between t = 0 and t =T. This is the sum of all the time every item has spent queuing.
Using this notation, Little’s law becomes
L = λ x W
which we will prove now. The following equations can be assembled from these definitions. We will need to use these to assemble Little’s Law.
- L = A/T (average number of items in the system = sum of time spent / total time)
- λ = N/T (average arrival rate = total number of items / total time, since every item leaves before t=T)
- W = A/N (average time in system = sum of all time spent / number of items)
We can now use these three equations to prove Little’s Law:
L = A/T from (1)
= (A/T)x(N/N) since N/N = 1
= (N/T)x(A/N) by rearranging fractions
= λ x W from (2) and (3)
This is what we wanted, so the proof is complete.
What does this mean?
A trick to getting good outcomes from Little’s Law is understanding which system we want to understand.
If we consider our queuing system to be our software development team, our system is requirements coming in, then being worked on and finished. In this case, W is the development time, and each item is a feature or bug fix, say.
To have a quicker time to market, and to be able to respond to change more quickly, we would love for our so-called “cycle time” W to be lower. If the number of new features coming into our system is the same, then we can achieve that by lowering L, the average work in progress. This is part of why Kanban advocates “limiting work in progress”.
Alternatively, we can consider our queuing system to be the whole software requirement generation, delivery, testing and deployment cycle. In this case, we might have W being the time taken between a customer needing a software feature to it being used by them. By measuring this, we get a true picture of time to market (our new W, which is true measure of “lead time”), and we with some additional measurements we would be able to discover the true cost of the time spent delivering the feature (since our new A is means total time invested).
Outside of the development side of software, we can apply Little’s Law to support tickets. We can, for example, state how long a customer will on average have to wait for their query to be closed, by looking at the arrival rate of tickets and the number of items in the system. If there are on average 10 items in the queue and items arrive at 5 per hour, the average wait time will be 2 hours, since the rearrangement of Little’s Law to L/λ = W gives us 10 / 5 = 2.
I hope that was interesting, if you would like me to explain the proof in the general case, let me know in the comments. I think it would be about 10 pages for me to explain, so in the spirit of lean I will only do this if there is a demand for it.