Gapfyre

System design interview questions

A system design interview is a conversation, but it is built from a small vocabulary: scaling up against scaling out, latency against throughput, caches and what happens when they miss, queues, CDNs and rate limits. If any of those is shaky, the conversation stalls on it.

Alongside the vocabulary are two back-of-the-envelope estimates, the usual running order of the interview itself, and seven short architectures with one thing wrong in each — the kind of flaw an interviewer is waiting for you to notice.

All 30 are the free Foundation level of the System Design topic in GapfyreSWE. Try each one before you open its answer.

  1. What is the key drawback of vertical scaling (scaling up) compared to horizontal scaling (scaling out)?

    1. It has a hard upper limit and remains a single point of failure
    2. It cannot be automated
    3. It requires rewriting the application as microservices
    4. It is always more expensive per unit of capacity than horizontal scaling
    Show the answer

    A. It has a hard upper limit and remains a single point of failure

    Vertical scaling adds more CPU, RAM, or disk to a single machine, which is simple but hits a hard physical ceiling and creates a single point of failure. Horizontal scaling adds more machines, which scales further and adds redundancy, at the cost of distributed-systems complexity (coordination, data partitioning).

  2. A load balancer using the "Least Connections" algorithm routes each new request to which server?

    1. The server with the fewest active connections
    2. The server geographically closest to the client
    3. The next server in a fixed rotation, regardless of load
    4. A random server chosen on each request
    Show the answer

    A. The server with the fewest active connections

    Least Connections sends traffic to whichever backend currently has the fewest active connections, which handles uneven request durations better than Round Robin (which just cycles through servers regardless of their current load).

  3. What is the difference between latency and throughput?

    1. Throughput measures error rate, latency measures uptime
    2. They are two names for the same metric
    3. Latency is time per request; throughput is requests handled per unit time
    4. Latency only applies to databases; throughput only applies to networks
    Show the answer

    C. Latency is time per request; throughput is requests handled per unit time

    Latency is the time to complete a single request (e.g. milliseconds per request); throughput is the number of requests a system can handle per unit time (e.g. requests per second). A system can have low latency but low throughput, or vice versa — optimising one does not automatically optimise the other.

  4. What does the "I" in ACID stand for, and what does it guarantee?

    1. Indexing — transactions automatically build indexes
    2. Idempotency — retrying a transaction has no additional effect
    3. Integrity — foreign keys are always enforced
    4. Isolation — transactions do not see each other's uncommitted state
    Show the answer

    D. Isolation — transactions do not see each other's uncommitted state

    Isolation guarantees that concurrently executing transactions do not see each other's intermediate, uncommitted state — the effect is as if transactions ran one after another, even though they may actually run concurrently for performance. This is what isolation levels (e.g. Read Committed, Serializable) tune.

  5. What does "high availability" mean for a system, and how is it typically achieved?

    1. Using the fastest possible single server
    2. Redundant components with automated failover
    3. Running all traffic through one heavily monitored node
    4. Disabling deployments to avoid downtime
    Show the answer

    B. Redundant components with automated failover

    High availability means the system remains operational for a very large percentage of the time (often expressed as "nines", e.g. 99.99%). It is achieved primarily through redundancy — multiple instances of each component, with automated failover — rather than by making any single component unbreakable.

  6. Why is redundancy important in system design?

    1. It reduces the total cost of the system
    2. It is only useful for reducing latency
    3. It replaces the need for monitoring
    4. It removes single points of failure
    Show the answer

    D. It removes single points of failure

    Redundancy means keeping extra, duplicate components (servers, network paths, power supplies, data copies) so that if one fails, another can take over immediately. Without redundancy, any single component is a single point of failure that can bring down the whole system.

  7. What does the principle of least privilege mean?

    1. Only the most senior engineers should have any system access
    2. Every service should have administrator access by default for convenience
    3. Permissions should never be reviewed once granted
    4. Only the minimum access needed for the function
    Show the answer

    D. Only the minimum access needed for the function

    Each user, service, or process should be granted only the minimum permissions necessary to perform its function, and nothing more. This limits the damage a compromised account or bug can cause, since it cannot access resources it was never granted.

  8. What is the difference between encryption "at rest" and encryption "in transit"?

    1. At rest protects stored data; in transit protects it moving
    2. In transit only applies to email; at rest only applies to backups
    3. At rest is always weaker than in transit
    4. They are the same thing implemented with different algorithms
    Show the answer

    A. At rest protects stored data; in transit protects it moving

    Encryption at rest protects data while it is stored (e.g. on disk or in a database), typically against unauthorised physical or storage-level access. Encryption in transit (e.g. via TLS) protects data while it moves across a network, against eavesdropping or tampering in transit. A secure system typically needs both.

  9. Which mitigation most directly addresses SQL injection vulnerabilities?

    1. Increasing the database connection pool size
    2. Disabling HTTPS to simplify request handling
    3. Parameterised queries instead of string concatenation
    4. Storing passwords in plaintext for easier debugging
    Show the answer

    C. Parameterised queries instead of string concatenation

    Parameterised queries (prepared statements) separate SQL code from user-supplied data, so input can never be interpreted as executable SQL. String-concatenating user input directly into a query is what allows SQL injection in the first place.

  10. What is the primary role of a firewall in a network architecture?

    1. To control traffic crossing a network boundary
    2. To cache frequently requested files
    3. To balance load across backend servers
    4. To compress network traffic for faster delivery
    Show the answer

    A. To control traffic crossing a network boundary

    A firewall sits at a network boundary and inspects incoming/outgoing traffic, allowing or blocking it based on configured rules (e.g. IP, port, protocol). It acts as a controlled checkpoint between trusted internal networks and untrusted external ones.

  11. How does a Content Delivery Network (CDN) reduce latency for end users?

    1. By forcing every request back to a single origin server
    2. By encrypting all traffic twice
    3. By compressing the origin server's database
    4. By serving cached content from edge servers near the user
    Show the answer

    D. By serving cached content from edge servers near the user

    A CDN caches and serves content from a network of geographically distributed edge servers ("points of presence"), so a user's request is served from a nearby edge location rather than travelling all the way to the origin server, reducing round-trip latency.

  12. What is the main benefit of caching in a system's architecture?

    1. It serves hot data from a faster layer
    2. It guarantees data is always perfectly up to date
    3. It eliminates the need for authentication
    4. It replaces the need for a database
    Show the answer

    A. It serves hot data from a faster layer

    Caching stores a copy of frequently accessed data in a faster layer (memory, edge, CDN) closer to where it is used, reducing repeated round-trips to a slower backend (database, origin server), which lowers latency and reduces load on that backend.

  13. What happens on a cache miss?

    1. The request fails and returns an error to the client
    2. The entire cache is invalidated
    3. The cache automatically resizes itself
    4. Fetched from the source and written into the cache
    Show the answer

    D. Fetched from the source and written into the cache

    A cache miss occurs when requested data is not found in the cache. The system must then fetch the data from the slower primary source (e.g. a database or origin server), typically populating the cache with the result so subsequent requests for the same data hit the cache.

  14. Why does a search engine build an index instead of scanning all documents for every query?

    1. To automatically translate documents into other languages
    2. To encrypt documents for security
    3. To reduce storage space used by the documents themselves
    4. To retrieve fast without scanning every document
    Show the answer

    D. To retrieve fast without scanning every document

    Indexing precomputes data structures (e.g. inverted indexes) that map query terms directly to the documents containing them, so a query can be answered in roughly logarithmic or constant time relative to relevant matches, instead of scanning the entire (potentially huge) document collection on every request.

  15. What is the role of a message broker (e.g. Kafka, RabbitMQ) in a distributed system?

    1. It stores and forwards messages, decoupling both sides
    2. It compiles application code into deployable artefacts
    3. It replaces the need for a load balancer
    4. It is a type of relational database optimised for joins
    Show the answer

    A. It stores and forwards messages, decoupling both sides

    A message broker sits between producers and consumers, receiving, durably storing, and forwarding messages, which decouples the sender from the receiver in time and location. Producers do not need consumers to be online, and consumers can process messages at their own pace.

  16. What are the core principles of RESTful API design?

    1. Custom RPC-style method names in the URL and a single HTTP verb for everything
    2. Resource URLs, standard methods, statelessness, standard status codes
    3. Server-side sessions that persist state between requests
    4. All requests must be sent as XML over a persistent socket
    Show the answer

    B. Resource URLs, standard methods, statelessness, standard status codes

    REST APIs model resources with URLs, use standard HTTP methods (GET, POST, PUT, DELETE) to act on them, are stateless (no server-side session between requests), and use standard HTTP status codes to communicate outcomes — making the API predictable and cacheable.

  17. What is a webhook?

    1. A client repeatedly polling a server for new data
    2. A type of database trigger with no network involvement
    3. An HTTP callback to a registered URL on an event
    4. A caching layer placed in front of an API
    Show the answer

    C. An HTTP callback to a registered URL on an event

    A webhook is an HTTP callback: instead of a client repeatedly polling a service for updates, the service sends an HTTP request to a URL the client registered in advance whenever a specific event occurs, pushing the notification to the client as it happens.

  18. What is the purpose of API rate limiting and throttling?

    1. To speed up individual requests
    2. To replace the need for authentication
    3. To cap requests per client, protecting the backend
    4. To permanently ban any client that sends more than one request
    Show the answer

    C. To cap requests per client, protecting the backend

    Rate limiting caps how many requests a client can make in a given time window, protecting the backend from being overwhelmed (by abuse, bugs, or traffic spikes), ensuring fair usage across clients, and keeping the system stable under load.

  19. What is the main benefit of containerization (e.g. Docker) for deploying applications?

    1. It replaces the need for an operating system entirely
    2. It is only useful for databases, not application code
    3. It guarantees the application has zero bugs
    4. It packages an app with its dependencies into a portable unit
    Show the answer

    D. It packages an app with its dependencies into a portable unit

    Containers package an application together with its dependencies and runtime into a single, lightweight, portable unit that runs consistently across different environments (a developer's laptop, staging, production), eliminating "works on my machine" discrepancies without the overhead of a full virtual machine.

  20. What does Kubernetes primarily automate for a containerised microservices deployment?

    1. Compiling source code into container images
    2. Encrypting all data stored in the cluster
    3. Deploying, scaling and scheduling containers
    4. Writing the application's business logic automatically
    Show the answer

    C. Deploying, scaling and scheduling containers

    Kubernetes automates deploying, scaling, and managing containers across a cluster of machines: scheduling containers onto nodes, restarting or rescheduling failed ones, scaling replica counts up/down, and providing service discovery and load balancing between them.

  21. An app has 10 million daily active users, and each makes 5 requests a day. Spread evenly over the day, roughly what is the average request rate?

    1. About 600 requests per second
    2. About 60 requests per second
    3. About 60,000 requests per second
    4. About 6,000 requests per second
    Show the answer

    A. About 600 requests per second

    10 million × 5 is 50 million requests a day, and a day is 86,400 seconds, which rounds to 100,000 for mental arithmetic: 5 × 10⁷ ÷ 10⁵ is 500, and the exact figure is about 580. The rounding is the point: an estimate needs the right power of ten, not the third digit. Real traffic is not even, so the next step is a peak, often two to three times the average.

  22. Roughly how many times longer is a network round trip between London and New York than a read from main memory?

    1. About a million times longer
    2. About a billion times longer
    3. About 100 times longer
    4. About 10,000 times longer
    Show the answer

    A. About a million times longer

    A main-memory reference takes about 100 nanoseconds, and a transatlantic round trip about 70 milliseconds; light in fibre alone needs about 56 ms for the distance and back. 70 ms ÷ 100 ns is 700,000, so about a million. That gap is why designs keep hot data in memory close to the user and avoid chatty calls between regions: one round trip costs as much as a million memory reads.

  23. Put these in the order a system design interview usually runs.

    • Define the API the system exposes
    • Draw the high-level design: services, stores and how requests flow
    • Name the core entities and sketch the data model
    • Deep-dive into bottlenecks, failure modes and trade-offs
    • Clarify the functional and non-functional requirements
    Show the answer
    1. Clarify the functional and non-functional requirements
    2. Define the API the system exposes
    3. Name the core entities and sketch the data model
    4. Draw the high-level design: services, stores and how requests flow
    5. Deep-dive into bottlenecks, failure modes and trade-offs

    Requirements come first because every later choice is judged against them: a design for 1,000 users and one for 100 million are different designs. The core entities and the API come next, in either order (frameworks differ, so both are marked right), because they fix what the system stores and what it promises. The high-level design then connects services and stores to serve that API, and the deep dives spend the remaining time on the parts most likely to break: hot keys, failure modes, consistency. Estimates fit wherever they change a decision, rather than as a ritual step.

  24. During the evening peak, events arrive faster than the warehouse can insert them, and the service dies with OutOfMemoryError before the peak is over. Which line is at fault?

    private final BlockingQueue<Event> pending =
            new LinkedBlockingQueue<>();
    
    void onEvent(Event e) {
        pending.offer(e);
    }
    
    void drainLoop() throws InterruptedException {
        while (true) {
            warehouse.insert(pending.take());
        }
    }
    1. new LinkedBlockingQueue<>();
    2. void drainLoop() throws InterruptedException {
    3. while (true) {
    4. warehouse.insert(pending.take());
    Show the answer

    A. new LinkedBlockingQueue<>();

    A LinkedBlockingQueue built without a capacity is limited only by the heap, so while events arrive faster than the warehouse takes them, the backlog grows until memory runs out, and every queued event is lost with the process. Give it a capacity, new LinkedBlockingQueue<>(10_000), and decide what happens when it is full: block the producer, reject so the sender retries later, or shed load. The drain loop is the slow consumer the queue is there to absorb; taking one event at a time is not wrong.

  25. Every request to the shop enters through the gateway, and the database and cache are managed services that run across zones. The shop should survive losing any one machine. Which line is at fault?

    services:
      gateway:
        image: shop/gateway:3.1
        deploy:
          replicas: 1
      api:
        image: shop/api:3.1
        deploy:
          replicas: 4
      worker:
        image: shop/worker:3.1
        deploy:
          replicas: 3
    1. image: shop/gateway:3.1
    2. replicas: 1
    3. image: shop/api:3.1
    4. replicas: 4
    5. image: shop/worker:3.1
    6. replicas: 3
    Show the answer

    B. replicas: 1

    One gateway replica means one process carries every request: when its machine fails, or it is redeployed, the shop is down however many API and worker replicas sit behind it. Run at least two gateway replicas on different machines or zones, behind a load balancer or a floating address. The API at four replicas and the workers at three already survive losing one, and the pinned image versions are good practice, not the fault.

  26. Every page view calls this. The Redis cluster has 12 shards, and one of them sits at 100% CPU at peak while the others are nearly idle. Which line is at fault?

    public void recordView(String articleId) {
        redis.incr("views:" + articleId);
        redis.incr("views:total");
        redis.expire("views:" + articleId, WEEK);
    }
    1. redis.incr("views:" + articleId);
    2. redis.incr("views:total");
    3. redis.expire("views:" + articleId, WEEK);
    Show the answer

    B. redis.incr("views:total");

    Redis Cluster maps each key to one shard, so one key is always served by one shard. views:total is incremented on every view, which sends all of that traffic to the shard holding it, however many shards the cluster has. Spread it: increment one of 16 sub-keys chosen at random (views:total:0 to views:total:15) and add them up when reading, or count in memory and flush every few seconds. The per-article keys spread across the shards by their ids.

  27. This endpoint serves 2,000 requests a second. The exchange rates it converts with are published once a day by an outside provider. Which line is at fault?

    app.get('/price/:sku', async (req, res) => {
      const product = await db.products.findOne({ sku: req.params.sku });
      const rates = await fetch(RATES_URL).then((r) => r.json());
      const price = product.priceGbp * rates[String(req.query.cur)];
      res.json({ sku: product.sku, price });
    });
    1. const product = await db.products.findOne({ sku: req.params.sku });
    2. const rates = await fetch(RATES_URL).then((r) => r.json());
    3. const price = product.priceGbp * rates[String(req.query.cur)];
    4. res.json({ sku: product.sku, price });
    Show the answer

    B. const rates = await fetch(RATES_URL).then((r) => r.json());

    Every request fetches the same rates from the provider: 2,000 calls a second for data that changes once a day, each one adding the provider's latency to the response and each one a chance to hit its rate limit. Fetch the rates once, keep them in memory or a shared cache, and refresh them on a timer. The product lookup is different: it reads the one row this request is about, which is what the database is for.

  28. The inventory service has a slow minute every few days. Each time, its traffic jumps to many times normal, and it takes an hour to recover after the slowdown itself is over. Which line is at fault?

    async function stockLevel(sku: string): Promise<number> {
      for (let attempt = 1; ; attempt++) {
        try {
          return await inventory.get(sku, { timeoutMs: 500 });
        } catch (err) {
          log.warn('inventory call failed', { sku, attempt });
        }
      }
    }
    1. for (let attempt = 1; ; attempt++) {
    2. return await inventory.get(sku, { timeoutMs: 500 });
    3. log.warn('inventory call failed', { sku, attempt });
    Show the answer

    A. for (let attempt = 1; ; attempt++) {

    The loop calls again at once and never gives up, so every caller that times out sends another request straight away. A struggling service then receives its normal load plus every repeat, which keeps it struggling after the original cause has gone. Bound the attempts, wait between them with exponential backoff and jitter, and stop calling for a while when most calls fail, which is what a circuit breaker does. The 500 ms timeout is sensible, and logging each failure is fine.

  29. Uploading a photo takes several seconds in the phone app, though storing the original takes a fraction of one. The app only needs the key back. Which line is at fault?

    func upload(w http.ResponseWriter, r *http.Request) {
        img, err := decode(r.Body)
        if err != nil {
            http.Error(w, "bad image", http.StatusBadRequest)
            return
        }
        key := store.Put(img)
        for _, size := range []int{160, 640, 1280, 2560} {
            store.Put(resize(img, size))
        }
        json.NewEncoder(w).Encode(map[string]string{"key": key})
    }
    1. img, err := decode(r.Body)
    2. http.Error(w, "bad image", http.StatusBadRequest)
    3. key := store.Put(img)
    4. store.Put(resize(img, size))
    5. json.NewEncoder(w).Encode(map[string]string{"key": key})
    Show the answer

    D. store.Put(resize(img, size))

    Each upload waits while four resized copies are made and stored, and resizing a large photo is the slow part, so the caller waits for work it does not need before it gets its key. Store the original, return the key, and make the thumbnails in a worker fed by a queue or by the store's upload event. Decoding the body and storing the original are the upload itself.

  30. Creating the account takes about 20 ms, but signup takes several seconds whenever the mail provider is slow, and fails when it is down. Which line is at fault?

    @app.post("/signup")
    def signup():
        user = User(email=request.json["email"])
        db.session.add(user)
        db.session.commit()
        mailer.send(welcome_email(user))
        return {"id": user.id}, 201
    1. user = User(email=request.json["email"])
    2. db.session.add(user)
    3. db.session.commit()
    4. mailer.send(welcome_email(user))
    5. return {"id": user.id}, 201
    Show the answer

    D. mailer.send(welcome_email(user))

    Sending the welcome email inside the request makes the user wait for the mail provider, and makes signup fail when the provider fails, for work the response does not depend on. After the commit, put a job on a queue and send the email from a worker, which can retry without anyone waiting. Creating and committing the user is the request's own work and belongs where it is.

Practise the rest in the app

GapfyreSWE has 59 more System design questions at Intermediate and Advanced level, and over 4,700 across 80+ topics. It works offline and asks for no account.

Download on the App Store Get it on Google Play

More topics