Performance testing/queue theory

23 Views Asked by At

During performance testing, I've encountered a problem I think must belong to queue theory, but I can't seem to find a solution to this scenario. So the problem is as follows: There are N clients and one instance of a resource shared among all clients. Each client operates in a loop as follows:

  1. The client does some work (not requiring the shared resource) that takes X amount of time, where X is iid uniformly distributed on some interval [a,b]. X is randomly selected for every iteration and is independent of all other iterations and other clients.
  2. The client then requests and uses the shared resource for some fixed amount of time, c. Then it releases the resource again.

Now the question is, what is the expected throughput (the sum of completed iterations per time unit across all clients) and what is the probability distribution of the time it takes to complete one iteration of the loop above (e.g. latency)?

Of course, the maximum achievable throughput is 1/c (where the shared resource is maximally utilized). Reaching this will often (depending on the other constants) require a high number of clients which will lead to queuing at the resource, thereby prolonging the execution time of the second step in the loop, increasing the latency. Conversely, minimal latency is achieved when there's only one worker, so there's never a queue. Here the latency will be distributed as X + c but the throughput will also be limited to 1/(E[X] + c).

What I'm looking for is some formula/solution describing the behavior of throughput and latency as a function of N, in this simplified model.