Course contentsShow
← Cloud and Infrastructure
Lesson 2591 of 2,98955. Microservices on CloudFree lesson

Timeout and Deadline Propagation

Configure appropriate timeouts and propagate deadlines across service calls to prevent resource exhaustion.

Timeout and Deadline Propagation

What you'll learn: How to configure timeouts and propagate deadlines across microservice calls to prevent cascading failures and resource exhaustion.

The Problem

When Service A calls Service B, which calls Service C, how long should each service wait? Without proper timeout management, a slow service at the end of the chain can hold resources hostage throughout the entire call stack, eventually exhausting connection pools, threads, and memory across your system.

Understanding Deadline Propagation

Deadline propagation means each service in a call chain inherits and respects the remaining time budget from its caller. Think of it like a relay race where each runner knows exactly how much time is left to complete the entire race—not just their leg.

When Service A sets a 5-second timeout and calls Service B at second 1, Service B should configure its downstream calls with a remaining deadline of 4 seconds (or less, accounting for its own processing). This prevents Service C from attempting a 10-second operation when the original caller will abandon the request in 3 seconds anyway.

Configuration Best Practices

Set per-service timeouts based on SLA requirements and measured latencies. For HTTP calls, configure both connection and read timeouts. For gRPC, use context deadlines that automatically propagate.

Always set timeouts shorter than your upstream caller's timeout—leave buffer for network latency and processing. A common pattern: if your service has a 10-second timeout, configure downstream calls at 8 seconds maximum.

Implementation Approach

Most modern frameworks support deadline propagation. HTTP headers like X-Request-Deadline or gRPC's built-in context deadlines carry timing information. Your services should extract this metadata, calculate remaining time, and apply it to outbound calls.

Key Takeaway: Timeout and deadline propagation prevents slow downstream services from exhausting resources across your entire microservices architecture by ensuring every service respects the caller's time budget and passes reduced deadlines to its dependencies.