wasAsked.

How would you design an ASP.NET Core API for a high-traffic product catalog while keeping response times predictable?

Zoho · Full Stack Developer · 3-4-years · technical

Published

Year not specified · .NET, ASP.NET Core, System Design

Community answers

Posted by wasAsked editorial collection

Predictable latency comes from keeping the hot path cheap and isolating expensive work. Caching in layers - CDN or reverse-proxy caching for anonymous catalog pages and images. - HTTP caching headers (Cache-Control, ETag) so clients and proxies reuse responses; return 304 for unchanged data. - Output caching in ASP.NET Core for common listing pages, plus Redis or HybridCache for product details, with invalidation on product updates. Efficient data access - Read-optimised models: denormalised product summaries, or a search index (Elasticsearch, Azure AI Search) for filtering, facets and full-text search instead of complex SQL. - AsNoTracking and projections returning only needed fields. - Keyset pagination and strict page-size limits. - Proper indexes, and read replicas to keep reads away from writes. Async and resource limits - Async I/O everywhere so threads are not blocked; no sync-over-async. - Timeouts and cancellation on every downstream call; circuit breakers for dependencies like pricing or inventory services. - Rate limiting per client to protect against scrapers and spikes. Keep work off the request path - Price recalculation, image processing and search re-indexing happen in background workers fed by queues or change events. - Precompute "top sellers" and recommendations. Payload and protocol - Response compression (Brotli or gzip), small DTOs, and HTTP/2 or HTTP/3. - Avoid large nested responses; let clients request details separately. Scalability - Stateless API instances behind a load balancer with autoscaling. - Load test (k6, Azure Load Testing) with realistic traffic, including cache-cold scenarios. Measure what "predictable" means - Track p95 and p99 latency, not averages; set SLOs and alerts. - Use distributed tracing to find slow dependencies. - Watch for GC pauses and thread-pool starvation with dotnet-counters.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics