IntermediateTECHNICAL
Walk me through how you would design and implement a new RESTful API endpoint that handles high read traffic. Cover data modeling, choice of HTTP methods and status codes, error handling, validation, and how you would make it observable in production.
Software Engineer
General

Sample Answer

I’d start by clarifying the access patterns. Let’s say it’s a product details endpoint doing 95% reads, 5% writes, with a target of p95 < 150ms at 2k RPS. I’d normalize core entities in the DB (Product, Price, Inventory) but create a read-optimized view or materialized projection that the GET /products/{id} endpoint hits. For responses, I’d use 200/404/400/500 as the main codes, plus 429 if we add rate limiting. Validation happens at the edge with a schema validator (e.g., Joi / class-validator) so bad requests never hit the DB, and I’d return structured error objects with stable error codes. For scale, I’d cache hot items at the API layer (Redis with a short TTL) and enable ETag or Last-Modified for client-side caching. For observability, I’d add structured logs with a request ID, metrics for latency, throughput, and error rate, and distributed tracing (OpenTelemetry) so we can see DB and cache spans in production.

Keywords

Start from access patterns and performance targetsRead-optimized data model plus caching strategyClear HTTP semantics, validation, and structured errorsObservability via metrics, logs, and tracing