Hard or soft dependency?
Step 1 · The pattern
Two dependencies, one of each kind
Every checkout calls payments and recommendations. Without payments there is no order. Without recommendations the page shows no suggestions and the order still goes through. On a normal day both rarely fail.
- request
- a call failed
- answered without suggestions
- answered
In short
Hard or soft dependency?: how it works and how it breaks
Every service has dependencies it cannot work without and dependencies it can skip. The first kind is hard, or fail-closed: when it fails, the caller fails too. The second is soft, or fail-open: the caller falls back and answers anyway. Retry rules, alerts, failover plans and error ownership all depend on knowing which is which, and the list in the design document is usually out of date. Measure it from traffic instead. For each dependency, take the requests where its call failed and ask what share of them the caller failed as well. Close to all of them means hard; close to none means soft. The count has to cover every request. Sampled traces keep a tiny share of requests, and failures are rare inside that share, so they take hours or days to give an answer.
How this comes up in interviews
"How would you find out which of a service's dependencies it cannot work without?"
Then they ask
- Why not answer it from distributed traces?
- What would you record, and at which point in the request?
- What would you do with a dependency that is neither clearly hard nor clearly soft?
A strong answer covers
- Don't trust the design document: measure it from live traffic.
- For each dependency, take requests where its call failed and work out the share where the caller failed too.
- High share: hard (fail-closed). Low share: soft (fail-open). Keep an 'unknown' band between.
- Count every request at the service: sampled traces hold so few failures that answers take hours or days.
- Key counts by endpoint, and use the result for alerting, retries and failover tests.
Points to cover, not a script. Say them in your own words and tie them to a system you have worked on.
On one page: the track cheat sheet.
Sources: Uber Engineering: Large-scale automated dependency analysis across Uber's service mesh ↗ · Uber Engineering: How Uber protects against retry storms ↗ · OpenTelemetry: Sampling ↗ · Report a problem
Diagrams are our own simulations: the timings, rates and counts in them are illustrative, not measurements. Captions are original wording.