pencils ready ✎

Microservices MCQs multiple-choice questions with answers & explanations

All 22 Microservices quiz questions on one page. Pick an answer in your head, then open Show answer to check it and read why. Want a score and a timer? Take them as a quiz instead.

  1. 1.

    A circuit breaker has been open for its configured wait duration. What happens next?

    easy
    1. AIt closes and sends all traffic to the dependency again
    2. BIt stays open until an operator resets it by hand
    3. CIt goes half-open and lets a few trial calls through
    4. DIt routes every future call to the fallback method
    Show answer

    Answer: C (It goes half-open and lets a few trial calls through)

    After the wait duration the breaker moves to half-open and permits a limited number of trial calls. If they succeed it closes; if they fail it opens again. Jumping straight to closed would risk flooding a service that is still recovering, and breakers recover automatically rather than needing a manual reset.

  2. 2.

    What ordering guarantee does Kafka provide for the records in a topic?

    mid
    1. ARecords are ordered within each partition only
    2. BRecords are ordered across every partition of the topic
    3. CRecords are ordered per consumer group, across topics
    4. DKafka makes no ordering guarantees of any kind
    Show answer

    Answer: A (Records are ordered within each partition only)

    Kafka orders records only within a partition; there is no total order across the partitions of a topic. To keep all events for one entity in order, give them the same key so they hash to the same partition.

  3. 3.

    A Kafka topic has 6 partitions, and 8 instances of a service join the same consumer group. What happens?

    mid
    1. AEach instance reads a share of every partition
    2. BKafka adds two partitions so every instance has one
    3. CEvery instance receives every record in the topic
    4. DSix instances get one partition each; two sit idle
    Show answer

    Answer: D (Six instances get one partition each; two sit idle)

    Within a consumer group, each partition is assigned to exactly one consumer, so the partition count caps parallelism and extra consumers stay idle. Kafka never adds partitions on its own, and receiving every record is what happens across separate groups, not within one.

  4. 4.

    A service commits an order to its database, then publishes OrderPlaced to a broker. Occasionally the publish fails after the commit. Which pattern fixes this?

    mid
    1. APublish the event first, then commit the order
    2. BA transactional outbox read by a message relay
    3. CRetry the publish a few times inside the request
    4. DBuffer the event in memory until the broker is back
    Show answer

    Answer: B (A transactional outbox read by a message relay)

    This is the dual-write problem. With a transactional outbox, the event is written to an outbox table in the same local transaction as the order, and a relay (polling or CDC) publishes it afterwards. Publishing first just moves the failure window, and in-request retries or in-memory buffers lose the event if the process crashes.

  5. 5.

    What is the main reason two-phase commit (2PC) is usually avoided across microservices?

    hard
    1. AIt cannot make changes atomic across participants
    2. BIt only works when all services are written in one language
    3. CParticipants block, holding locks, if the coordinator fails
    4. DIt requires every service to store events instead of rows
    Show answer

    Answer: C (Participants block, holding locks, if the coordinator fails)

    2PC does provide atomicity, but a participant that has voted yes must hold its locks until it learns the outcome, so a coordinator failure can leave it blocked. It also needs every participant available to commit, and many NoSQL stores and brokers do not support XA. That is why sagas are the usual alternative.

  6. 6.

    In a saga, the payment step fails after an earlier step already reserved stock. What should happen?

    easy
    1. AA compensating step releases the reserved stock
    2. BThe database rolls the reservation back automatically
    3. CThe saga retries the payment step until it succeeds
    4. DThe coordinator asks all participants to vote again
    Show answer

    Answer: A (A compensating step releases the reserved stock)

    Each saga step commits its own local transaction, so there is nothing left for a database to roll back. The saga runs compensating transactions to semantically undo the completed steps. Voting belongs to two-phase commit, and retrying a declined payment forever would never finish.

  7. 7.

    Which HTTP method is not idempotent by definition?

    easy
    1. AGET
    2. BPUT
    3. CDELETE
    4. DPOST
    Show answer

    Answer: D (POST)

    HTTP semantics define GET, PUT and DELETE as idempotent: repeating them has the same effect as sending them once. POST is not, so a retried POST can create duplicates unless the server supports something like an idempotency key.

  8. 8.

    A consumer processes a message and updates its database, then crashes before acknowledging. With at-least-once delivery, what happens?

    mid
    1. AThe message is lost and never processed again
    2. BThe broker redelivers it, so the handler runs twice
    3. CThe broker sees the database change and skips it
    4. DThe message is moved straight to the dead-letter queue
    Show answer

    Answer: B (The broker redelivers it, so the handler runs twice)

    Without an acknowledgement, the broker assumes the message was not processed and delivers it again, so the same message is handled twice. That is why consumers must be idempotent. The broker knows nothing about your database, and messages normally reach a DLQ only after repeated failures.

  9. 9.

    A service's liveness probe checks that a shared database is reachable. The database is down for several minutes. What is the likely result?

    mid
    1. APods leave the Service endpoints but keep running
    2. BNothing, since liveness probes ignore dependency errors
    3. CKubernetes restarts every pod, making the outage worse
    4. DThe autoscaler adds replicas to absorb the failures
    Show answer

    Answer: C (Kubernetes restarts every pod, making the outage worse)

    A failing liveness probe makes the kubelet restart the container, so a dependency outage restarts every pod at once, and they may keep crash-looping. Leaving the Service endpoints is what a failing readiness probe does. Liveness should check only the process itself.

  10. 10.

    Why do you add jitter to exponential backoff between retries?

    easy
    1. ASo clients that failed together do not retry in sync
    2. BSo that each wait is exactly twice as long as the last
    3. CSo a retried request can never be processed twice
    4. DSo the circuit breaker can skip its half-open state
    Show answer

    Answer: A (So clients that failed together do not retry in sync)

    Without jitter, every client that failed at the same moment retries at the same moments, sending synchronized waves of load at a recovering service. Randomizing each wait spreads retries out. Doubling the wait is what exponential backoff itself does, and preventing duplicates is the job of idempotency, not jitter.

  11. 11.

    A client calls service A, A calls B, and B calls C. Each of those three callers makes up to 3 attempts per call. If C is down, how many calls can reach C for one client request?

    hard
    1. A3
    2. B9
    3. C27
    4. D81
    Show answer

    Answer: C (27)

    Retries multiply across layers: 3 client attempts × 3 attempts from A × 3 attempts from B = 27 calls to C. This retry amplification is why you retry at one layer only, cap attempts, and use retry budgets or circuit breakers.

  12. 12.

    According to the CAP theorem, what must a distributed data store trade off when a network partition occurs?

    hard
    1. AAvailability versus partition tolerance
    2. BConsistency versus availability
    3. CLatency versus throughput
    4. DDurability versus consistency
    Show answer

    Answer: B (Consistency versus availability)

    During a partition, a system must either refuse some requests to stay consistent (CP) or keep answering with possibly stale data (AP). Partition tolerance is not optional in a real network, which is why "pick two of three" is misleading. Latency versus consistency is the PACELC trade-off when there is no partition.

  13. 13.

    In PACELC, which trade-off applies during normal operation, when there is no network partition?

    hard
    1. AAvailability versus consistency
    2. BDurability versus availability
    3. CThroughput versus partition tolerance
    4. DLatency versus consistency
    Show answer

    Answer: D (Latency versus consistency)

    PACELC says: if there is a Partition, choose Availability or Consistency; Else, choose Latency or Consistency. Even without failures, waiting for replicas to confirm each write improves consistency but adds latency. Availability versus consistency is the trade-off during a partition.

  14. 14.

    The Orders service needs each customer's name, which the Customer service owns. Which approach fits the database-per-service pattern?

    mid
    1. AKeep a local copy updated from customer events
    2. BJoin directly against the Customer service tables
    3. CGive Orders read-only access to the customer database
    4. DMerge both services into one shared schema
    Show answer

    Answer: A (Keep a local copy updated from customer events)

    A service must not read another service's database, even read-only, because that couples it to the owner's internal schema. Replicating just the needed fields from the owner's events (or calling its API) keeps ownership clear, at the cost of eventual consistency.

  15. 15.

    What does Kubernetes do when a pod's readiness probe fails?

    easy
    1. ARestarts the container immediately
    2. BDeletes the pod and schedules a new one
    3. CScales the Deployment up by one replica
    4. DStops sending Service traffic to it
    Show answer

    Answer: D (Stops sending Service traffic to it)

    A failing readiness probe removes the pod from the endpoints of matching Services, so it stops receiving traffic, but the container keeps running. Restarting the container is the response to a failing liveness probe.

  16. 16.

    What is the core idea of the strangler fig pattern for migrating a monolith?

    easy
    1. ARewrite everything, then switch over in one release
    2. BMove features to new services one slice at a time
    3. CSplit the database first, then deal with the code
    4. DKeep the monolith and a full rewrite running forever
    Show answer

    Answer: B (Move features to new services one slice at a time)

    A facade in front of the monolith routes requests, and capabilities move to new services one slice at a time until the monolith can be retired. Each step is small and reversible, unlike a big-bang rewrite.

  17. 17.

    A CQRS read model is updated asynchronously from events. What is the main trade-off?

    mid
    1. AWrites must lock the read model before committing
    2. BCommands and queries must share the same table
    3. CReads may briefly lag behind the latest writes
    4. DThe read model can never be rebuilt from scratch
    Show answer

    Answer: C (Reads may briefly lag behind the latest writes)

    Because the view is updated from events after the write commits, it is eventually consistent: a query right after a change may see old data. Read models can usually be rebuilt by replaying events, and the point of CQRS is that commands and queries use separate models.

  18. 18.

    A Kafka consumer uses transactions to read a record, charge a card through an external API, and write a result to another topic. It crashes and restarts. What can go wrong?

    hard
    1. AThe result topic will always contain duplicate records
    2. BThe card may be charged twice by the external API
    3. CThe consumer offset is lost and the topic is replayed
    4. DNothing, because the transaction covers the API call
    Show answer

    Answer: B (The card may be charged twice by the external API)

    Kafka transactions commit the output records and the consumer offset atomically, and read_committed consumers never see aborted output, so the result topic does not end up with duplicates. The external API call is outside the transaction, though, so it can repeat after a crash; it needs an idempotency key.

  19. 19.

    In the token bucket rate-limiting algorithm, what sets the largest burst a client can send at once?

    mid
    1. AThe bucket capacity
    2. BThe refill rate
    3. CThe number of instances
    4. DThe request timeout
    Show answer

    Answer: A (The bucket capacity)

    A full bucket holds capacity tokens, so a client can spend them all in one burst; after that, requests are limited to the refill rate. The refill rate sets the long-run average, not the burst size.

  20. 20.

    A client times out on POST /payments and retries with the same Idempotency-Key. The first attempt had actually succeeded. What should the server do?

    mid
    1. ACharge again, because the client sent it twice
    2. BReject the retry with 400 Bad Request
    3. CRefund the first payment and charge again
    4. DReturn the stored result of the first attempt
    Show answer

    Answer: D (Return the stored result of the first attempt)

    The point of an idempotency key is that repeats of the same logical operation return the original outcome without redoing the work. The server stores the result against the key and replays it; it rejects the key only if it is reused with a different request body.

  21. 21.

    What does mutual TLS (mTLS) add compared with ordinary TLS between two services?

    mid
    1. ATraffic is encrypted twice for defense in depth
    2. BThe server no longer needs its own certificate
    3. CThe client is also verified by its certificate
    4. DUser-level authorization is no longer necessary
    Show answer

    Answer: C (The client is also verified by its certificate)

    In ordinary TLS only the server proves its identity. With mTLS both sides present certificates, so each service knows which service it is talking to. It proves service identity, not end-user permissions, so tokens and authorization checks are still needed.

  22. 22.

    In Kubernetes, how does a pod usually reach another service's healthy pods?

    easy
    1. ABy querying a Eureka registry from the client
    2. BThrough the DNS name of a Kubernetes Service
    3. CBy reading pod IPs from a shared config file
    4. DBy broadcasting a discovery request on the node
    Show answer

    Answer: B (Through the DNS name of a Kubernetes Service)

    A Kubernetes Service has a stable DNS name and virtual IP, and traffic is routed to its ready pods: server-side discovery built into the platform. Client-side registries like Eureka work but are usually unnecessary on Kubernetes, and pod IPs change too often to hard-code.

esc