The DevBlog.

Building Resilient Apps: A Practical Guide to Surviving Cloud Outages

Cloud outages happen. Learn the patterns that keep your app useful when dependencies fail: timeouts, retries, circuit breakers and fallbacks.

Published

Updated

Building Resilient Apps: A Practical Guide to Surviving Cloud Outages

No provider can promise perfect uptime. Microsoft’s near-24-hour Microsoft 365 disruption this month was a reminder that even the largest platforms suffer long incidents, and that the root causes are often a pile-up of small, ordinary problems rather than one dramatic failure. You cannot prevent your providers from failing. You can decide how your app behaves when they do.

Start with a simple mindset: assume dependencies will fail

Every call to another service, database or API is a place where things can be slow, wrong or absent. Resilient design means answering three questions for each dependency:

  1. What happens if it is slow?
  2. What happens if it is down?
  3. What happens if it returns bad data?

If the honest answer is “my whole app hangs,” you have found your first job.

Pattern 1: Timeouts everywhere

The most common cause of cascading failures is a call that waits forever. Set explicit timeouts on every network request, and make them shorter than your own users’ patience. A slow dependency that ties up all your worker threads can take down a healthy service.

async function fetchWithTimeout(url, ms = 3000) {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), ms);
try {
return await fetch(url, { signal: controller.signal });
} finally {
clearTimeout(timer);
}
}

Pattern 2: Retries with backoff and jitter

Retrying helps with brief glitches, but naive retries can make outages worse. If a thousand clients all retry every second, they hammer a service that is trying to recover. Use exponential backoff, which waits longer after each failure, plus random jitter so clients do not retry in lockstep. Also cap the number of attempts, and only retry operations that are safe to repeat.

async function withRetry(fn, { retries = 4, baseMs = 200, maxMs = 5000 } = {}) {
for (let attempt = 0; ; attempt++) {
try {
return await fn();
} catch (err) {
if (attempt >= retries) throw err;
const cap = Math.min(maxMs, baseMs * 2 ** attempt);
const delay = Math.random() * cap; // full jitter
await new Promise((r) => setTimeout(r, delay));
}
}
}

For writes such as payments or orders, add an idempotency key so a repeated request cannot create a duplicate.

Pattern 3: Circuit breakers

A circuit breaker watches calls to a dependency. When failures pass a threshold, it “opens” and fails fast for a period instead of sending more traffic. After a cooldown, it lets a few test requests through; if they succeed, it closes again. This protects the struggling dependency and your own resources, and it gives you a clear place to trigger a fallback.

Pattern 4: Graceful degradation

Decide in advance what “partially working” looks like. Some examples:

  • Search is down: show recent or popular items from a cache.
  • Email provider is down: queue messages and send them later, and tell the user it may take longer.
  • Recommendation service fails: show a default list instead of an error.
  • Auth provider is slow: allow already-signed-in sessions to continue while blocking new sign-ups.

Users forgive a limited experience far more easily than a blank screen. Write the fallback messages now, not during the incident.

Pattern 5: Queues and idempotent workers

If an action does not need an instant result, put it in a queue. Queues absorb bursts, let you retry safely, and keep your user-facing request fast while a dependency recovers. Make workers idempotent so that processing a message twice is harmless.

Pattern 6: Be careful with automation that removes capacity

One lesson from recent outage reports is that protective automation can amplify problems. Health checks that pull servers out of rotation, autoscalers that react to short spikes, and failover scripts that shift load can each make sense alone and still create a feedback loop together. Put limits on automated actions, such as never removing more than a set share of capacity at once without human approval. Test these mechanisms deliberately; failover code that has never run in anger is a hidden risk.

Pattern 7: Choose your redundancy honestly

Redundancy is not free, so match it to the risk:

  • Multiple availability zones protect against a single data-centre failure and are usually worth it.
  • Multi-region protects against regional outages but adds complexity, especially for data consistency.
  • Multi-cloud protects against a provider-wide failure but is hard to do well and can introduce its own failure modes.
  • A manual fallback is sometimes the cheapest option. A documented procedure for taking orders by phone or spreadsheet can save a business during a long outage.

Ask what an hour of downtime costs, then spend accordingly.

Pattern 8: Keep your control tools outside the blast radius

When a cloud console, identity provider or chat tool goes down, the tools you need to respond may go down with it. Keep break-glass credentials, runbooks and an on-call contact list in a place that does not depend on the affected provider. Host your status page on separate infrastructure, and have an out-of-band way to reach customers.

Observability: know before your users do

Resilience depends on detection. Track the golden signals: latency, traffic, errors and saturation. Define service level objectives (SLOs), such as “99.9% of requests succeed within one second,” and alert on how fast you are consuming your error budget. Add synthetic checks that exercise a full user journey every minute from outside your network.

Practise failure

Resilience that is not tested is a guess. Schedule regular game days where you deliberately break something in a safe environment: block a dependency, add latency, kill a node, or disable a region. Chaos engineering tools can automate this, but a simple, well-planned manual exercise teaches a lot. After each exercise, write down what surprised you and fix it.

Communicate during incidents

A good incident response has a clear owner, a single source of truth, and honest updates. Say what you know, what you do not, and when you will update next. Afterwards, publish a plain-language post-mortem that focuses on systems rather than blame. Customers remember how you handled the outage as much as the outage itself.

A starter checklist

  • Timeouts on every outbound call
  • Retries with exponential backoff and jitter, plus idempotency keys on writes
  • Circuit breakers on critical dependencies
  • Written fallback behaviour for each major dependency
  • Queues for work that can wait
  • Limits on automated capacity removal
  • Break-glass access and runbooks stored outside the main provider
  • Independent status page and customer contact route
  • SLOs, alerts and synthetic checks
  • A scheduled game day each quarter

You do not need to build all of this at once. Start with timeouts and one clear fallback for your most important dependency, and add the rest as your product grows.

Was this article helpful?

Comments

Comments are reviewed before they appear. Links are displayed as plain text and are not clickable.

Written by Methembe Nyoni

An innovative Information Technology student