Backpressure and capacity

A queue buys time. It does not create processing capacity.

Written deep dive25% previewBy Daniyal Saqib

Read the opening here. A free account gives you the full guide.

Follow an AI assistant that accepts PDFs and makes them searchable within three minutes. A queue holds accepted work, workers process it, and a policy decides when to buffer, scale, or refuse new work. The rates and durations below are illustrative assumptions, not measurements of InterviewLayer.

01

Protect the completion promise

A quick upload response can hide a growing completion delay.

A user uploads a PDF. The API durably accepts its processing job, returns a receipt, and a worker later extracts, embeds, and indexes the document. Acceptance means that our service has taken responsibility for this job; searchable completion is a later event. The three-minute target runs from acceptance to that completion.

Suppose uploads keep succeeding immediately while documents wait longer in the queue. The upload API can look healthy even as users wait too long to search their documents. We therefore measure accepted-to-searchable time as well as response time. Waiting is part of the user experience even when it happens outside the HTTP request.

The queue lets already accepted work survive a worker interruption and wait for another attempt. That is useful, but it cannot make workers finish faster. Our next decision is how much waiting the product can absorb, when additional workers help, and what to do before accepting work we cannot safely finish.

02

Separate what can finish from what does finish

Capacity is a tested ability; throughput is an observed completion rate.

Normally four documents arrive each second. Tests on this workload suggest that the current worker fleet can finish about five documents per second when it has enough work. Five per second is its useful capacity under those test conditions. With only four arriving and no backlog, actual throughput is about four, because there is no fifth document to finish.

Once enough work is waiting, completions can approach the tested five-per-second rate. If fifteen are accepted each second while five finish, unfinished work increases by about ten each second. Count successful document completions, rather than worker starts or attempts, because a failed attempt can consume resources without producing a searchable document.

Our estimates assume similarly sized jobs, arrival-order waiting, roughly even completions, and a stable useful service rate. We count waiting documents separately from documents already being processed. Those assumptions make the arithmetic understandable; they do not guarantee an exact deadline for every PDF. A different document mix needs another capacity measurement.

03

Let a finite spike drain

A burst can be buffered when later spare capacity and the waiting budget are sufficient.

Start with almost no waiting work. Uploads jump from four to fifteen per second for thirty seconds.

7 more sections to read

Sign in to keep reading

Backpressure and capacity

Continue this section and read the complete guide and explore its visuals.

Free account. No payment required.

Read how we handle account information in our privacy notice.

7 more sections to read

There’s more in the full article

Continue reading with a free account.

Keep reading

Free account. No payment required.

Inside the full article

Continue the guide with 7 more sections.

  1. Recognize overload that will not drain by itselfRead after sign-in
  2. Add enough capacity to catch upRead after sign-in
  3. Let a controller request workersRead after sign-in
  4. Estimate one document’s waitRead after sign-in
  5. Find the bottleneck before adding workersRead after sign-in
  6. Protect the acceptance boundaryRead after sign-in
Show 1 more sections
  1. Combine buffering, scaling, and protectionRead after sign-in
Continue reading

7 more sections to read

Sign in to keep reading

Backpressure and capacity

Continue this section and read the complete guide and explore its visuals.

Free account. No payment required.

Read how we handle account information in our privacy notice.