As asked
Design a Rust HTTP service that handles 50,000 requests per second for a read-heavy endpoint backed by Postgres. Cover the framework choice, connection pooling, caching, observability, and how you would handle hot spots.
Sample answer outline
Framework: axum on tokio for async handling. Connection pool: deadpool-postgres or sqlx PgPool sized to saturate Postgres without overloading it (typically 10 to 20 connections per Postgres core). Layer a Redis cache in front with read-through and a short TTL for hot rows. Observability: tracing + OpenTelemetry exporting to Jaeger or Datadog, Prometheus metrics via axum middleware. Hot spots: shard reads to read replicas, add a local in-process cache (moka) for the hottest keys to avoid Redis roundtrips.
Expect these follow-ups
- How would you handle cache invalidation when the underlying Postgres row changes?
- At what point does the Tokio thread pool stop scaling and what do you do then?