InterviewHubPRO
Section Overview
Q34

Question 34 of 50

Part 3: Distributed Transactions, Consensus & Reliability (26 - 36)

68%
System Design (50 Qs)•Part 3: Distributed Transactions, Consensus & Reliability (26 - 36)

Dead Letter Queues (DLQ) and Exponential Backoff with Full Jitter.

In Simple Words: When retrying failed network calls or message processing, retrying immediately causes thundering herd traffic spikes.

  • Exponential Backoff: Multiplies sleep interval by $2^n$ on each failure ($1s, 2s, 4s, 8s, 16s...$).
  • Full Jitter: Adds random uniform delay ($sleep = \text{random}(0, min(\text{cap}, \text{base} \times 2^{\text{attempt}}))$) to desynchronize retrying clients.
  • Dead Letter Queue (DLQ): After maximum attempts (e.g. 5 retries), unprocessable messages are routed to a DLQ for inspection rather than blocking the main pipeline.
typescript
export function calculateBackoffWithJitter(attempt: number, baseMs = 100, maxMs = 5000): number {
  const exponential = Math.min(maxMs, baseMs * Math.pow(2, attempt));
  return Math.floor(Math.random() * exponential);
}