← Blog

Microservices · Deadlines · Reliability

Who Owns the Deadline in a Chain of Microservice Calls?

Timeouts set independently in each service can keep work running long after the user has given up. This article explains how one end-to-end deadline, passed down the call chain, keeps every service working against the same clock.

Aashaya Aryal

October 8, 2026 · 15 min read

Updated November 17, 2026

Analog stopwatch photographed against a black background.

A user sends a request, and the frontend is willing to wait 800 ms for an answer. The API calls an order service with a 2-second timeout. The order service queries PostgreSQL with a 5-second statement timeout and calls a payment API with a 10-second timeout.

Each of those numbers looks reasonable on its own. Put together, they describe a system that can keep working for seconds after the user stopped waiting.

Diagram

Client
800 ms

API
2 s timeout

Order Service
5 s timeout

Payment Service
10 s timeout

Database

That leftover work still holds threads, connections, CPU, memory and database capacity. On a normal day the waste is small. Under overload it can be part of what keeps the system overloaded: callers give up, but servers keep spending scarce resources on results nobody will read. The Google SRE book describes this pattern in its chapter on addressing cascading failures.

Putting a timeout on every HTTP call is a good start, and it does stop calls from hanging forever. What it doesn't do is tell each service how much time the user has left. This article is about that missing piece: one end-to-end time budget for an operation, passed down so every service knows how much of it remains.

Timeouts and deadlines answer different questions

A timeout answers: how long may this particular call run? "Spend at most 500 ms on this HTTP request."

A deadline answers a broader question: at what point does the whole result stop being useful?

Say a request starts at 10:00:00.000 and the caller will wait 800 ms. The deadline is 10:00:00.800. If the API spends 150 ms authenticating, validating input and waiting for a worker, the next service doesn't get a fresh 800 ms. It has 650 ms left. If that service spends another 300 ms, the next hop has 350 ms.

Crossing a service boundary doesn't restart the user's clock. That sounds obvious written down, but many systems behave as if it does, because each service configures its own client timeouts with no knowledge of what came before.

How independent timeouts outlive the request

Here is a call chain where each layer picked its own timeout:

LayerTimeout
Client1 s
API3 s
Order service5 s
Inventory5 s
Database10 s

The client gives up after one second. Nothing in the downstream values makes the rest of the chain stop at that point.

Diagram
DatabaseInventoryOrder ServiceAPIClientDatabaseInventoryOrder ServiceAPIClient1 second passesDownstream work may continueRequesttimeout=3stimeout=5stimeout=10sGive up

The SRE book's version of this: one service uses most of its allowed time, then hands its dependency a brand-new timeout instead of what's left. The dependency starts work that can't possibly finish in time for the original caller. At that point the work isn't just slow. Its result is already unusable.

Passing the remaining budget downstream

The alternative is to start with one deadline and have every hop ask "how much time is left?" before calling the next one.

TimeHopRemaining
T+0 msClient → API800 ms
T+80 msAPI → Order service720 ms
T+210 msOrder → Inventory590 ms
T+350 msInventory → Database450 ms
Diagram
DatabaseInventoryOrder ServiceAPIClientDatabaseInventoryOrder ServiceAPIClient80ms consumed130ms consumed140ms consumeddeadline in 800ms~720ms remaining~590ms remaining~450ms remaining

Now the request is no longer five unrelated RPCs. It's one user operation with one shrinking budget, and every service sees the same picture.

gRPC builds this in. Its deadlines guide defines a deadline as the point after which the client won't wait any longer, lets the server check whether that point has passed, and supports deadline propagation: when a server calls another service, the outgoing call inherits the remaining time. Propagation is on by default in Java and Go, and has to be enabled in some other languages such as C++. gRPC also sends the remaining duration rather than an absolute timestamp, with time already spent deducted, which protects against clock skew between machines.

That is the behaviour worth copying even if you don't use gRPC: the work carries its remaining budget, and no hop invents a fresh timeout.

Who owns the deadline

Not the database, not the payment service, and not the API gateway. The deadline belongs to the operation someone is waiting on, and the outermost caller that cares about the result usually knows when it stops being valuable.

A browser might need a response within 2 seconds. A batch process might wait 30 seconds. A reconciliation job might wait several minutes. The same downstream service can receive all three deadlines on the same day, each one legitimate.

This is why a hard-coded timeout can't fully describe what a caller wants. The same dependency call is reasonable with 900 ms left and pointless with 12 ms left, even when the dependency is perfectly healthy both times.

It also leads to a slightly strange situation: a request can be doomed while every service is healthy. If a request has 12 ms left and the payment call normally takes 100 ms, nothing is broken and nothing on the dashboard is red, yet the operation can't succeed. Health tells you whether components work. Remaining time tells you whether this request can still finish.

Local limits still matter

Passing the deadline down doesn't mean every dependency should use all the time that's left. If the request has 4 seconds remaining but the inventory service has decided a single database lookup should never take more than 500 ms, the lookup should use whichever is smaller:

TS
const dbBudgetMs = Math.min(deadline.remainingMs(), 500);

The inherited deadline answers "when does my caller stop caring?" The local cap answers "how long am I willing to spend on this dependency?" Both are useful. A service should respect the caller's budget without giving up its own protection against a dependency that has gone pathological. Each layer is free to be stricter than the deadline; none should quietly extend it.

The same logic applies at the edge of your system, in the other direction. If an external caller sends a 6-hour deadline, you probably don't want to reserve resources for six hours. A sensible rule is effective deadline = min(caller deadline, endpoint maximum): a caller asking for 30 seconds on an endpoint capped at 2 seconds gets 2 seconds. The caller tells you when the result stops being useful to them; your service still protects itself.

Endpoint caps also tend to reveal API design problems. GET /users/123 might reasonably need 300 ms. POST /reports/yearly-export might need minutes, and a single global 5-second timeout is wrong for both. If an endpoint needs an enormous timeout, that's often a sign it should become an asynchronous job (submit, get a job ID, poll or get notified) rather than one long-held HTTP request.

Waiting in a queue spends the budget too

It's easy to count only active processing time. Suppose a request arrives with 500 ms remaining and spends 450 ms waiting for a worker thread. When it finally runs, 50 ms are left. Starting a 300 ms database query at that point makes little sense. The service should be able to say "there isn't enough time to begin this" and fail fast.

The SRE book calls out this queueing problem specifically: requests can wait so long for resources that their callers have already left before processing starts.

Rejecting that doomed work can increase how many requests succeed. Picture a service with 100 worker threads where 50 are busy with requests whose callers have already timed out. The service looks fully loaded, but half of it is producing nothing anyone will use. Stopping those requests frees capacity for requests that can still be answered in time.

This turns the deadline into a form of backpressure (a signal that slows or sheds work when a system can't keep up). Under overload, queue time grows, so requests reach workers with less time left, so more of them are rejected before doing expensive work, so less capacity is wasted. It doesn't replace load shedding, rate limiting or concurrency limits, but it complements them: requests that can no longer finish in time stop costing full price.

Stopping work nobody is waiting for

A deadline expiring at the caller is half the solution. The other half is getting that news to the code doing the expensive work. If a user navigates away and only the browser knows, the API, the recommendation service and the database may all carry on.

Diagram
DatabaseRecommendationsAPIClientDatabaseRecommendationsAPIClientAbandoned work stopsRequestSubrequestQueryCancelCancelCancel if supported

gRPC's cancellation guide describes this: when the caller no longer wants the result, ongoing work should stop where practical, and the cancellation should reach downstream calls started on its behalf.

There's a catch. A framework can tell your handler a request was cancelled, but it can't stop arbitrary work your code already started:

JAVA
executor.submit(() -> generateLargeReport());

If generateLargeReport() never checks for cancellation, it can keep running for another 30 seconds after the request is gone. The transport did its part; the application didn't. Long-running work needs a way to learn that its result is no longer wanted, and to stop at safe points.

When the work has side effects

Not every operation should be abandoned the moment the caller disappears. If the caller no longer wants recommendations, stopping is fine. A credit card charge is different. Once the request has reached the payment provider, the client's deadline expiring doesn't mean nothing happened. The charge may already have succeeded, and stopping your wait doesn't undo it.

gRPC's deadlines blog post points out exactly this case: the server can finish successfully while the response arrives after the deadline, so the client sees DEADLINE_EXCEEDED. A timeout doesn't tell you the operation failed. It tells you that you don't know.

Kind of workWhen the deadline passesTypical handling
Pure computationStopThe result is no longer useful
Read-only queryCancel when practicalFree the resources
External or irreversible side effectOutcome may be unknownReconcile, or retry idempotently

Here's how it plays out. The client deadline is 500 ms. At 490 ms the payment provider completes the charge. The response would arrive at 520 ms, but the client stopped waiting at 500. The client sees a timeout, the server recorded a success, and if the client retries without protection, the customer is charged twice.

The deadline didn't create that ambiguity; it exposed it. The fix is idempotency: giving the operation a stable identifier (say payment_request_42) that survives the first attempt, the timeout, the retry and any later status check, so the provider recognises repeats as the same charge. The Amazon Builders' Library covers this in Making retries safe with idempotent APIs. Deadlines limit how long you wait; idempotency makes the uncertainty afterwards safe to recover from. They belong in the same design conversation.

Retries and backoff share the same budget

Suppose the operation has 1 second, and the first attempt uses 800 ms before timing out. Launching a second attempt with a fresh 800 ms timeout would run past the deadline. Only 200 ms remain, and if the dependency can't realistically answer in 200 ms, the retry is just extra load.

So the retry loop has to live inside the deadline:

TS
async function callWithRetry(deadline: Deadline) {
  for (let attempt = 1; attempt <= 3; attempt++) {
    const remaining = deadline.remainingMs();

    if (remaining < MIN_USEFUL_ATTEMPT_MS) {
      throw new DeadlineExceededError();
    }

    const timeout = Math.min(remaining, PER_ATTEMPT_CAP_MS);

    try {
      return await callDependency({
        timeout,
      });
    } catch (error) {
      if (!isRetryable(error)) {
        throw error;
      }
    }
  }
}

That means retries have two budgets: a number of attempts and an amount of time. With a 900 ms budget, an attempt of 300 ms, a 100 ms backoff and a second 300 ms attempt leave 200 ms. The attempt counter may say one try is left while the clock says it isn't worth it. Both signals matter.

Backoff waits come out of the same budget too. Before scheduling the next retry, check that there's enough time for the wait, the network round trip and the actual processing. Exponential backoff with jitter is valuable because it spreads retries out and stops clients hammering a recovering service in sync, but even a well-designed schedule doesn't help if the successful answer arrives after the caller has left.

AWS's Well-Architected guidance on setting client timeouts describes the tension from both sides: timeouts that are too long hold resources during failures, and timeouts that are too short trigger extra retries that make an overloaded backend busier. It also warns that some client libraries default to infinite or very long timeouts.

Picking timeout values from real latency

A value like 500 ms should come from somewhere: the dependency's observed latency, the business latency goal, how many false timeouts you can tolerate, and the network path. Suppose a dependency's latency percentiles are:

PercentileLatency
p5040 ms
p9590 ms
p99180 ms
p99.9420 ms

A 50 ms timeout would fail a large share of requests that would have succeeded. A 30-second timeout would hold resources far too long during a real outage. gRPC's guidance is similar: choose deadlines from how your application actually behaves and validate them with load testing.

Remember that a remote call is more than the server's processing time. It can include DNS lookup, TCP connection, TLS handshake, waiting for a pooled connection, proxies and load balancers, transit, and queueing on the server. Different libraries count different parts of that path in different timeout settings, so it's worth knowing exactly what yours measure. A request on a warm connection might take 40 ms; the same request on a cold connection (DNS, TCP and TLS first) might take 130 ms. A timeout tuned only for the warm case will start failing after a deployment, a burst of connection churn or a certificate change.

Fan-out and partial results

When an API calls several services in parallel, they share one deadline. They don't each get a fresh interval.

Diagram

API

Profile

Inventory

Recommendations

Pricing

If the operation has 500 ms left, that's 500 ms for all four. This gets useful when the dependencies aren't equally important. Inventory and pricing might be required while recommendations are optional. With little time left, returning a page without recommendations is often better than missing the whole deadline.

The same idea applies to a dashboard built from five services. If four answer within 200 ms, one is struggling, and the deadline is 700 ms, then at 650 ms the API can either keep waiting and risk failing everything, or return four of the five widgets. That isn't always acceptable, but where it is, deadlines let you express a priority a plain timeout can't: this optional piece isn't worth risking the whole response. Thinking about deadlines forces the question of which parts of a response actually matter.

Asynchronous jobs get their own deadlines

Queues complicate things. If an HTTP request enqueues a job and waits synchronously for the result, the original deadline still applies. But if the service returns 202 Accepted and promises to finish later, the HTTP request and the job are now different operations. The job might have its own contract, such as "complete within 10 minutes". Copying a short HTTP deadline onto work that exists specifically to outlive the request would be a mistake. A deadline belongs to an operation, and when the operation changes, so can the deadline.

For the synchronous case, the message can carry the original deadline:

JSON
{
  "requestId": "req_92",
  "deadline": "2026-10-08T22:00:00.800Z",
  "payload": {}
}

The worker checks it before doing anything expensive:

TS
if (Date.now() >= message.deadline) {
  metrics.expiredBeforeProcessing.inc();
  return;
}

Without that check, a message can wait 2 seconds in the queue, take 1 second to process, and finish 2.5 seconds after the caller stopped waiting. A queue shouldn't turn expired work back into fresh work.

Building a budget from the outside in

A deadline isn't the same as an SLO (service level objective). An SLO such as "99% of checkout requests complete within 800 ms" describes behaviour across many requests. A deadline describes how long one specific operation stays useful. They should inform each other, but a system can reasonably let its slowest 1% exceed the SLO target while still having a somewhat larger hard deadline, and an individual caller may be less patient than the SLO.

What the SLO is good for is deriving the budget. If checkout should normally finish within 1 second, you can split that from the outside in:

PartBudget
End-to-end1000 ms
Gateway and network80 ms
Application overhead120 ms
Safety margin100 ms
Left for dependencies700 ms

The dependency path might then need about 150 ms for inventory, 350 ms for payment and 100 ms for the database, with some of that running in parallel. The numbers won't be exact. What matters is that they come from one end-to-end requirement. If instead each team picks its own value (inventory 2 s, payment 5 s, database 10 s), there's no way the combination meets a one-second checkout goal.

Carrying the deadline in code

You don't need gRPC to do this. A small class carried through your request context is enough:

TS
class Deadline {
  constructor(private readonly expiresAt: number) {}

  remainingMs(): number {
    return Math.max(0, this.expiresAt - Date.now());
  }

  expired(): boolean {
    return this.remainingMs() === 0;
  }

  timeoutFor(localCapMs: number): number {
    return Math.min(this.remainingMs(), localCapMs);
  }
}

Create it at the edge:

TS
const deadline = new Deadline(Date.now() + 800);

Then derive each downstream timeout from what's left:

TS
const timeout = deadline.timeoutFor(300);

if (timeout < 50) {
  throw new DeadlineExceededError();
}

await inventoryClient.getItem(productId, { timeout });

In gRPC Java, the client applies the remaining time to the stub:

JAVA
InventoryGrpc.InventoryBlockingStub stub =
    inventoryStub.withDeadlineAfter(
        remainingMillis,
        TimeUnit.MILLISECONDS
    );

For Spring applications on plain HTTP, the same thing can travel in request context or propagated headers. The transport doesn't matter much. What matters is keeping one clock for the operation.

Seeing where the time went

Ordinary latency metrics tell you a request took 780 ms. Deadline-aware telemetry can tell you how it got there. A trace that records the remaining budget at each hop might show the API starting with 790 ms, the order service with 630 ms, payment with 410 ms, and a payment retry with 130 ms. Now it's clear why a further retry would be pointless.

TEXT
Checkout [800ms deadline]
├── Auth          45ms
├── Inventory    120ms
└── Payment
    ├── Queue     180ms
    ├── Attempt 1 260ms
    ├── Backoff   100ms
    └── Attempt 2 started with 70ms remaining

"Payment was slow" becomes something specific: the second attempt started without enough time to succeed. That's much easier to act on.

Metrics worth adding:

  • deadline_exceeded_total
  • cancelled_total
  • expired_before_processing_total
  • remaining_budget_at_dependency_call
  • retry_skipped_due_to_deadline
  • work_completed_after_caller_cancelled

The last one is my favourite because it measures wasted capacity directly.

When deadline errors go up, don't assume the backend got slower. The caller may have shortened its deadline, network latency may have risen, queueing may have increased, or the retry policy may be eating more of the budget. If a caller sends a 50 ms deadline to a service that normally needs 100 ms, every request fails even though nothing degraded. The contract became impossible.

Key takeaways

  • Give every externally started request a finite end-to-end deadline, and pass the remaining time to each downstream call.
  • Let services apply stricter local caps, and cap what external callers can ask for, but never let a hop extend the original deadline.
  • Count queue time, connection setup and backoff against the same budget as processing. Reject work early when there isn't enough time left to finish it.
  • Propagate cancellation, and make long-running application code check for it.
  • Treat a timeout on side-effecting work as "outcome unknown", and use idempotency keys or reconciliation to recover safely.
  • Choose timeout values from measured latency, and give asynchronous jobs deadlines that match their own purpose.
  • Record remaining budget in traces and track work that finished after the caller left. That's the waste a deadline is meant to prevent.

References