I don't think this is true, unless I'm misunderstanding your description. Do you mean if the work comes in faster than the worker can process it?
If work arrives at the same rate the worker can process it, the depth of the queue is a random walk starting at zero, with the restriction that it can never go below zero. I'm not sure how that behaves, but it definitely grows much less than linearly.
Python simulation code below:
import random
def random_walk(steps):
count = 0
max_count = 0
for step in range(steps):
if count > 0:
count -= 1
if random.random() > .5:
count += 2
max_count = max(count, max_count)
if step in [2 ** i for i in range(14)]:
print(f"step={step}, count={count}, max_count={max_count}")
for i in range(10):
random_walk(2**13 + 1)That is wrong. It is proportional to sqrt(n). And the fact that in the blog post it looked quadratic rather than n^(3/2) suggests that the tool was producing misleading results.
This makes the time between arrivals, and the time to complete a job both exponential distributions. It also makes the number of arrivals while a job is being worked on into a Poisson distribution.
For a computer simulation you can simplify this even further by forgetting about time and focusing on events. If the worker is busy, the next event is either a new arrival or a job completion with a probability based on the rates.
It's tempting to model work time with an exponential distribution too, and there's a lot of theory for this case. Unfortunately, exponential distribution has a mode = 0, so it's not a good choice for real life process times. It's more common to see distributions like lognormal, gamma, Weibull, loglogistic, beta, or others with a mode > 0.
Edit: same qualitative result (substantially sublinear). Didn’t try to fit it to a distribution.
> A pet peeve of mine is showing things much more easily and clearly with math than demonstrating them through programming.
You probably meant something like
> A pet peeve of mine is demonstrating things through math that can much more easily and clearly be shown with programming.
I don't think andrepd would disagree with the latter. Basically, pick the clearest way to show things.
In this case, by simple inversion that'd be demonstrating things through programming, that would be more challenging to prove with mathematics.
By such a standard, the four-colour theorem would be an example of a feral peeve. However, the work of Agner Krarup Erlang would not.
* Workload distribution (heavy tailed, exponential, uniform etc.)
* Scheduling policies (FirstComeFirstServe, ShortestRemainingProcessingTime etc.)
* Arrival rate of the jobs (poisson, uniform etc.) in comparison to their "service" rate
(not the author)
[0]: https://en.m.wikipedia.org/wiki/Poisson_point_process [1]: https://en.m.wikipedia.org/wiki/M/M/1_queue
It starts with a simple subject, and a mildly interesting result. Then obfuscates it with an unenlightening and confusing model. Then shows how to do lots of exploratory programming with that model and create apparently surprising results. Then uses it to sell the modeling tool so that you too can come to surprising results about things in a way that does not enlighten.
Here is the simple subject. If jobs are randomly coming in at the same speed that a worker can work, you will get a line. The lines can grow without bound, and the average length of the line is linear in the amount of time this has been going on. Therefore the amount of time spend waiting in line grows quadratically with how long this has been going on.
Add a second worker and the average length of line becomes a fixed, small number. Time waiting is now linear.
Add jobs as fast as both workers can work and voila, lines start growing again!
There are a lot of interesting results in queuing theory. But the stated style of experiment doesn't seem like a good way to figure it out.