Interview conceptSoftware Engineering Fundamentals

API Aggregation And Partial Failure

Asked of: Software Engineer

Last updated

Architecture diagram showing an API aggregator fanning out bounded, deadline-aware requests to identity, payment, and address services, then fanning in partial results.

What's being tested

These prompts test whether you can design a fan-out/fan-in API aggregator that calls multiple downstream services, combines their responses, and remains useful when some dependencies fail. The interviewer is probing your judgment around API contracts, bounded concurrency, deadlines, retry safety, partial-response semantics, and observability—not merely whether you can issue three HTTP requests. DoorDash relies on this skill because customer-facing flows often depend on restaurant, delivery, payment, identity, and address services with different latency and availability profiles.

Core knowledge

  • Fan-out/fan-in orchestration sends independent downstream requests in parallel, then joins results before responding. Sequential calls produce approximately ∑iLi\sum_i L_i latency; parallel calls approach max⁡i(Li)\max_i(L_i) plus aggregation overhead, provided concurrency is bounded.

  • Dependency classification separates required data from optional enrichments. If consumer identity is required but payment methods and addresses are optional, a consumer failure may produce 5xx, while an address timeout can produce 200 with an explicit unavailable or omitted section.

  • Deadline propagation gives the entire request a fixed budget and derives child timeouts from remaining time. If the end-to-end budget is 800 ms, do not give every child an independent 800 ms timeout; otherwise queued work and response assembly can exceed the caller’s deadline.

  • Bounded concurrency uses a worker pool, semaphore, or structured-concurrency limit rather than creating unbounded tasks per request. This protects the aggregator and downstreams during traffic spikes; the right limit depends on connection pools, CPU, and downstream capacity.

  • HTTP status handling distinguishes transport failures, timeouts, malformed payloads, and application statuses such as 4xx or 5xx. A 404 may mean “no optional resource,” whereas 401, 403, schema-invalid 200, and dependency 503 need deliberately different semantics.

  • Retry policy applies only to transient failures and preferably idempotent operations. Use exponential backoff with jitter, for example dk=min⁡(dmax⁡,d02k)+U(0,j)d_k=\min(d_{\max},d_0 2^k)+U(0,j); cap attempts and ensure retries fit inside the remaining deadline.

  • Idempotency and duplicate work matter even for reads: retries can amplify load, and writes require an idempotency key or deduplication strategy. Avoid retrying every 5xx; distinguish connection resets and 503 from deterministic validation failures such as 400.

  • Partial-response contracts should be explicit and machine-readable. A response can include data, degraded or warnings, and per-section status such as available, unavailable, or not_authorized; never silently return an empty list that looks like valid data.

  • Circuit breakers and bulkheads prevent one unhealthy dependency from consuming all threads, sockets, or latency budget. A circuit breaker opens after an error-rate or timeout threshold, while bulkheads isolate dependency-specific pools and preserve capacity for healthy services.

  • Observability requires structured logs, distributed tracing, and metrics by dependency and outcome. Track success rate, timeout rate, retry count, breaker state, fan-out latency, aggregation latency, and p50/p95/p99; propagate a correlation or trace ID.

  • Load and failure testing should cover dependency latency, connection exhaustion, malformed JSON, partial outages, cancellation, and retry storms. Validate both the external SLO and internal resource behavior; a graceful 200 is not successful if worker queues or downstream traffic grow without bound.

Worked example

For “Aggregate Consumer, Payment, and Address APIs with Partial Failure,” I would first ask which data is mandatory, what response status and schema are required for each dependency failure, the expected QPS, and the end-to-end latency SLO. I would declare that consumer data is required, payment and address are optional, calls are read-only, and the aggregator has a fixed deadline such as 500 ms. I would organize the answer around contract semantics, parallel orchestration, timeout/retry policy, and observability/resource isolation. The implementation would start the three calls concurrently, apply a per-call timeout bounded by the remaining overall deadline, validate HTTP status and payload schema, and assemble available sections. A consumer timeout or invalid response would return a dependency-aware 5xx, while payment or address failure would return a degraded response with explicit section metadata. I would explicitly choose not to retry non-idempotent operations and would limit retries to one bounded attempt for transient failures, because retries can worsen a downstream outage. I would also mention cancellation: once the required consumer call fails or the client disconnects, unnecessary optional work should be cancelled where the runtime supports it. If I had more time, I would add contract tests, fault injection, circuit-breaker thresholds, and load-test results to validate the design.

A second angle

For “Build an API aggregator with concurrency and retries,” the central framing shifts from response semantics toward controlling retry amplification and latency under failure. I would clarify whether downstream calls are idempotent, whether the caller permits stale or partial data, and how much of the deadline remains after each attempt. A strong design uses parallel calls, a shared deadline, exponential backoff with jitter, and a strict retry budget rather than independently retrying every dependency. I would discuss how a retry storm can turn a partial outage into a system-wide outage, then add circuit breakers, bulkheads, and metrics for attempts per request. The key tradeoff is higher recovery from transient network errors versus extra load and worse tail latency.

Common pitfalls

Pitfall: Treating all downstream failures identically and returning 500 whenever one call fails. This loses useful optional data and ignores the business distinction between required and enrichment dependencies; define failure semantics per section.

Pitfall: Saying “call everything in parallel and retry on failure” without specifying deadlines, concurrency limits, retryable statuses, or cancellation. The interviewer wants an executable policy, including what happens when the caller has only 50 ms remaining.

Pitfall: Going deep into framework syntax while skipping the API contract and operational behavior. A code sketch is useful, but first explain response shape, dependency isolation, observability, and how the design behaves during a dependency outage.

Connections

An interviewer may pivot to circuit breakers, bulkheads, and backpressure, or ask how distributed tracing identifies the slowest dependency. They may also explore API versioning, schema validation, caching, request hedging, or graceful degradation under an SLO.

Further reading

Practice questions

Related concepts