Cracking the System Design Interview: Tips and Must-Know Questions

Cracking the System Design Interview: Tips and Must-Know Questions 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. 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

  2. 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

  3. 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

  4. What is an ExecutorService and why use it?

    Instead of new Thread per task, submit Runnable to fixed pool sized to CPU/IO profile. Handle Future results and exceptions. On shutdown hook call shutdown() and...

    Full answer

  5. What are virtual threads in Java 21 and when should you use them?

    Virtual threads excel when code blocks on IO — HTTP clients, JDBC, file reads — allowing one platform thread to serve thousands of concurrent requests. For CPU-heavy parallel...

    Full answer

  6. How do CompletableFuture and virtual threads compare for concurrency?

    Use virtual threads when business logic is naturally blocking — call DB, call HTTP, return. Use CompletableFuture when composing multiple independent async results with...

    Full answer

  7. What are weak references and WeakHashMap use cases?

    Attach metadata to objects without extending their lifetime — canonical mapping while object lives. When key GCs, entry drops. Do not rely on timing. For API response caching...

    Full answer

  8. What is the difference between ArrayList and LinkedList?

    ArrayList: dynamic array, great for get(i) and iteration, amortized append. LinkedList: node chain, costly random access, only wins for frequent insert/remove in middle 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. What is Hibernate second-level cache and when enable it?

    Enable for ProductCategory, Currency — READ_ONLY, rarely changed. spring.jpa.properties.hibernate.cache.use_second_level_cache=true with Caffeine region factory. Avoid on...

    Full answer

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

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