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 choose between a SQL and a NoSQL database?

    Choose SQL when data is relational, you need joins, transactions and flexible queries, and the schema is fairly stable. Choose NoSQL when you need a flexible schema, very high scale for simple access patterns known in advance, or a data model like documents, key-value or graphs. Many systems use both.

    BeginnerIn-depth4 min read
  2. What does a load balancer do, and what is the difference between L4 and L7 load balancing?

    A load balancer sits in front of a group of servers and spreads incoming requests across the healthy ones, so no single server is overloaded and failures are hidden from users. An L4 balancer routes by IP address and port without reading the request. An L7 balancer reads HTTP details such as path, host and headers and can route on them.

    BeginnerIn-depth4 min read
  3. What is caching and what caching strategies should you know?

    A cache keeps a copy of frequently used data in faster storage, like memory, so repeated reads are quick. Know cache-aside, write-through and write-back, eviction policies like LRU, TTLs, and the hard part, keeping the cache consistent with the database.

    BeginnerIn-depth3 min read
  4. What is the difference between horizontal and vertical scaling?

    Vertical scaling (scaling up) makes one machine bigger with more CPU, RAM or faster disks. Horizontal scaling (scaling out) adds more machines and spreads the load across them. Vertical is simpler but has a hard ceiling and a single point of failure; horizontal scales further and survives failures but needs stateless services and a load balancer.

    BeginnerIn-depth4 min read
  5. How do health checks work in a load balancer?

    The load balancer probes each server regularly, for example an HTTP request to /health. After several failures it stops sending traffic to that server, and after several successes it adds it back.

    BeginnerQuick answer1 min read
  6. How do you focus an input automatically when a component mounts?

    Attach a ref to the input with ref={inputRef}, then call inputRef.current.focus() inside a useEffect with an empty dependency array. The ref is filled only after the element is in the DOM.

    BeginnerQuick answer1 min read
  7. How does a CDN work and what does it improve?

    A CDN keeps copies of your content on servers near users around the world. A user is routed to the closest edge, which serves cached content quickly and only contacts your origin server on a miss.

    BeginnerQuick answer1 min read
  8. How does leader-follower database replication work?

    All writes go to one leader, which streams its changes to follower replicas. Followers serve reads, which spreads read load and gives a standby copy if the leader fails, but they may lag behind.

    BeginnerQuick answer1 min read
  9. How does the cache-aside pattern work?

    The application checks the cache first. On a miss it reads the database, stores the result in the cache and returns it. On writes it updates the database and removes or updates the cache entry.

    BeginnerQuick answer1 min read
  10. Should you add read replicas or shard when the database is slow?

    Add read replicas when reads dominate, since they scale reads cheaply. Shard when writes or data size exceed one machine. Check indexes, queries and caching before either.

    BeginnerQuick answer1 min read
  11. What are sticky sessions and why do many teams avoid them?

    Sticky sessions make the load balancer send a user to the same server every time, usually via a cookie. They avoid shared session storage but cause uneven load and lose the session if that server dies.

    BeginnerQuick answer1 min read
  12. What are the common load balancing algorithms?

    Round robin hands requests out in turn, weighted round robin favours stronger servers, least connections picks the least busy server, and IP hash sends the same client to the same server.

    BeginnerQuick answer1 min read
  13. What are the rules of hooks, and why do they exist?

    Call hooks only at the top level of a component or custom hook, never inside loops, conditions or nested functions, and only from React functions. React tracks hooks by call order, so the order must be the same every render.

    BeginnerQuick answer1 min read
  14. What does '99.9% availability' mean, and how much downtime is that?

    99.9% availability, called three nines, allows about 8.76 hours of downtime a year, roughly 43 minutes a month. Each extra nine cuts the allowed downtime by ten times and costs much more to achieve.

    BeginnerQuick answer1 min read
  15. What does an API gateway do in a microservice system?

    An API gateway is the single entry point for clients. It routes requests to the right service and handles shared concerns such as authentication, rate limiting, TLS and logging, so each service does not repeat them.

    BeginnerQuick answer1 min read
  16. What does the dependency array do in useEffect?

    It tells React when to re-run the effect. No array means after every render, an empty array means once after mount, and a list of values means after renders where one of them changed, compared with Object.is.

    BeginnerQuick answer1 min read
  17. What does useRef return, and does changing ref.current cause a re-render?

    It returns a mutable object { current } that stays the same across renders. Changing ref.current does not trigger a re-render, so refs suit values React does not need to display, such as timer IDs or DOM nodes.

    BeginnerQuick answer1 min read
  18. What is a dead letter queue and when do you use one?

    A dead letter queue holds messages that failed processing after the allowed retries. It stops one bad message from blocking the queue forever and keeps the message for inspection and later reprocessing.

    BeginnerQuick answer1 min read
  19. What is a single point of failure and how do you remove it?

    A single point of failure is one component whose failure takes the whole system down. You remove it with redundancy: run several copies, add failover, and spread them across machines and zones.

    BeginnerQuick answer1 min read
  20. What is the difference between a message queue and publish-subscribe?

    In a queue each message is processed by exactly one consumer from a group, which shares the work. In pub-sub each message is delivered to every subscriber, so many services can react to the same event.

    BeginnerQuick answer1 min read
  21. What is the difference between a reverse proxy and a forward proxy?

    A forward proxy sits in front of clients and makes requests on their behalf, hiding the client. A reverse proxy sits in front of servers and receives requests for them, hiding the servers.

    BeginnerQuick answer1 min read
  22. What is the difference between availability and reliability?

    Availability is whether the system is up and responding when asked. Reliability is whether it keeps giving correct results over time without failing. A system can be available yet wrong, so it is available but not reliable.

    BeginnerQuick answer1 min read
  23. What is the difference between latency and throughput?

    Latency is how long one request takes; throughput is how many requests the system finishes per unit of time. You can improve one without the other, and pushing throughput too hard often raises latency.

    BeginnerQuick answer1 min read
  24. What is the difference between LRU and LFU cache eviction?

    LRU evicts the item not used for the longest time. LFU evicts the item used the fewest times. LRU favours recency and is the common default; LFU favours long-term popularity but is slower to adapt.

    BeginnerQuick answer1 min read
  25. What is the difference between offset and cursor pagination?

    Offset pagination uses page number and size (LIMIT 20 OFFSET 40), which is simple but slow on deep pages and shifts when rows change. Cursor pagination continues after the last item seen, so it stays fast and stable.

    BeginnerQuick answer1 min read
  26. What is the difference between REST and GraphQL?

    REST exposes many fixed endpoints that each return a set shape of data. GraphQL exposes one endpoint where the client asks for exactly the fields it needs, which avoids over-fetching but makes caching and rate limiting harder.

    BeginnerQuick answer1 min read
  27. What is the difference between sharding and partitioning?

    Partitioning splits a big table into smaller parts, often inside one database. Sharding is partitioning where the parts live on different servers, so both data and load are spread across machines.

    BeginnerQuick answer1 min read
  28. What is the difference between SLI, SLO and SLA?

    An SLI is a measured number like request success rate. An SLO is the internal target for that number, such as 99.9%. An SLA is the contract with customers that promises a level and usually names a penalty if missed.

    BeginnerQuick answer1 min read
  29. What is the difference between strong and eventual consistency?

    Strong consistency means every read sees the latest completed write. Eventual consistency means replicas may briefly return old data but will all converge to the same value if no new writes arrive.

    BeginnerQuick answer1 min read
  30. When does the cleanup function returned from useEffect run?

    React runs it before the effect runs again and when the component unmounts. Use it to undo what the effect set up: clear timers, remove listeners, close connections or cancel requests.

    BeginnerQuick answer1 min read