Interview Q&A / System Design

INTERVIEW Q&A · 70 QUESTIONS

System Design interview questions

Caching, scaling, databases and classic design problems for beginners.

  1. How do you add more shards to a running system without a long outage?

    Avoid plain modulo hashing, which moves most keys when the shard count changes. Use consistent hashing or many small virtual shards mapped to servers, then move a few of them in the background while dual-checking routing.

    AdvancedQuick answer1 min read
  2. What is the difference between useEffect and useLayoutEffect?

    useEffect runs after the browser has painted. useLayoutEffect runs after DOM changes but before paint, and blocks painting. Use the layout version only to measure or adjust the DOM so users do not see a flicker.

    AdvancedQuick answer1 min read
  3. What is the PACELC theorem and how does it extend CAP?

    PACELC says: if there is a Partition, choose Availability or Consistency; Else, when running normally, choose between Latency and Consistency. It captures that consistency costs latency even when nothing is broken.

    AdvancedQuick answer1 min read
  4. What is the transactional outbox pattern and what problem does it solve?

    It solves the dual-write problem: updating a database and publishing an event can't be atomic. The outbox writes the event into a table in the same database transaction, and a separate process publishes it to the broker.

    AdvancedQuick answer1 min read