System Design Junior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

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

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

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

  4. 4. What does the REST principle "resources + HTTP methods" mean?

    Correct answer: The URL names a resource; the method names an action

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

  5. 5. How does GET differ from POST?

    Correct answer: GET reads data and mustn't change it, POST sends data to be changed

    GET is a safe and idempotent method: it can be cached, retried and prefetched. Parameters are visible in the URL and logs, so secrets must not be sent via GET. POST creates or changes data, and the browser asks before resubmitting a form.

  6. 6. Which HTTP method is NOT idempotent?

    Correct answer: POST

    Idempotency: repeating the same request has the same effect on the server. PUT replaces a resource entirely, DELETE removes it - repeating changes nothing. Two "create order" POSTs create two orders. That's why retrying POST on failure is dangerous without an idempotency key.

  7. 7. What do the HTTP status code classes mean?

    Correct answer: 2xx - success, 3xx - redirect, 4xx - client error, 5xx - server error

    Examples: 200 OK, 201 Created, 204 No Content; 301/302 redirects, 304 Not Modified; 400 Bad Request, 401, 403, 404, 409 Conflict, 422, 429; 500, 502, 503, 504. The class also drives client logic: 4xx are usually not retried, while 5xx and network errors can be.

  8. 8. How do 401 and 403 responses differ?

    Correct answer: 401 - not authenticated, 403 - authenticated but lacking permission

    On 401, the client usually prompts the user to sign in or refreshes the token. On 403, signing in again won't help - show "access denied". 404 means the resource wasn't found (sometimes it's returned instead of 403 to avoid revealing that the resource exists).

  9. 9. How does authentication differ from authorization?

    Correct answer: Authentication is who you are, authorization is what you're allowed to do

    First the system verifies identity (password, OAuth, passkey), then permissions for a specific action (role, ownership of the resource). Permission checks are mandatory on the server: a hidden button in the UI protects nothing.

  10. 10. What does it mean that HTTP is a stateless protocol?

    Correct answer: Each request is independent; "memory" of the user is passed via a cookie or token

    The server doesn't remember previous requests by itself, so the session is sent with every request: a cookie with a session ID or a token in a header. Stateless servers are easy to scale - any instance can handle any request.

  11. 11. What is a CDN for?

    Correct answer: Serving content from servers geographically close to the user

    A CDN caches static assets (JS, CSS, images, video) and even HTML at points of presence worldwide: lower latency, less load on the origin server, protection against traffic spikes. For dynamic content, a CDN can proxy and cache by rules.

  12. 12. What does the Cache-Control: max-age=3600 header specify?

    Correct answer: The cached response stays usable for an hour

    While the response is "fresh", the browser doesn't hit the network. After it expires, the browser can revalidate with a conditional request (ETag/Last-Modified) and get a 304. no-store forbids caching, and no-cache requires revalidation before every use.

  13. 13. How does latency differ from bandwidth?

    Correct answer: Latency is the time to a response, bandwidth is the data volume per unit of time

    Even on a wide channel, each extra request costs a round trip to the server and back (RTT). Mobile networks have high latency, so fewer requests, CDNs, prefetching and HTTP/2 matter. For large files, bandwidth matters more.

  14. 14. How does an SPA differ from an MPA?

    Correct answer: An SPA switches pages on the client via JS, an MPA loads new HTML from the server

    An SPA gives smooth transitions and rich interactivity but needs more JS and attention to SEO and first load. An MPA is simpler and faster to start. Modern frameworks (Next.js) combine server rendering and client navigation.

  15. 15. Why does server-side rendering (SSR) often improve the first load?

    Correct answer: The user gets ready HTML right away, without waiting for JS to load and run

    With CSR, the browser first gets almost empty HTML and waits for the bundle. With SSR, content is visible immediately, which improves LCP and SEO, but hydration still needs JS for interactivity. The cost is server load and response time.

  16. 16. Why does an API return a list page by page (pagination)?

    Correct answer: So that thousands of records aren't transferred and rendered at once

    Large responses are slow to transfer and burden the database and browser memory. Pagination can be offset-based (?page=3&limit=20) or cursor-based (?after=abc). In the UI: page numbers, "Load more" or infinite scroll.

  17. 17. Why use debounce in search-as-you-type?

    Correct answer: To send a request only after a pause in typing

    Without debounce, the word "sneakers" produces 8 requests. A 200–300 ms delay reduces server load. Additionally, stale requests are cancelled (AbortController) so an old response doesn't overwrite a new one, and results are cached.

  18. 18. Which UI states should you plan for a screen with a list of data?

    Correct answer: Loading, empty list, error and successful result

    An empty state suggests what to do next, an error state offers a "Retry" button, and skeletons reduce the feeling of waiting. In a system design interview, such details demonstrate maturity.

  19. 19. How do functional requirements differ from non-functional ones?

    Correct answer: Functional - what the system does, non-functional - how well it does it

    Functional: "the user can add an item to the cart". Non-functional: performance, accessibility, security, reliability, scalability, offline support. System design interviews start by clarifying both.

  20. 20. How does vertical scaling differ from horizontal scaling?

    Correct answer: Vertical - a more powerful server, horizontal - more servers

    Vertical scaling (more CPU/RAM) is simple but has a ceiling and a single point of failure. Horizontal scaling needs a load balancer and stateless servers, but it's nearly unlimited and improves fault tolerance.

  21. 21. What does a load balancer do?

    Correct answer: Distributes requests among several servers and removes unhealthy ones

    Algorithms: round robin, least connections, IP hash. Health checks exclude failed instances. A load balancer is the foundation of horizontal scaling and fault tolerance.

  22. 22. In general, how do relational (SQL) databases differ from NoSQL?

    Correct answer: SQL has schemas and relations; NoSQL is more flexible

    Relational DBs (PostgreSQL) provide transactions, JOINs and a strict schema. NoSQL - document (MongoDB), key-value (Redis), columnar, graph - scale horizontally more easily or fit a specific access pattern better. The choice depends on the data and queries.

  23. 23. What is polling?

    Correct answer: The client periodically asks the server whether there's new data

    The simplest way to get updates: a request every N seconds. Downsides: up to N seconds of delay and empty requests. Alternatives: long polling, SSE, WebSocket. For infrequent updates, polling is often enough.

  24. 24. When should you choose WebSocket?

    Correct answer: When you need frequent two-way exchange in real time

    WebSocket keeps a persistent connection, and both sides can send messages at any time. The cost is persistent connections on the server, reconnections and scaling. For a server-only stream, SSE is simpler.

  25. 25. What should you do with images to make the page load faster?

    Correct answer: Serve modern formats at the right size and lazy-load those below the fold

    AVIF/WebP, srcset for screen size, loading="lazy" for off-screen images, dimensions to prevent CLS, a CDN with optimization. Base64 inflates HTML by a third and isn't cached separately - it's justified only for tiny icons.

  26. 26. Why split the JS bundle into parts (code splitting)?

    Correct answer: So the user loads only the code for the needed page or feature

    One huge bundle slows down the first load. Splitting by routes and heavy components (import(), React.lazy) reduces the initial size. Frameworks like Next.js split by routes automatically.

  27. 27. What do minification and compression (gzip, brotli) give you?

    Correct answer: They reduce the size of transferred files and speed up loading

    Minification removes whitespace and shortens names, and HTTP-level compression shrinks text resources several times more (brotli is usually more efficient than gzip). It barely affects execution speed - that depends on the code's size and complexity.

  28. 28. What are dev, staging and production environments for?

    Correct answer: Development, testing on a copy of production, and serving real users

    Staging mirrors production's configuration to catch problems before release. Configuration (API URLs, keys) is passed via environment variables rather than stored in code - a 12-factor app principle.

  29. 29. What is CI/CD?

    Correct answer: Automated checks and delivery of every change

    Continuous Integration: every push runs the linter, tests and build. Continuous Delivery/Deployment: changes that pass the checks are rolled out automatically (to staging or production). This speeds up releases and reduces risk.

  30. 30. Why does the frontend need error monitoring (Sentry and the like)?

    Correct answer: To learn about real users' errors along with stack traces

    Users rarely report errors. Monitoring collects exceptions, unhandled promise rejections, the browser and the actions leading up to the failure, and source maps turn a minified stack into a readable one.

  31. 31. What does a 429 Too Many Requests response mean?

    Correct answer: The client exceeded the request limit and should wait

    Rate limiting protects a service from abuse and overload. The response may include Retry-After. The client should retry later, preferably with exponential backoff, not immediately.

  32. 32. Where should form data be validated?

    Correct answer: On the client for convenience and on the server for security

    Client-side validation gives instant feedback but is easily bypassed with a direct request. The server must check everything. A shared schema (e.g. Zod) can be reused on both sides.

  33. 33. Why version an API (/api/v1/...)?

    Correct answer: To change the contract without breaking clients that already work

    Mobile apps and old browser tabs keep using the old contract for a long time. Breaking changes go into a new version, while non-breaking ones (new optional fields) are added to the existing one. The version can be passed in the URL or a header.

  34. 34. Why set a timeout on network requests?

    Correct answer: To avoid waiting forever and to show the user an error or retry

    fetch has no timeout by default: a "hung" request keeps the loading indicator spinning forever. Use AbortSignal.timeout(ms) and show a clear state with a retry button.

  35. 35. What is an optimistic UI update?

    Correct answer: Showing the result immediately, before the server responds, with rollback

    A like, checking off a task or sending a message feel instant. If the server returns an error, the state is rolled back and the user is notified. It suits actions with a high chance of success.

  36. 36. How do you avoid losing a draft of a long form if the tab is closed by accident?

    Correct answer: Periodically save the draft to localStorage or to the server

    Autosave (with debounce) to localStorage/IndexedDB or the server restores the data when the user returns. You can additionally warn via beforeunload, but you can't and shouldn't forbid closing. An in-memory variable disappears with the tab.

  37. 37. Why is accessibility (a11y) considered a non-functional requirement of a system?

    Correct answer: It describes how well everyone can use the product

    Accessibility affects audience reach, SEO, legal risks (accessibility laws in the EU and US) and usability for everyone. It's cheaper to build it in from the start: semantics, keyboard support, contrast, ARIA for complex widgets.

  38. 38. What should you take into account if the product will be in several languages?

    Correct answer: Dictionaries, locale formats, RTL and string lengths

    Strings aren't hardcoded but moved into dictionaries; dates, currencies and numbers are formatted with Intl; plural forms, writing direction and translation length are taken into account. The language is usually reflected in the URL for SEO.

  39. 39. What is a feature flag?

    Correct answer: A switch that turns a feature on without a new deploy - for some or all users

    Flags let you ship code switched off, enable a feature gradually, run A/B tests and quickly disable something broken. Old flags must be removed, or the code accumulates branches.

  40. 40. What is a single point of failure?

    Correct answer: A component whose failure brings down the whole system

    For example, a single database without replicas or a single server without a load balancer. It's eliminated through redundancy: multiple instances, replicas, different availability zones. On the frontend, the analogue is a whole page depending on one third-party script.

  41. 41. What does "99.9%" (three nines) availability mean?

    Correct answer: Allowed downtime is about 8.7 hours per year

    99.9% ≈ 43 minutes of downtime per month, 99.99% about 4 minutes. Each extra "nine" gets dramatically more expensive. SLOs (internal targets) and SLAs (commitments to customers) are stated in these terms, and an "error budget" helps balance release speed and reliability.

  42. 42. Why can't you trust data that comes from the client?

    Correct answer: The user can modify any request the client sends

    Via DevTools, curl or a proxy, anyone can send any values: a product price, someone else's ID, an admin role. The server must check permissions, validate input and recompute important values (an order total) itself.

  43. 43. How do you protect against XSS when displaying user content?

    Correct answer: Escape output, sanitize HTML and configure CSP

    Frameworks escape text by default; the dangerous parts are innerHTML, dangerouslySetInnerHTML and javascript: links. If HTML is needed (an editor), it's sanitized on the server and the client. CSP restricts script sources - a second line of defense.

  44. 44. What is "logging" in the context of operating a system?

    Correct answer: Recording events and errors to investigate problems

    Logs, together with metrics and traces, make up observability. It's important to log in a structured way (JSON), with a request ID and without personal data or secrets.

  45. 45. Why is a static site (SSG) good for a blog or documentation?

    Correct answer: HTML is built in advance and served from a CDN - fast, cheap and reliable

    The content changes rarely and is the same for everyone, so it pays to prerender it. Updates happen via a rebuild or ISR. Personal data needs dynamic rendering or client-side loading.

  46. 46. Why is a cache like Redis in front of the database useful under high load?

    Correct answer: Frequent requests are answered from memory, offloading the database

    Popular data (profiles, a catalog) is read from memory in fractions of a millisecond. The main difficulty is invalidation: when and how to update the cache after the data changes. Redis complements the main DB rather than replacing it.

  47. 47. What is database replication?

    Correct answer: Copies of data kept on several servers

    A typical setup: one primary server for writes and replicas for reads. If the primary fails, a replica can be promoted. Caveat: replication lag - just-written data may not have appeared on the replica yet.

  48. 48. What is an ETag, and why is it needed?

    Correct answer: A resource version identifier used for 304 responses

    The browser sends If-None-Match: <etag>, and if the resource hasn't changed, the server responds 304 Not Modified without a body - saving traffic. It's the cache revalidation mechanism used together with Cache-Control.

  49. 49. How does long polling differ from regular polling?

    Correct answer: The server keeps the request open until new data appears

    The response arrives as soon as there's an event, after which the client opens a new request. Latency is lower than with regular polling, and it works through any proxy. Today SSE or WebSocket are used more often.

  50. 50. How do you send analytics when the page closes without losing the request?

    Correct answer: With navigator.sendBeacon or fetch with keepalive: true

    A regular request during page unload may be cancelled. sendBeacon queues a small POST in the browser and delivers it in the background. It's better to send on visibilitychange (when the page is hidden), since unload fires unreliably.

  51. 51. What is the main improvement of HTTP/2 over HTTP/1.1?

    Correct answer: Multiplexing many requests over one connection

    HTTP/1.1 effectively handles one request at a time per connection. HTTP/3 goes further by running over QUIC (UDP) to avoid TCP head-of-line blocking.

  52. 52. What does a TLS certificate prove to the browser?

    Correct answer: That the server really owns the domain

    Encryption without authentication would allow man-in-the-middle attacks. Certificates expire and must be renewed (often automatically).

  53. 53. What is CORS?

    Correct answer: A way for servers to allow cross-origin reads

    Without CORS headers, the same-origin policy blocks reading cross-origin responses in the browser. Server-to-server calls aren't affected.

  54. 54. What does the browser do with cookies that localStorage doesn't do?

    Correct answer: Sends cookies automatically with matching requests

    Automatic sending is convenient for sessions but enables CSRF, so cookies need flags like SameSite, HttpOnly and Secure.

  55. 55. What does a 304 Not Modified response mean?

    Correct answer: The cached copy is still valid; no body is sent

    It's the result of a conditional request with If-None-Match (ETag) or If-Modified-Since, saving bandwidth.

  56. 56. How do 502, 503 and 504 differ?

    Correct answer: Bad gateway, unavailable service, gateway timeout

    These codes help locate the problem: the proxy, the app servers or a slow dependency. 503 often comes with Retry-After.

  57. 57. What does throughput (requests per second) measure compared to latency?

    Correct answer: How much work the system handles per unit of time

    A system can have high throughput but poor latency (e.g. batching), so both are tracked.

  58. 58. What is a cache hit ratio?

    Correct answer: The share of requests served from the cache

    A higher ratio means less load on the origin and faster responses. Cache keys that vary too much (e.g. by cookie) lower it.

  59. 59. What does a database index do?

    Correct answer: Speeds up searching by a column

    Without an index, filtering scans the whole table. Index columns used in WHERE, JOIN and ORDER BY of frequent queries.

  60. 60. Why must secrets like a database password never be put in frontend code?

    Correct answer: Anyone can read code in the browser

    Frontend env variables (NEXT_PUBLIC_, VITE_) are public. Call protected APIs through your backend.

  61. 61. What is a health check endpoint for?

    Correct answer: Checking that an instance is alive and ready

    Unhealthy instances are taken out of rotation automatically. A good check also verifies critical dependencies cheaply.

  62. 62. Why should every deployment be easy to roll back?

    Correct answer: A quick return to the old version limits damage

    Immutable builds and versioned artifacts make rollback a quick switch. Database migrations must be compatible with the previous version.

  63. 63. When is classic pagination better than infinite scroll?

    Correct answer: When users need to reach specific items

    Infinite scroll suits browsing feeds. Pagination gives stable URLs and a sense of progress; "Load more" is a middle ground.

  64. 64. Why are skeleton screens often preferred to a full-page spinner?

    Correct answer: They show the page structure immediately

    Match the skeleton to the real layout to avoid layout shift. For very short waits, showing nothing avoids flicker.

  65. 65. What is progressive enhancement?

    Correct answer: A working baseline first, extras on top

    If JS fails or loads slowly, users can still read and submit forms. Server Actions with <form action> follow this idea.

  66. 66. Why should you test the app on a throttled slow network?

    Correct answer: Fast office Wi-Fi hides loading problems

    DevTools network and CPU throttling reveal missing loading states, large bundles and slow LCP.

  67. 67. What does font-display: swap do for web fonts?

    Correct answer: Shows a fallback font, then swaps it

    Invisible text hurts perceived speed. Matching fallback metrics (size-adjust) reduces the layout shift on swap.

  68. 68. What is the critical rendering path?

    Correct answer: The steps from HTML, CSS and JS to first pixels

    Render-blocking CSS and scripts in <head> delay first paint; inlining critical CSS and deferring scripts shorten the path.

  69. 69. What is a webhook?

    Correct answer: An HTTP request sent to your URL on an event

    It's the reverse of polling: the provider pushes events. The receiving endpoint must verify signatures and handle retries.

  70. 70. How does synchronous communication between services differ from asynchronous?

    Correct answer: With synchronous calls, the caller waits for a reply

    Async messaging decouples availability and absorbs load spikes but makes flows harder to trace.

  71. 71. What is OpenAPI (Swagger) used for?

    Correct answer: Describing a REST API for tools and people

    Generating TypeScript types from the spec keeps the frontend in sync with the backend contract.

  72. 72. Why aren't database replicas a replacement for backups?

    Correct answer: Replicas also copy deletions and corruption

    Replication protects against server failure; backups (and tested restores) protect against mistakes and attacks.

  73. 73. What does a reverse proxy (e.g. nginx) in front of app servers do?

    Correct answer: Forwards client requests to backend servers

    Clients see one address while the backend can scale and change behind it.

  74. 74. How should user passwords be stored?

    Correct answer: As slow, salted hashes like Argon2 or bcrypt

    Slow hashing makes brute-forcing leaked hashes expensive; unique salts stop precomputed table attacks.

  75. 75. What is mixed content?

    Correct answer: An HTTPS page loading resources over HTTP

    Serve all resources over HTTPS; the upgrade-insecure-requests CSP directive can help during migration.