Distributed Systems Interview Questions for 5 Years Experience

Distributed Systems Interview Questions for 5 Years Experience Work through these 12 questions out loud. Open any question for the full model answer, the trap to avoid, and the follow-up a panel usually asks.

  1. Explain the transactional outbox pattern.

    OrderService @Transactional saves Order and OutboxEvent(type=ORDER_CREATED, payload=json). OutboxProcessor @Scheduled polls FOR UPDATE SKIP LOCKED, sends to Kafka, updates...

    Full answer

  2. Database sharding strategies for high-scale Java services?

    Shard by tenant_id mod 32 — RoutingDataSource lookup. User-scoped queries single shard. Global admin reports from CQRS read replica or Elasticsearch. Plan shard key early —...

    Full answer

  3. Kafka consumer groups, offsets, and delivery semantics?

    @KafkaListener with AckMode.MANUAL — ack after DB save. Consumer group order-service scales to partition count max. Idempotency key in message header dedup table. Monitor...

    Full answer

  4. A database connection pool is getting exhausted. How do you identify and solve it?

    Enable `spring.datasource.hikari.leak-detection-threshold`. Watch `hikaricp.connections.active` and threads blocked waiting. Fix leaks with try-with-resources; avoid long...

    Full answer

  5. What are idempotency keys and how implement them in REST APIs?

    Client sends Idempotency-Key: uuid on POST /payments. Server Redis SETNX key, process, store response JSON. Retry with same key returns 201 + original body without double...

    Full answer

  6. When accept eventual consistency and how communicate it to clients?

    Checkout returns 202 Accepted with orderId — poll or webhook when confirmed. Inventory display may lag seconds — show "approximate stock." Payment ledger uses strong...

    Full answer

  7. How do you implement rate limiting for APIs?

    Apply at API Gateway; in-app use Redis-backed limiter for cluster-wide counts. ```java @RateLimiter(name = "apiLimiter") @GetMapping("/users") public List<User> users() {...

    Full answer

  8. What is circuit breaker pattern?

    When payment service errors exceed 50% in 10s window, breaker opens — return fallback immediately for 30s. Half-open lets one request through to test recovery. Pair with...

    Full answer

  9. Explain CAP theorem in the context of microservices.

    When a network split isolates nodes, you cannot have both perfect consistency and every node answering. Example: order service during partition — either reject writes (CP) or...

    Full answer

  10. How would you design a rate-limited REST API?

    API gateway or filter applies token bucket per API key — Redis stores tokens with TTL. Exceeding limit returns 429 + Retry-After. Different tiers per plan. Log rejections for...

    Full answer

  11. Explain microservices vs monolith trade-offs.

    Start monolith until team or scale pain justifies split. Microservices enable independent deploy and tech diversity but add network failures, observability burden, and data...

    Full answer

  12. Saga pattern — choreography vs orchestration?

    Order saga: reserve inventory → charge payment → ship. Failure at payment triggers release inventory compensation. Orchestration clearer for complex flows with visibility....

    Full answer

Distributed Systems Interview Questions and Answers · Top 50 Distributed Systems Interview Questions and Answers (2026 Edition) · Top 40 Distributed Systems Interview Questions | Must-Prepare before interview. · Distributed Systems Interview Questions Every Fresher Must Know

All interview question lists · Interview guides · Home · Support the platform