System Design Interview Questions and Answers
Designing frontends and web systems: rendering, APIs, caching, auth, real-time, scalability, deployment.
225 questions for System Design interviews with answers and explanations - Junior, Middle and Senior levels. Sample questions, online quizzes and coding tasks.
- Caching
- API
- Auth
- Real-time
- Scalability
Questions by level
Junior
Core concepts and syntax · 50 questions
Middle
Practice, nuances and optimization · 50 questions
Senior
Architecture, internals, edge cases · 50 questions
Sample questions
A few questions from each level with the correct answer and an explanation.
System Design · Junior
- What happens when a user types a site's address and presses Enter?
Correct answer: DNS → connection (TCP/TLS) → HTTP request → response → page rendering
The browser resolves the IP via DNS (with caches at every level), establishes a connection and the TLS handshake, sends the request, receives HTML, parses it, loads CSS/JS/images, builds the DOM and CSSOM, and performs layout and paint. It's the classic opening question for a performance discussion.
- What is DNS for?
Correct answer: It translates domain names into server IP addresses
DNS is the internet's distributed "phone book". Responses are cached (browser, OS, ISP) for the duration of the TTL. Encryption is TLS's job, and copies of content near the user are the CDN's job.
- How does HTTPS differ from HTTP?
Correct answer: Traffic is encrypted and the server's authenticity is verified via TLS
TLS protects against eavesdropping and tampering, and the certificate confirms you're talking to the real server. Many modern browser APIs (Service Worker, geolocation, HTTP/2 in browsers) work only over HTTPS.
- What does the REST principle "resources + HTTP methods" mean?
Correct answer: The URL identifies a resource and the method an action:
GET /users/1,DELETE /users/1REST uses nouns in URLs and the semantics of HTTP methods: GET reads, POST creates, PUT/PATCH update, DELETE deletes. This makes the API predictable, and caches and proxies understand the meaning of requests.
System Design · Middle
- What is the right way to start answering a frontend system design question?
Correct answer: By clarifying requirements and constraints
A popular framework is RADIO: Requirements (functional and non-functional), Architecture (components and data flow), Data model (client state), Interface (API), Optimizations (performance, a11y, i18n, security). Without requirements it's easy to design the wrong system.
- Why is cursor pagination better than offset pagination for a feed?
Correct answer: No duplicates on inserts and fast on deep pages
With
offset, new posts shift the window and the user sees repeats;OFFSET 100000is expensive for the DB. A cursor ("after the record with id X") is stable and efficient on an index. The downside is you can't jump to page 57, so for tables with page numbersoffsetis sometimes more appropriate. - How would you design an infinite feed with thousands of posts?
Correct answer: Cursor loading via
IntersectionObserverplus list virtualizationA sentinel element near the end of the list triggers loading the next page. Virtualization keeps only visible items in the DOM. Also consider: restoring scroll position when navigating back, images with explicit dimensions, new posts at the top without the feed "jumping".
- What matters when designing autocomplete?
Correct answer: Debounce, cancelling stale requests, caching, keyboard support
Plus a minimum query length, handling response races, highlighting matches, a "nothing found" state, and the ARIA combobox pattern. For a small fixed dictionary, filtering on the client is fine (sometimes with a trie); for large ones, use server-side search.
System Design · Senior
- What does the CAP theorem state?
Correct answer: During a network partition you have to choose between consistency and availability
Consistency, Availability, Partition tolerance: network partitions are inevitable in a distributed system, and at that moment the system either rejects some requests (CP) or responds with possibly stale data (AP). In normal operation the trade-off is between consistency and latency (PACELC).
- A user updated their profile, refreshed the page and saw the old data. Which guarantee was violated?
Correct answer: Read-your-writes: the user must see their own changes
A typical cause is reading from a replica the change hasn't reached yet, or a stale cache. Solutions: read "own" data from the primary for a while after a write, update the client cache with the mutation response, use
updateTaginstead of SWR invalidation. - Why is choosing "creation date" as a sharding key dangerous?
Correct answer: All new records land in one shard - a hot partition
Sharding distributes data across nodes; the key must spread the load evenly and match the queries. A monotonic key concentrates writes in the last shard. A hash of the user id or a composite key is often used.
- Why use consistent hashing when adding cache nodes?
Correct answer: When the number of nodes changes, only a small share of keys move
With
hash(key) % N, changing N redistributes almost all keys and the cache misses en masse. A hash ring (with virtual nodes) moves only ~1/N of the keys. Used in distributed caches, CDNs and databases.
Combined quizzes with this topic
Questions from several topics at once - just like an interview for a specific role.
Coding tasks
Write your solution right in the browser, and tests check it instantly. Interview classics: debounce, throttle, deepClone, Promise.all, EventEmitter, an LRU cache and more.
Open tasks →