Katkat

Design aggregator for multiple downstream services

Walmart LabsSoftware Engineer · Onsite

Last updated

This question assesses the ability to design an API Gateway or Aggregator service that coordinates requests to multiple downstream microservices while managing latency, partial failures, and data aggregation.

Problem Statement

Design an Aggregator Service for an e-commerce platform that displays a unified "Product Detail Page." When a user requests a product, the Aggregator must fetch data from three distinct downstream services concurrently:

  1. Product Catalog Service: Returns basic metadata (name, description, category).
  2. Inventory Service: Returns stock status and quantity.
  3. Pricing Service: Returns current price, discounts, and currency.

Functional Requirements

  • The Aggregator must consolidate the data from all three services into a single JSON response.
  • The system must be able to handle 5,000 requests per second (RPS).
  • Latency should be minimized; the total response time should be governed by the slowest downstream service rather than the sum of all response times.

Non-Functional Requirements

  • Resilience: If the Inventory Service is slow or down, the page should still load with a "Stock information unavailable" message rather than failing entirely.
  • Scalability: The service must scale horizontally to handle traffic spikes.
  • Observability: Provide a high-level approach for tracking request success rates and latency across downstream dependencies.

Deliverables

  1. High-level system architecture diagram (described in text).
  2. API design for the Aggregator endpoint.
  3. Strategy for handling partial failures and timeouts.
  4. Discussion on performance optimizations (e.g., caching, connection pooling).

Hints

Hint 1

Consider using an asynchronous I/O model (like Futures or Promises) to perform the downstream service calls in parallel rather than sequentially.

Hint 2

Look into the Circuit Breaker pattern to prevent cascading failures when one downstream service experiences high latency or downtime.

Hint 3

Think about where caching might fit in—would you cache at the Aggregator level or rely on downstream services to handle their own cache?

Follow-up questions

  • How would you change your design if the Pricing Service requires a token that must be fetched from an Auth service first?
  • If the Product Catalog data changes infrequently, how would you implement a multi-layer caching strategy to reduce load on the Catalog service?
  • How would you perform distributed tracing to identify which downstream service is causing a bottleneck in a specific request flow?