Api Design hard
A user reports a slow request. It traverses 8 microservices. How do you identify which service caused the latency?
- A Implement Distributed Tracing (e.g., OpenTelemetry) to propagate a unique Trace ID across all service boundaries, allowing for a unified visualization of the request's execution path.
- B Aggregate and synchronize the high-resolution system logs from all involved microservices using a centralized timestamp-ordered index to manually correlate the entry and exit times.
- C Enable verbose network-level packet capture on every container's virtual interface to analyze the exact TCP transmission and acknowledgment delays between specific service instances.
- D Deploy a health-check circuit breaker that periodically pings every internal endpoint and flags any service that fails to respond within a predefined P99 latency threshold.
Answer: A. Implement Distributed Tracing (e.g., OpenTelemetry) to propagate a unique Trace ID across all service boundaries, allowing for a unified visualization of the request's execution path.
**Distributed Tracing** (e.g., OpenTelemetry, Jaeger) provides a request-scoped view across microservices. By propagating a `Trace Context` (Trace ID and Span ID) in headers, you can reconstruct the entire lifecycle of a request as a waterfall graph. This makes it trivial to identify which specific service or database call contributes to high latency.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- You're designing a REST API for a blog. Which endpoint best represents 'get all comments for post 123'?
- A client wants to update only the 'status' field of an order, leaving other fields unchanged. Which HTTP method is most appropriate?
- A client calls POST /users with valid data, and the user is created. What status code should the server return?
- A client retries a failed 'POST /payments' request due to network timeout. The server receives the request twice. Without idempotency handling, what can happen?
- An API returns 10,000 products. Returning all in one response is impractical. Which pagination approach is simple and stateless?
- Your API serves both mobile apps and third-party integrations. Which authentication method is most appropriate?