Course contentsShow
← System Design
Lesson 1113 of 1,91928. Timeouts and DeadlinesFree lesson

Cross-Protocol Deadline Handling

Managing deadlines when requests traverse multiple protocols like HTTP, gRPC, and message queues.

Cross-Protocol Deadline Handling

You'll learn how to maintain deadline consistency when requests cross protocol boundaries like HTTP → gRPC → message queues.

The Multi-Protocol Reality

Modern distributed systems rarely speak just one protocol. A user's HTTP request might trigger a gRPC call to a backend service, which publishes to Kafka, which triggers another microservice via AMQP. Each protocol has its own timeout/deadline mechanism, and deadlines must translate correctly at every boundary to maintain end-to-end timeout integrity.

The Translation Challenge

Each protocol expresses deadlines differently:

  • HTTP: Custom headers like X-Timeout-Ms or Request-Timeout
  • gRPC: Native grpc-timeout header with automatic propagation
  • Message Queues: Message TTL or expiration properties
  • Internal RPC: Context objects with deadline fields

When crossing boundaries, you must:

  1. Extract the deadline from the incoming protocol's format
  2. Calculate remaining time budget after processing
  3. Translate to the outgoing protocol's format
  4. Handle missing deadlines (apply sensible defaults)

Example Flow

An HTTP request arrives with X-Timeout-Ms: 5000. Your service spends 200ms processing, then makes a gRPC call. You extract 5000ms, subtract elapsed time (4800ms remaining), convert to gRPC format (4800m), and set grpc-timeout: 4800m. The gRPC service later publishes to Kafka with a message TTL of the remaining deadline.

The Normalization Strategy

Adopt an internal deadline representation (like absolute timestamp or duration) that all gateway code translates to/from protocol-specific formats. This prevents conversion bugs and ensures consistency.

Key Takeaway: Cross-protocol deadline handling requires explicit translation logic at every boundary, converting between protocol-specific formats while preserving the remaining time budget to prevent timeout violations across your entire request chain.