API Gateway System Design Interview Questions

Reviewed by Mark Dickie · Last updated

An API gateway is a server that sits between external clients and a set of backend services, acting as the single entry point for all incoming requests. For interviews, you should know the core responsibilities: request routing, authentication and authorization enforcement, rate limiting, response transformation, and load shedding. You should also be able to discuss the trade-offs of introducing one, such as added latency from an extra network hop, the risk of a single point of failure, and the operational cost of managing configuration at scale.

ResponsibilityWhat an interviewer expects you to explain
Request routingHow the gateway maps an incoming path or host to a specific upstream service, including path rewriting and version-based routing.
Authentication & authorizationCentralizing token validation (JWT, OAuth2) so individual services do not each reimplement it, and passing identity headers downstream.
Rate limiting & throttlingToken-bucket vs. fixed-window vs. sliding-window counters, per-client vs. global limits, and what happens when a limit is exceeded (429, Retry-After).
Response transformationAggregating responses from multiple services into a single payload, or reshaping fields so the client gets a clean contract.
Load balancing & failoverDistributing traffic across service instances, retrying on transient failures, and circuit-breaking to protect downstream services.

What does an API Gateway interview test?

An interviewer wants to see that you can identify when an API gateway is the right call versus when it adds unnecessary complexity. They will probe whether you can place one correctly in a system diagram, reason about its failure modes, and justify your choice of off-the-shelf product (Kong, Envoy, AWS API Gateway) versus building your own.

How should you structure your API Gateway answer?

  1. Start by stating the problem: multiple services, multiple clients, and the need for a unified entry point.
  2. Draw the gateway between the client and services, and label the traffic flow in both directions.
  3. Walk through each responsibility the gateway handles, naming the specific mechanism (e.g., JWT validation middleware, token-bucket rate limiter).
  4. Address failure modes: what happens if the gateway goes down, how you run multiple instances behind a load balancer, and how you keep configuration in sync.
  5. End with trade-offs: added latency, operational overhead, and the coupling it introduces between client contracts and backend service boundaries.

What are the common mistakes candidates make with API Gateways?

A frequent mistake is treating the gateway as a dumping ground for business logic. Interviewers push back when you move domain rules into the gateway because it blurs the line between infrastructure and application code, making the system harder to test and reason about. Another common gap is ignoring the failure mode: if you cannot explain how the system behaves when the gateway is degraded, the answer feels incomplete.

Key facts

  • Tarmac has 18 System Design interview questions on this topic, 10 of them on this page, at difficulty 1–5 of 5.
  • Tarmac tracked 4,937 job postings asking for System Design in August 2026.
  • Roles asking for System Design advertise a median base salary of US$181,600, across 1,164 job postings as of August 2026.
  • Tarmac last reviewed these System Design interview questions on 21 September 2026.

At a glance

Questions10 shown · 18 in the bank
Difficulty1–5 of 5
FormatsTrue / false, Fill in the blank, Multiple choice, Ordering, Multiple answer, Design exercise

What you'll review

  1. sd architecture
  2. api gateway
  3. microservices
  4. ai system design

Practice questions

Try one before you open the answer. Pick an option and press Check; it's marked on the spot.

System Design/sd-architecture

A monolithic architecture packages all application components (UI, business logic, and data access) into a single deployable unit, which means the entire application must be redeployed whenever any component changes.#

Options

Show answer

True. In a monolithic architecture, all components—UI, business logic, and data access—are packaged into one deployable unit. A change to any component requires rebuilding and redeploying the entire application. This coupling is a primary reason teams adopt microservices, which allow individual services to be deployed independently.

Why:

By definition, a monolith is a single deployable artifact. All components are tightly coupled and compiled/packaged together. Any code change—regardless of which layer it affects—requires rebuilding and redeploying the whole unit. This is one of the key motivations for moving toward microservices, which allow individual components to be deployed independently.

System Design/sd-architecture

Complete the two key concepts: A _____ balances incoming network traffic across multiple servers to improve availability and throughput. When user session data must remain on the same server for the duration of a session, this is called _____ persistence.#

Show answer

Complete the two key concepts: A load balancer balances incoming network traffic across multiple servers to improve availability and throughput. When user session data must remain on the same server for the duration of a session, this is called sticky persistence.

Why:

A load balancer sits in front of a pool of servers and distributes client requests using algorithms such as round-robin or least-connections. When an application stores session state locally on a specific server, a 'sticky session' (also called session affinity) configuration tells the load balancer to always route a given client to the same backend server so that session data remains accessible. This avoids the need to share session state across servers but can create uneven load distribution.

System Design/sd-architecture/api-gateway

In a microservices deployment, what is the primary role of an API gateway placed between external clients and the internal services?#

Options

Show answer

An API gateway is a single client-facing entry point that routes and aggregates requests and centralises cross-cutting concerns — authentication, TLS termination, rate limiting — so services don't each reimplement them. It complements a load balancer rather than replacing it, holds no application or session state, is not a database proxy, and is not a build tool that merges services into one artifact.

Why:

An API gateway is the single front door for client traffic: it routes (and often aggregates) requests to the right backend services and centralises cross-cutting concerns — auth, TLS termination, rate limiting, request shaping — that would otherwise be duplicated in every service. It complements a load balancer (which spreads traffic across instances of a service) rather than replacing it, and it holds no application/session state (b). It is not a database proxy and has nothing to do with cross-service data consistency (c), nor is it a build tool that merges services (d) — the services stay independently deployed behind it.

System Design/sd-architecture

You are designing a globally distributed, multi-region active-active database (e.g., a shopping-cart service). Each region accepts both reads and writes and replicates asynchronously to the others. A user updates their cart from two different regions nearly simultaneously before either update has replicated.#

Options

Show answer

Vector clocks (or version vectors) with application-level or CRDT-based merging are the best fit. They capture causal relationships between writes across regions, allowing the system to detect true conflicts (concurrent writes with no causal ordering) and apply deterministic merge logic — without requiring cross-region coordination on the write path. LWW risks silent data loss due to clock skew, 2PC sacrifices availability, and read repair only acts on the read path.

Why:

In a multi-region active-active architecture, the core challenge with eventual consistency is handling concurrent writes to the same record from different regions. Vector clocks (or similar mechanisms like CRDTs) track causality across nodes so that conflicts can be detected and resolved rather than silently overwriting data. Last-Write-Wins (LWW) based solely on wall-clock time is unsafe because clocks can skew, making it possible to overwrite a newer write with an older one. Two-phase commit provides strong consistency but introduces cross-region coordination latency and is an availability risk — the opposite of what active-active targets. Read repair is a read-path technique and does not prevent write conflicts. Vector clocks remain the standard causality-tracking answer for active-active replication conflict detection.

System Design/sd-architecture

A distributed key-value store experiences a network partition that splits its nodes into a majority group and a minority group. Arrange the following architectural decision steps in the correct order a system architect should reason through when handling this scenario, from first principle to final action:#

Put these in order

Show answer

The correct order is: Detect the partition → Identify majority vs. minority nodes → Determine CP vs. AP SLA → Enforce the policy (CP: reject minority writes outright; AP: accept all writes and track divergence) → Reconcile after healing (AP: conflict resolution; CP: minority re-syncs from the majority log). Identifying the majority/minority split must precede enforcement, and true CP systems reject — not queue — minority-side writes.

Why:

The question tests deep understanding of the CAP theorem applied to a concrete split-brain scenario. First, the system must detect the partition — without detection, no decision can be made. Second, nodes must identify majority vs. minority — this quorum assessment is a prerequisite to knowing which side to suppress or allow. Third, the architect must consult the system's SLA to decide between CP and AP behaviour. Fourth, the system enforces that decision: an AP system (e.g., Cassandra, DynamoDB) accepts writes on both sides and logs divergence; a true CP system (e.g., etcd, ZooKeeper — both Raft/Paxos-based) outright rejects writes that cannot achieve quorum on the minority side — queuing writes would defer the consistency decision and is an AP-leaning strategy, not CP. Finally, after healing, AP systems perform conflict resolution (LWW, vector clocks, CRDTs); CP systems simply re-sync minority nodes from the authoritative majority log, because those minority nodes accepted no writes and have nothing to replay.

System Design/sd-architecture

A senior engineer is reviewing a system design document for a high-traffic e-commerce platform. Which of the following architectural statements are correct? Select all that apply.#

Options

Pick every one that applies.

Show answer

The correct statements are the ones about message queues, stateful services, and read replicas. A message queue like Kafka decouples producers and consumers and smooths traffic spikes. Stateful services require externalised or sharded state before horizontal scaling; just adding instances risks split-brain. Read replicas offload read traffic from the primary. Placing a CDN in front of the application tier is wrong because CDNs cache HTTP responses at the edge — they cannot introspect or cache arbitrary database query results.

Why:

This question probes several common but costly misconceptions in large-scale system design. (1) Adding a CDN for database query caching is FALSE — CDNs cache static or edge-cacheable HTTP responses, not raw database queries; that role belongs to an in-process or distributed cache like Redis. (2) A message queue (e.g., Kafka, SQS) decouples producers from consumers and naturally absorbs traffic spikes by acting as a buffer, so bursts don't overwhelm downstream services — TRUE. (3) Horizontal scaling of stateful services is NOT simply a matter of adding instances; state must be externalised or partitioned (sharding, consistent hashing) to avoid split-brain and inconsistency — FALSE. (4) Database read replicas reduce load on the primary by offloading read traffic — TRUE. All four require careful evaluation, making this a multi-select question.

System Design/sd-architecture

You operate a multi-tenant SaaS platform backed by a horizontally sharded database. One shard becomes a persistent hot spot because a single mega-tenant drives 60 % of all writes. Which of the following strategies does NOT generally mitigate a write-heavy hot partition for that tenant?#

Options

Show answer

Adding read replicas does NOT mitigate a write-heavy hot partition. Read replicas offload read traffic to secondary copies, but every write still routes to the primary shard — so the write bottleneck is completely unchanged. Strategies that actually reduce write pressure include re-sharding with virtual nodes, write-behind/coalescing caches, and splitting the hot shard into finer-grained child shards.

Why:

All four techniques are valid strategies for avoiding hot partitions in high-throughput distributed systems. Consistent hashing with virtual nodes spreads load evenly across nodes and handles node churn gracefully. Write-behind caching absorbs burst writes before they hit the storage layer. Shard splitting (range sub-partitioning) breaks a hot shard into smaller shards to distribute the hot key range. However, simply adding read replicas only helps with read-heavy hot spots; it does NOT alleviate write hot spots because all writes must still go to the primary. If the hot partition is write-heavy — the most common production scenario — read replicas are ineffective. The question asks which strategy does NOT generally mitigate a write-skewed hot partition, making read replicas the correct answer.

System Design/sd-architecture

A team is evolving a high-scale e-commerce order management system. Arrange the following architectural milestones in the recommended evolutionary order — from earliest (most foundational) to latest (most mature) — to maximize stability and minimize risk at each transition:#

Put these in order

Show answer

The recommended evolutionary order is: (1) Monolith, (2) Message queue / microservice decomposition, (3) Saga orchestration, (4) CQRS, (5) Event sourcing, (6) Geo-replication. Microservice decomposition immediately removes ACID guarantees, so saga orchestration must come next — before CQRS or event sourcing — as Richardson's Microservices Patterns argues. CQRS then prepares the write/read split that makes event sourcing lower-risk, and geo-replication is safe only once the event-sourced write model is stable.

Why:

The defensible canonical progression follows the 'concrete operational pain at each step' principle from Richardson's Microservices Patterns and Newman's Building Microservices: (1) Monolith — proves product-market fit with minimal operational complexity. (2) Message queue / microservice decomposition — synchronous bottlenecks and tight coupling become painful under load; introducing Kafka and drawing service boundaries enables independent deployment but immediately removes the monolith's ACID transaction guarantee. (3) Saga orchestration — as Richardson explicitly argues, the first architectural problem exposed by microservice decomposition is the loss of distributed ACID transactions; sagas (orchestration or choreography) must be introduced at this point to manage compensating transactions across service boundaries before any further persistence changes are layered on. (4) CQRS — once service boundaries are stable and transactions are safely coordinated by sagas, read and write workloads diverge sharply; CQRS separates the command model from read projections and is a lower-risk prerequisite for event sourcing because it can be applied to ordinary state-mutation services. (5) Event sourcing — building on the already-separated command model and saga-coordinated boundaries, mutable state is replaced with an immutable event log in a dedicated event store (e.g., EventStoreDB); CQRS projections already in place make this migration far less risky. Event sourcing does not require the message queue as a technical prerequisite, but sagas and CQRS being in place dramatically reduce the blast radius. (6) Geo-replication — only after the event-sourced architecture is stable does replicating the event log across regions become operationally safe and worthwhile; attempting geo-replication before the write model is settled multiplies operational risk.

System Design/sd-architecture/microservices

An e-commerce company runs a single large monolith (catalog, cart, checkout, payments, orders, inventory, shipping all in one deployable, one database). Deploys are slow and risky, one team's bug takes the whole site down, and they can't scale checkout independently of browsing. Design the decomposition into microservices and the platform that supports it.#

Show answer

Goals & when to split. The pains are concrete: coupled deploys, no fault isolation, and an inability to scale checkout independently of browsing (which is ~50× the traffic). Those justify splitting. But microservices aren't free — they trade in-process calls and ACID transactions for network hops, partial failure, and distributed-transaction headaches. So I split deliberately, by business value, not everywhere at once.

Service boundaries. I decompose by bounded context / business capability: catalog, cart, orders, payments, inventory, shipping. Each is high-cohesion and owns its domain logic and its data. I avoid the anti-pattern of slicing along database tables into chatty anaemic services — boundaries follow how the business reasons about the domain, so services stay loosely coupled.

Database decomposition. Each service gets its own datastore (database-per-service) — this is what actually breaks the shared-DB scaling ceiling and SPOF. Services no longer cross-join each other's tables; instead they expose APIs and emit events. The orders service stores the product id (and denormalises the few fields it needs) and fetches the rest from the catalog API, or subscribes to catalog change events. What we give up is the convenient cross-table join and strong cross-entity consistency — replaced by API calls and eventual consistency.

Communication & gateway. An API gateway fronts everything: it authenticates, routes to the right service, rate-limits, and can fan out/aggregate. Between services I pick per interaction: synchronous REST/gRPC for a read I need right now (get product), asynchronous events for 'order placed' / 'inventory changed' so producers don't block on consumers. Every synchronous call is wrapped with timeouts, retries (idempotent), and a circuit breaker so a slow dependency fails fast instead of hanging the caller.

Cross-service correctness (place order). Placing an order spans orders + inventory + payments — three databases, so no single ACID transaction. I use a saga: a sequence of local transactions with compensating actions. Orchestrated, an order orchestrator does: reserve inventory → charge payment → confirm order; if payment fails after the reservation, it fires the compensation release inventory. The order sits in a PENDING state until the saga completes, and the user sees pending → confirmed (or failed). This is eventually consistent but never permanently leaks reserved stock.

Migration & new failure modes. No big-bang. I use the strangler-fig pattern: keep the monolith running behind the gateway, peel out one service plus its data at a time, route that capability's traffic to the new service (feature-flagged), dual-write / shadow-read to validate, then cut over and delete the monolith's copy. New failure modes — partial failure (one service down), cascading failure (a slow dependency dragging callers down), and added latency from hops — are contained with circuit breakers, bulkheads (isolate resource pools per dependency), idempotent retries with backoff, and distributed tracing so a request can be followed across services.

Why:

Decomposing a monolith tests judgement, not just diagram-drawing. The two decisions that define the answer are where the boundaries go — by bounded context / business capability so services are loosely coupled and own their data, never by slicing a shared table into chatty anaemic services — and how to break the shared database, the actual scaling ceiling, via database-per-service reached incrementally with the strangler-fig pattern (peel out one service plus its data at a time, no big-bang). Once data is split, cross-service flows like 'place order' can't use a single ACID transaction, so the correct tool is a saga with compensating actions (reserve → charge → confirm, release on failure), accepting eventual consistency. The strong candidate also names the costs microservices add — partial and cascading failure, network latency — and contains them with an API gateway, circuit breakers, bulkheads, idempotent retries, and distributed tracing, rather than treating 'microservices' as an unqualified win.

System Design/sd-architecture/ai-system-design

Design an LLM-powered customer-support assistant for a large SaaS product. Users ask questions in natural language; the assistant answers grounded in the company's own docs, help-centre articles, and the user's account context, and escalates to a human when unsure.#

Show answer

Requirements. This is grounded generation (RAG), not free-form chat: every answer must be backed by the company's own content, cited, and must never invent policy. Hard constraints: strict per-tenant isolation (no cross-account leakage), human escalation when the model isn't confident, and acceptable chat latency. LLM calls dominate cost and latency, so much of the design is about doing fewer/cheaper/cached calls.

Retrieval (RAG) pipeline. Offline, an indexing pipeline chunks the ~500K docs, embeds each chunk, and writes vectors + metadata (tenant, doc id, version, last-updated) into a vector store. It runs continuously so edited docs are re-embedded and the index stays fresh — that's how a policy reworded last week is reflected. At query time: embed the question → hybrid retrieval (vector similarity + keyword) for the top-k relevant chunks → assemble a prompt: system instructions + retrieved chunks (with their source ids) + the conversation → call the LLM, which answers from the provided context and returns citations.

Serving, cost & latency. The LLM is the bottleneck, so: cache responses (a semantic/embedding cache so near-duplicate questions reuse an answer); stream tokens so the user sees output immediately; tier models — easy/FAQ-matched queries get a small model or a direct retrieved-answer, only hard ones hit the large model; keep prompts tight (top-k, not the whole KB); and queue/batch under load to ride out the 100 QPS peak. These cut both spend and tail latency.

Grounding, hallucination & isolation. The system prompt instructs the model to answer only from the retrieved context and to say it doesn't know (and escalate) when the context doesn't cover the question — this is the main hallucination guard, reinforced by always returning citations the user can check. Tenant isolation is enforced at retrieval: the vector query is filtered by the requesting user's tenant_id (a metadata filter), so account-specific chunks for another tenant are never even candidates for the prompt. Enforcing it at retrieval (not by hoping the model behaves) is what makes leakage structurally impossible.

Failure handling & escalation. LLM calls get timeouts and retries; on provider outage we fail over to a fallback model or degrade gracefully to 'let me connect you to a human', never an indefinite hang. Low-confidence answers — weak retrieval scores, or the model signalling uncertainty — are escalated to a human queue with the conversation context attached, rather than guessing at policy.

Evaluation & scaling. Quality is tracked with an offline eval set (known Q→A pairs) run on each prompt/model change, LLM-as-judge plus human spot-checks on sampled live answers, and logging of every answer with its retrieved context and the user's thumbs feedback to find regressions and gaps. The serving tier is stateless and scales horizontally behind a load balancer; the vector store and indexing pipeline scale independently of it.

Why:

An LLM support assistant is the canonical RAG design, and the framing that separates a strong answer from 'just call the API' is treating it as grounded generation: an offline pipeline chunks and embeds the knowledge base into a vector store, and the request path retrieves the top-k relevant chunks and stuffs them into the prompt so the model answers from company content with citations — which (plus an explicit instruction to refuse/escalate when context is thin) is the real hallucination guard. The two constraints interviewers push on are cost/latency (LLM calls dominate, handled with semantic caching, streaming, model tiering, and tight prompts) and tenant isolation, which must be enforced at retrieval via a tenant metadata filter so another user's data is never even a candidate for the prompt — not left to the model's good behaviour. Rounding it out: provider-outage fallback, human escalation on low confidence (from retrieval scores), and continuous evaluation (offline eval sets, LLM-as-judge, feedback logging) so quality is measured rather than assumed.

Related interview questions

Job market

See system-design salaries and hiring demand from live job postings.

The other 8 questions

This page shows 10 and marks what you pick. That's as far as a page can go. A free account opens the other 8 and keeps every answer. What you miss comes back until it's right: after a day, then at longer gaps.

Start with this topic

Free · the whole bank · 100 marked answers per 30 days · written feedback on the paid plan

What moved, monthly

One email a month when the bulletin comes out: what moved in the markets we track, and the new question topics we published. Confirm your address to join. Unsubscribe any time.