Tutorials › Calculus I › Queue Length From Arrival And Service Rates

Calculus-Based Model Construction · Tutorial 1476 of 1495

Queue Length From Arrival And Service Rates

Learn how arrival and service rates determine when a queue grows, shrinks, or empties, and how to keep rate-based predictions physically meaningful.

Advanced 11 min read

What You'll Learn

  • Define queue length, arrival rate, service capacity, and actual departure rate in a fluid model.
  • Compute queue changes by integrating net rates while the queue remains positive.
  • Identify intervals of buildup and reduction from the comparison of arrival and service rates.
  • Adjust predictions when a queue empties before service capacity is fully used.
  • Check queue predictions using conservation of jobs and the nonnegative constraint.

Why Queue Length Needs a Constraint

A queue grows when work arrives faster than it can be served and shrinks when service capacity exceeds arrivals. A first calculation might subtract the service rate from the arrival rate and integrate the result. That works only while the queue is positive. If the queue empties, service cannot remove jobs that are not there.

We will use a fluid model: the queue length is allowed to be a nonnegative real number, rather than only a whole number. This approximation is useful when describing aggregate flow over time. It also makes the rate balance explicit. A prediction from the balance must still satisfy the physical condition that the queue cannot be negative.

Rates and the Queue Balance

Let \(q(t)\) be the amount of work waiting in the queue at time \(t\), measured in jobs. Let \(\lambda(t)\) be the arrival rate and \(\mu(t)\) the service capacity, both measured in jobs per unit time. The actual departure rate may be less than the capacity: if the queue is empty and arrivals are slow, the system cannot serve jobs that have not arrived.

Definition: A fluid queue has queue length \(q(t)\ge 0\), arrival rate \(\lambda(t)\ge 0\), and service capacity \(\mu(t)\ge 0\). When \(q(t)>0\), the full service capacity is used, so the actual departure rate is \(\mu(t)\). When \(q(t)=0\), the actual departure rate cannot exceed the arrival rate.

Write \(d(t)\) for the actual departure rate. The conservation balance is that the change in queue equals arrivals minus departures. Thus, wherever the rates and derivative are defined,

$$ q'(t)=\lambda(t)-d(t). $$

When the queue is positive, \(d(t)=\mu(t)\), so \(q'(t)=\lambda(t)-\mu(t)\). At an empty queue, actual departures are limited to the available arrivals: \(d(t)=\min\{\lambda(t),\mu(t)\}\). Consequently, the rate of change can be written as

$$ q'(t)= \begin{cases} \lambda(t)-\mu(t), & q(t)>0,\\[4pt] \max\{\lambda(t)-\mu(t),0\}, & q(t)=0. \end{cases} $$

This is a work-conserving model: available service capacity is used whenever there is work to serve. The formula at \(q(t)=0\) prevents the queue from decreasing below zero. If arrivals exceed capacity at an empty queue, the excess starts to build a queue. If capacity exceeds arrivals, all arrivals can be served immediately, and the queue stays empty.

Using Net Rates While the Queue Is Positive

On an interval where the queue remains positive, the queue change is the integral of the net rate \(\lambda(t)-\mu(t)\). If the rates are constant on an interval of length \(T\), this reduces to multiplying the net rate by \(T\). A positive net rate means buildup; a negative net rate means reduction. These conclusions apply only as long as the queue does not empty during the interval.

Worked Example: A Queue That Builds Up

A queue initially contains \(3\) jobs. Arrivals occur at \(7\) jobs per hour and service capacity is \(5\) jobs per hour for \(2\) hours. Find the queue length at the end.

The net rate is \(7-5=2\) jobs per hour, which is positive. The queue therefore stays positive and grows throughout the interval. Over \(2\) hours the change is

$$ (2\ \text{jobs/hour})(2\ \text{hours})=4\ \text{jobs}. $$

Adding this change to the initial queue gives

$$ q(2)=3\ \text{jobs}+4\ \text{jobs}=7\ \text{jobs}. $$

Check: Arrivals total \(7\times2=14\) jobs, and departures total \(5\times2=10\) jobs. The conservation balance gives \(3+14-10=7\) jobs, matching the prediction.

When rates change over time, the same balance uses an integral rather than a single rate multiplied by a duration. As long as \(q(t)>0\) throughout the interval from \(a\) to \(b\),

$$ q(b)=q(a)+\int_a^b\bigl(\lambda(t)-\mu(t)\bigr)\,dt. $$

The condition that the queue stays positive matters. If this expression predicts a negative queue at some time, the unrestricted balance has been used beyond its valid interval and must be corrected at the point the queue empties.

Worked Example: Reduction Followed by Buildup

A queue starts with \(4\) jobs. During the first hour, arrivals occur at \(3\) jobs per hour and service capacity is \(5\) jobs per hour. During the second hour, arrivals occur at \(6\) jobs per hour and service capacity is \(4\) jobs per hour. Find the queue at the end of each hour and identify the intervals of reduction and buildup.

In the first hour, the net rate is \(3-5=-2\) jobs per hour. The queue changes by \((-2)(1)=-2\) jobs, so after the first hour it contains

$$ 4-2=2\ \text{jobs}. $$

It remains positive during this hour: it decreases steadily from \(4\) jobs to \(2\) jobs. Thus the queue is reducing throughout the first interval.

In the second hour, the net rate is \(6-4=2\) jobs per hour. The change is \((2)(1)=2\) jobs, giving

$$ 2+2=4\ \text{jobs} $$

at the end of the second hour. It remains positive and is building up throughout that interval.

Check: Total arrivals are \(3+6=9\) jobs, and total departures are \(5+4=9\) jobs. Starting from \(4\) jobs, the balance predicts \(4+9-9=4\) jobs at the end, as calculated.

What Changes When the Queue Empties?

If the queue reaches zero, one must stop subtracting the full service capacity from arrivals. After that point, some capacity may be unused. The queue stays at zero for as long as capacity is at least as large as the arrival rate. If arrivals later exceed capacity, the queue starts to grow again.

For constant rates with \(\mu>\lambda\) and a positive initial queue \(q_0\), the net reduction rate is \(\mu-\lambda\). If that rate continues, the queue empties after \(q_0/(\mu-\lambda)\) units of time. This calculation identifies when the positive-queue balance stops applying. The queue cannot be allowed to continue decreasing after that time.

Worked Example: Capacity Exceeds the Work Remaining

A queue starts with \(2\) jobs. For one hour, arrivals occur at \(1\) job per hour and service capacity is \(4\) jobs per hour. Find the ending queue, total departures, and total unused service capacity.

While the queue is positive, its net reduction rate is \(1-4=-3\) jobs per hour. At that rate, the \(2\)-job queue empties after

$$ \frac{2\ \text{jobs}}{3\ \text{jobs/hour}}=\frac{2}{3}\ \text{hour}. $$

For the first \(2/3\) hour, the queue is positive and all service capacity is used. During this part, \(2\) initial jobs and \(1\times(2/3)=2/3\) arriving jobs are served, for a total of \(2+2/3=8/3\) departures. For the remaining \(1/3\) hour, the queue is empty. Arrivals continue at \(1\) job per hour and are served as they arrive, so \(1\times(1/3)=1/3\) more job departs. Total departures are therefore

$$ \frac{8}{3}+\frac{1}{3}=3\ \text{jobs}. $$

The ending queue is zero. Over the full hour, the service capacity is \(4\times1=4\) jobs, while actual departures total \(3\) jobs. Hence total unused capacity is \(4-3=1\) job. More precisely, capacity is unused at a rate of \(3\) jobs per hour during the final \(1/3\) hour after the queue empties. Its total over that interval is \((3\ \text{jobs/hour})(1/3\ \text{hour})=1\) job.

Check: The conservation balance gives initial queue \(2\) jobs plus \(1\) arriving job minus \(3\) departing jobs, which is \(0\) jobs. This agrees with the nonnegative queue calculation.

A General Nonnegative Queue Formula

There is a concise way to describe the correction for time-varying rates. Suppose the rates are integrable and the initial queue is \(q_0\ge 0\). First calculate the queue that would result if the full capacity were always used, even when no work remained. Call this unrestricted balance \(x(t)\):

$$ x(t)=q_0+\int_0^t\bigl(\lambda(s)-\mu(s)\bigr)\,ds. $$

This balance may become negative, so it is not always a physically valid queue. Define the cumulative unused capacity needed to keep it nonnegative by

$$ L(t)=\max\left\{0,\ \sup_{0\le s\le t}[-x(s)]\right\}. $$

Then the constrained queue is \(q(t)=x(t)+L(t)\). The correction \(L(t)\) is nondecreasing: once capacity has gone unused, its cumulative total cannot decrease. It grows only as needed to offset a negative unrestricted balance. In the fluid queue, this corresponds to capacity that cannot be used because the queue is empty.

Theorem: For integrable arrival and capacity rates and initial queue \(q_0\ge0\), the work-conserving fluid queue is \(q(t)=x(t)+L(t)\), where \(x(t)=q_0+\int_0^t(\lambda(s)-\mu(s))\,ds\) and \(L(t)=\max\{0,\sup_{0\le s\le t}[-x(s)]\}\). The correction \(L\) is the smallest nondecreasing correction that keeps \(x+L\) nonnegative.

To justify the formula, first observe that for every \(s\le t\), \(L(t)\ge -x(s)\), and \(L(t)\ge0\). In particular, taking \(s=t\) gives \(x(t)+L(t)\ge0\), so the proposed queue never becomes negative. The supremum records the largest deficit encountered up to time \(t\); if that deficit increases, the correction increases just enough to offset it. This increase can occur only when \(x(t)+L(t)=0\), because a new largest deficit means \(L(t)=-x(t)\).

For minimality, let \(R(t)\) be any nondecreasing correction with \(R(t)\ge0\) and \(x(s)+R(s)\ge0\) for all \(s\). Then \(R(s)\ge -x(s)\) at every \(s\), and monotonicity gives \(R(t)\ge R(s)\) whenever \(s\le t\). Therefore \(R(t)\) is at least every value \(-x(s)\) for \(s\le t\), and it is also at least zero. It follows that \(R(t)\ge L(t)\). Thus \(L\) is the smallest cumulative correction that keeps the queue nonnegative. In queue terms, it is precisely the amount of service capacity left unused to avoid serving nonexistent work.

A Common Mistake: Subtracting Capacity After Emptying

A frequent error is to apply \(q_0+(\lambda-\mu)T\) over an entire interval without checking whether the queue stays positive. For the one-hour example above, that calculation gives

$$ 2+(1-4)(1)=2-3=-1\ \text{job}. $$

This result is impossible: it violates \(q(t)\ge0\). The rate calculation is valid only until the queue empties, which occurs after \(2/3\) hour. After that, actual departures equal arrivals at \(1\) job per hour, rather than continuing at the \(4\)-job-per-hour capacity. The corrected ending queue is zero, with \(1\) job of unused capacity over the hour.

Another way to catch this mistake is to check conservation using actual departures, not capacity. Capacity is a maximum possible departure rate; it is not necessarily the number of jobs served when the queue empties during the interval.

Practical Checks for a Queue Model

Before accepting a queue prediction, check the following:

  • Units: Rates have units such as jobs per hour; integrating a rate over hours gives jobs.
  • Sign: A positive arrival-minus-capacity rate grows a positive queue; a negative one reduces it.
  • Empty intervals: Once the queue reaches zero, do not subtract unused capacity from it.
  • Conservation: Ending queue equals starting queue plus arrivals minus actual departures.
  • Nonnegativity: Every predicted queue length must be at least zero.

These checks distinguish a meaningful queue model from an unrestricted rate calculation. The key idea is to use the net rate while work is waiting, then respect the boundary at zero when no work remains.

Check Your Understanding

For each question, state the relevant rates and account for whether the queue remains positive.

  1. A queue has \(5\) jobs. Arrivals are \(4\) jobs per hour and capacity is \(2\) jobs per hour for \(3\) hours. What is the ending queue, and how can you check it by conservation?
  2. A queue contains \(6\) jobs, with arrivals at \(2\) jobs per hour and capacity at \(5\) jobs per hour. How long does it take to empty if the rates persist?
  3. When the queue is empty and arrivals are \(3\) jobs per hour while capacity is \(7\) jobs per hour, what are the actual departure rate and queue-change rate?
  4. Why does a negative result from the unrestricted balance indicate that the full-capacity calculation cannot apply over the whole interval?
  5. In the nonnegative queue formula, what does the correction \(L(t)\) represent in the service system?

Test yourself: Calculus I final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon