Dice and Queues
justincartwright.com
justincartwright.com
I was fortunate enough to take some great queueing theory classes in college, and fondly remember flailing about in Simio [1] trying to get a bank teller simulation to work. Really useful stuff to learn, although it did make me incredibly susceptible to Factorio and similar games.
After, Little's law, he introduces the First Queue Size Control Principle (Q13): Controlling queue size rather than capacity utilization offers a more effective way to manage cycle time and process efficiency. — No mister business stakeholder, adding items to the dev team's to-do list and making sure they are working 110% isn't going to get stuff delivered faster.
Diffusion Principle (Q15): Random processes can lead to queues spinning out of control; these high-queue states can last long and cause significant economic damage. — No mister business stakeholder, we can't fix this one little thing right now, it's bigger than you think and is going to make it harder to deliver the big important project.
[1] https://www.amazon.com/Principles-Product-Development-Flow-G...
[2] https://www.joecotellese.com/posts/principles-of-product-dev...
I warmly recommend Harchol-Balter: https://www.amazon.com/Performance-Modeling-Design-Computer-... It is an eminintly practical book which is written in terms of computers, goes beyond the basic M/M/1 but without being overbearing.
(The other secret superpower is statistical process control.)
- `Little’s Law`: The average number of objects in a queue is the product of the entry rate and the average holding time - Response-time formula for a multi-user system: - Assume n users of average think time z are connected to an arbitrary system with response time r. - Each user cycles between thinking and waiting-for-response, so the total number of jobs in the meta-system (consisting of users and the computer system) is fixed at n. - If you cut the path from the system's output to the users, you see a meta-system with average load n, average response time z + r, and throughput x (measured in jobs per time unit). - Little’s Law says n = x × (z + r), and solving for r gives r = n/x – z.
It's not only possible if there's no variability. It's only possible if the arrival rate is always less than number of available processing slots, which can be engineered in a number of ways. (e.g. ensuring that the number of processing units is oversupplied, i.e. exceeds the maximum arrival rate + departure rate; or altering number of processing units dynamically so that utilisation never exceeds 80%.)
However, these approaches are generally not the lowest cost approaches, and so are only used when queueing is incredibly undesirable, e.g. when the cost of maintaining the queue exceeds the cost of holding the spare capacity.
One example for oversupply is airports - most airports have enough gates that incoming aircraft never have to queue, despite that meaning that many gates are empty for most of the day.
For dynamically adjusting capacity examples include listening thread pools for network applications which can spin up new waiting threads whenever the pool free count drops below a certain threshold (the threshold being decided based on the maximum arrival rate). Or a cloud service which spins up new servers whenever cpu utilisation exceeds 80%.
> For the service rate (λ), we can keep things simple and assume that our server can service 10 items per minute with zero variation.
I think it's supposed to be mu and not lambda
P(random() < 1/6) ~= 1/6 .
Which is how they simulate a dice landing a "6". This explanation could be included in the text.
Over many iterations (minutes, hours), you accumulate the effects of these random additions. As a result, even though the distribution is binomial (or approximated Poisson), its behavior for large enough values and sums of multiple minutes becomes approximately gaussian due to CLT.