Skip to content
tezvyn:
Menu

Mitigating risk from an unproven external dependency?

Source: interviewMediumHow cards are made

Summary

Designing for dependency failure.

Key points

Timeouts and circuit breakers to fail fast, bulkheads to isolate resources, fallbacks or cached/degraded responses.

What's really being asked

Whether you treat every external dependency as something that will eventually be slow or down, and design the blast radius accordingly rather than trusting the happy path.

The full answer

Start with timeouts on connect and read so a hung dependency releases resources quickly instead of pinning threads or connections. Add a circuit breaker that trips open after a failure threshold, short-circuiting calls for a cooldown so you fail fast and let the dependency recover, then half-opens to probe. Apply the bulkhead pattern by isolating the dependency in its own thread pool or connection quota, so its saturation cannot starve unrelated requests. Define a fallback: serve a cached or stale value, a sensible default, or a degraded but functional experience, and make it explicit what the user sees. Where the feature allows, move the call off the synchronous request path entirely, queuing it or precomputing results. Retries with backoff help for transient blips but must be bounded.

The mistakes people make

Relying on retries alone, which amplifies load on a struggling dependency. No timeout, so slow calls accumulate and exhaust the thread pool. A circuit breaker with no fallback, which just turns slowness into hard errors with no graceful path. Ignoring resource isolation, letting one bad dependency take down the whole service.

What usually comes next

How do you tune the breaker thresholds. What does the degraded experience look like to users. How do timeouts interact with retries to avoid retry storms. How do you test these paths.

A concrete example

A new recommendations API powers the homepage rail. You set a 200ms timeout, wrap it in a circuit breaker that opens after a 50 percent error rate, and isolate it in a dedicated pool. When the API degrades, the breaker opens, calls fail in under a millisecond, and the page renders a cached default rail. Users see slightly stale recommendations instead of a broken or hanging homepage.

Interview question

A critical service calls a flaky third-party API synchronously with no timeout. During a slow spell at the dependency, why does the calling service itself often go down?

  • a.The third party returns malformed JSON that crashes parsing
  • b.DNS resolution for the dependency fails globally
  • c.The circuit breaker opens too aggressively
  • d.Hung calls accumulate and exhaust the caller's threads or connection poolCorrect
Why?

Without timeouts, slow calls hold threads and connections until the pool is exhausted, so the caller can no longer serve any requests. A circuit breaker is the cure here, not the cause, and there is none in this setup.

Just read this? Test yourself on what you have been reading.

Read the original → learn.microsoft.com

Put your scrolling time to good use

Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.

The iPhone app is on the way

We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.

Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.

Get it on Google PlayiPhone app coming soon

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles