# Naturally occurring concurrency

I needed to predict the level of concurrency that will naturally occur given a level of traffic and a time frame. For example:

A test case takes 3 minutes to run (including think time). 20 iterations need to run in 1 hour but be random, just as traffic to a web site is. Straight math says EXACTLY 20 cases of 3 minutes each can execute consecutively with zero concurrency. However we intuitively know that such a distribution is extremely unlikely. Given random starting times, there will certainly be SOME amount of concurrency but how much?

Here’s the model that I came up with and I welcome any feedback.

Since there are (20) 3 minute time slots in 60 minutes, randomly draw a number between 1 and 20 for each iteration. Count the results by slot. Any slot that has more than one test = concurrency.

I plugged this into Excel and looked at sample sizes of up to 3000 and the answer is ~27% of the time.

See below for a small sample.

 Randomized slot for a test iteration to start Tests  Per Slot 27% 38% 36% Slots 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 Multiple Single None 20 20 19 7 16 11 5 14 5 19 15 8 15 1 10 13 13 6 18 9 9 1 0 0 0 2 1 1 1 2 1 1 0 2 1 2 1 0 1 2 1 25% 50% 25% 9 14 5 9 12 17 11 10 2 7 1 11 18 11 19 18 6 13 18 20 1 1 0 0 1 1 1 0 2 1 3 1 1 1 0 0 1 3 1 1 15% 60% 25% 11 12 5 4 14 20 13 10 11 6 12 5 7 19 3 16 4 3 5 16 0 0 2 2 3 1 1 0 0 1 2 2 1 1 0 2 0 0 1 1 30% 35% 35% 15 20 2 18 13 9 16 9 11 13 19 12 7 18 3 20 19 10 20 16 0 1 1 0 0 0 1 0 2 1 1 1 2 0 1 2 0 2 2 3 30% 35% 35% 7 10 8 12 18 11 14 4 18 4 17 7 15 3 5 6 4 4 12 15 0 0 1 4 1 1 2 1 0 1 1 2 0 1 2 0 1 2 0 0 25% 40% 35% 12 11 20 20 10 1 11 18 10 7 15 9 14 20 18 15 2 20 15 11 1 1 0 0 0 0 1 0 1 2 3 1 0 1 3 0 0 2 0 4 25% 30% 45% 14 12 4 5 8 16 20 19 13 7 16 16 6 10 12 14 7 15 17 10 0 0 0 1 1 1 2 1 0 2 0 2 1 2 1 3 1 0 1 1 25% 45% 30% 14 17 11 5 15 14 7 18 8 12 2 3 7 7 2 13 5 7 7 14 0 2 1 0 2 0 5 1 0 0 1 1 1 3 1 0 1 1 0 0 20% 40% 40%

I'm not a mathematician and this may not hold true under different circumstances but it was a useful way of illustrating the concept with my client.