Design Patterns · Study deck

Service Resilience: Breakers, Retries, and Timeouts

A blind retry repeats a request without checking whether it already worked.

Blueprint Bina is your guide for this deck.

resilience
Blueprint Bina, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: Normal device traffic reaches capacity before the dependency failure; synchronized clients then retry on the same schedule, creating a second spike above server capacity precisely while the service is trying to recover.
  • Explain: Cancel work: Propagate cancellation so downstream services stop doing work after the caller no longer needs the result.
  • Explain: Retries are useful only when the failure is likely transient and the operation is safe to repeat.
  • Explain: It decides whether the caller should attempt the dependency now or fail fast and use fallback behavior.
iotclass.org

Major section

Failure Modes in IoT Services

A database query, external API, model inference endpoint, or message broker takes much longer than expected.

  • A recovering dependency receives synchronized traffic and fails again.
  • A lost acknowledgement makes a caller retry a command that already succeeded.
  • One dependency consumes the shared worker pool, connection pool, queue, or rate limit.

Key terms

Healthy features
Healthy features are blocked by an unhealthy dependency.
iotclass.org

Major section

Failure Modes in IoT Services (continued)

Healthy features are blocked by an unhealthy dependency.

  • Cloud services are unreachable but the edge gateway, local device network, or cached configuration still works.
  • The system needs a local or degraded operating mode.
  • One malformed message fails repeatedly and blocks a queue consumer.
  • The pipeline needs retry limits and a dead-letter route.
iotclass.org

Major section

Circuit Breaker Pattern

A circuit breaker is a state machine around a dependency call.

  • It decides whether the caller should attempt the dependency now or fail fast and use fallback behavior.
  • A timer alone does not declare the dependency healthy: probe outcomes do.
  • Calls do not reach the dependency.
  • The caller returns fallback behavior quickly and protects its own resource pool.

Why it matters

After a cooldown, the policy allows a small number of probes.

Circuit breaker states for service calls
Circuit breaker states for service calls
iotclass.org

Major section

Retry, Backoff, and Jitter

Retries are useful only when the failure is likely transient and the operation is safe to repeat.

  • A retry policy should answer four questions before it is enabled.
  • Reads are usually safe.
  • Writes need idempotency keys, command sequence numbers, or server-side deduplication.
  • Retries must fit inside the caller's total deadline.

Why it matters

Exponential backoff lowers attempt frequency, jitter spreads attempts in time, a retry budget caps amplification, and idempotency prevents a delayed acknowledgement from turning the recovery wave into duplicate physical commands.

Naive retry storm after a dependency failure
Naive retry storm after a dependency failure
iotclass.org

Major section

Retry, Backoff, and Jitter (continued)

Connection resets, rate limits, and temporary unavailability can be retry candidates.

  • Normal device traffic reaches capacity before the dependency failure; synchronized clients then retry on the same schedule, creating a second spike above server capacity precisely while the service is trying to recover.
  • Invalid input, authorization failure, and missing resources usually are not.
  • Exponential backoff reduces pressure.
iotclass.org

Major section

Timeouts and Deadlines

Resilient services usually need both.

  • A status request may have a small budget; a firmware transfer may have a larger one.
  • Cancel work: Propagate cancellation so downstream services stop doing work after the caller no longer needs the result.
  • The service may open circuits or use fallback unnecessarily.
iotclass.org

Major section

Bulkhead Pattern

Bulkheads limit the blast radius of a dependency, tenant, device fleet, or workload class.

  • The goal is simple: one failing dependency should not consume all resources that healthy work needs.
  • Each pool keeps its own workers and links.
  • A queue limit or rejection path stops one load from taking the next pool.
  • A slow dependency cannot take every socket.
Bulkhead isolation with separate thread pools
Bulkhead isolation with separate thread pools
iotclass.org

Major section

Fallback and Graceful Degradation

Fallback is not the same as hiding the problem.

  • A good fallback is honest, useful, and bounded.
  • For high-risk physical actions, require an operator to confirm state rather than silently retrying.
  • When no safe fallback exists, fail clearly and preserve resources instead of pretending the action succeeded.
iotclass.org

Major section

Common Pitfalls

Increasing timeouts may hide symptoms while making resource exhaustion worse.

  • Failing fast protects resources, but the product still needs a user-visible or workflow-visible degraded result.
  • One pool for every downstream call makes one slow dependency everyone's incident.
  • Backoff without jitter can still synchronize clients.
  • Jitter is essential for device fleets.
iotclass.org

Major section

Summary

Retries need idempotency, backoff, jitter, and a retry budget.

  • Circuit breakers fail fast after repeated failure signals and use half-open probes for recovery.
  • Bulkheads isolate resource pools so healthy features keep working.
  • Fallback behavior should be explicit, tested, observable, and honest about degraded mode.

Why it matters

Resilience patterns prevent one failed dependency from consuming the whole service.

iotclass.org

Deck summary

Key takeaways

A database query, external API, model inference endpoint, or message broker takes much longer than expected.

  • Healthy features are blocked by an unhealthy dependency.
  • A circuit breaker is a state machine around a dependency call.
  • Retries are useful only when the failure is likely transient and the operation is safe to repeat.
  • Connection resets, rate limits, and temporary unavailability can be retry candidates.
iotclass.org

Retrieval practice

Recall check 1 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q1A telemetry enrichment service calls a machine-learning endpoint. The endpoint starts timing out. After repeated timeouts, the caller opens its circuit breaker and serves last-known enrichment metadata from cache. What is the main benefit?

AThe caller keeps worker threads free instead of waiting on a dependency already known to be failing.
BThe endpoint receives more requests from callers and therefore recovers faster from the timeouts during the outage.
CThe caller removes all timeout settings because the circuit breaker alone bounds every request.
DThe caller no longer observes breaker state or fallback use once the cache is available.
Show answer

Answer: A Circuit breakers prevent cascading failure by stopping calls that are likely to waste resources.

iotclass.org

Retrieval practice

Recall check 2 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q2A gateway sends a command to unlock a service cabinet. The network drops before the gateway receives the acknowledgement. The command may have succeeded. What should the retry policy require before sending the command again?

AA faster retry interval so the operator sees a quick result
BA longer gateway timeout with no receiver-side tracking
CA command ID that lets the receiver deduplicate repeats
DA circuit breaker around code that never crosses a dependency
Show answer

Answer: C Retries for actuator and provisioning commands need idempotency.

iotclass.org

Retrieval practice

Recall check 3 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q3A service call has a two-second user deadline. The first attempt to a downstream service fails after 1.8 seconds, leaving 0.2 seconds; the minimum useful retry timeout is 0.5 seconds. What should a well-designed retry policy do next?

ARun all configured retries even after the user deadline, allowing late results and extra load.
BTurn off the circuit breaker because one failed attempt makes further failure tracking unnecessary.
CSkip the retry because the remaining 0.2-second deadline cannot fit a useful 0.5-second attempt.
DMove the request into the shared pool so more threads can absorb an already late retry.
Show answer

Answer: C Retries belong inside a deadline and retry budget.

iotclass.org

Retrieval practice

Recall check 4 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q4What repeats only safe service operations with limits, backoff and jitter after transient failure?

ATimeout
BCircuit breaker
CBulkhead
DRetry
Show answer

Answer: D It repeats only safe operations with limits, backoff, and jitter after transient failure.

iotclass.org

Retrieval practice

Recall check 5 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q5A configuration service returns HTTP 503 during a rolling restart. Device clients need to retry, but the platform has hundreds of thousands of devices. Which retry behavior is most appropriate?

AFixed one-second retries by every device until the configuration service recovers
BNo retry for any HTTP 503 response even when the rolling restart is transient
CImmediate retries without timeouts because the rolling restart will soon finish
DExponential backoff with random jitter and a maximum retry budget for each device
Show answer

Answer: D Retry storms are common in device fleets.

iotclass.org

Retrieval practice

Recall check 6 of 6

Blueprint Bina says: answer from memory, then check your reasoning.

Q6Which statement best describes the difference between a circuit breaker and a bulkhead?

AA circuit breaker stores messages while a bulkhead changes the version of a public API.
BA circuit breaker serves databases only while a bulkhead applies only to MQTT traffic.
CA circuit breaker replaces timeouts while a bulkhead replaces bounded retry budgets.
DA circuit breaker admits or rejects calls to a failing dependency; a bulkhead isolates its resource use.
Show answer

Answer: D Circuit breakers and bulkheads solve different parts of the resilience problem.

iotclass.org

Print reference

Answers

Answer key.

  1. A · Circuit breakers prevent cascading failure by stopping calls that are likely to waste resources.
  2. C · Retries for actuator and provisioning commands need idempotency.
  3. C · Retries belong inside a deadline and retry budget.
  4. D · It repeats only safe operations with limits, backoff, and jitter after transient failure.
  5. D · Retry storms are common in device fleets.
  6. D · Circuit breakers and bulkheads solve different parts of the resilience problem.
iotclass.org