Skip to content
Tech Interview Prep
Technical interview guide

Message Queues & Async Processing

Decoupling a slow or unreliable step from the request path by handing it to a queue and processing it separately.

Read
23 min
Practice MCQs
25
Interview Q&A
25
Edition
v6
Editorial status
Reviewed

Scope: Vendor-neutral distributed-systems principles; current AWS architecture guidance.

Curated: · Written: · Reviewed:

25 questions

MCQ-10What does a log-based system offer that a traditional queue does not?
MCQ-3A team publishes events to a topic with 12 partitions, keyed by account ID, and runs 12 consumers in one group. They observe that events for a given account are always consumed in the order they were produced, but events for different accounts are interleaved unpredictably. Which statement about Kafka's ordering guarantee explains this?
MCQ-11A payments service publishes to a Kafka topic with 12 partitions, keyed by account ID, and a consumer group of 12 applies events at 42k msg/s with per-account ordering intact. A new audit rule requires every event to be applied in the exact order it was produced, across all accounts. The team keeps the topic and the 12 consumers. What is the highest sustained rate at which events can now be applied in that global order?
MCQ-19An orders topic has 12 partitions. Producers publish with the order ID as the message key, acks=all, retries=10, max.in.flight=5, and idempotence disabled. One consumer group applies a per-order state machine. Over a week, 3 of roughly 40,000 orders had a 'shipped' event applied before the earlier 'paid' event for the same order. What is the most likely cause?
MCQ-25A topic has 6 partitions. A consumer group runs 12 instances, each able to process 400 msg/s, and producers publish 3,000 msg/s. Lag climbs steadily and no consumer reports errors. Which statement is true of this group?
MCQ-4A partitioned log has 6 partitions. A consumer group of 6 members, one per partition, keeps up with a producer sending 30,000 messages/s; each member processes 5,000 messages/s. The producer rate rises to 45,000 messages/s and the team adds 6 more members to the same group. What is the steady state?
MCQ-14A team runs a consumer fleet with a fixed 512 MB memory limit per pod. Processing time per message ranges from 5 ms to 400 ms depending on payload, and traffic arrives in bursts 10x the steady-state rate. They are choosing between AMQP `basic.consume` and a Kafka `poll()` loop. Which statement correctly describes the flow-control trade-off that decides this choice?
MCQ-22A consumer group `billing` reads a single-partition topic `orders`. Its last committed offset is 4,200,000. The group is stopped for 5 days; the topic's retention.ms is 3 days, so the log start offset is now 5,100,000 and the log end offset is 5,600,000. The group's committed offsets are still stored (offsets.retention.minutes defaults to 7 days), and its auto.offset.reset is latest. What does the consumer do when the group restarts?
MCQ-18An SQS queue ingests order events at 1,200 messages per second during a week-long promotion. Twenty consumers each process 40 messages per second, draining 800 messages per second; each message takes 25 ms. The queue uses the default 4-day retention period and the default 30-second visibility timeout. No consumer fails. What happens to the messages published in the first minute of the promotion?
MCQ-23Why must a visibility timeout exceed realistic processing time?
MCQ-6A worker polls a queue whose visibility timeout is 30 seconds. One handler takes 45 seconds, never extends the timeout, and the worker process stays up throughout. Other workers are polling the same queue. What happens at t = 30 s?
MCQ-5An order service consumes from an SQS standard queue whose redrive policy sets maxReceiveCount = 3 and points at a dead-letter queue. The consumer's handler retries a failing message 5 times in-process before rethrowing; the SDK then leaves the message undeleted. The five attempts finish in under 2 s, well inside the 30 s visibility timeout. A malformed order fails every attempt. How many times does the handler run before the message reaches the dead-letter queue?
MCQ-16What does an unmonitored dead-letter queue become?
MCQ-8A payments service consumes messages from a queue and retries each failed handler up to three times with exponential backoff before routing the message to a dead-letter queue. Which failure should not be retried?
MCQ-7A payments service runs 800 worker processes. On a failed call to the fraud-check API, each worker retries with exponential backoff: base 1 s, factor 2, no jitter, up to 3 retries. At 09:00:00 the fraud-check API is restarted and all 800 in-flight calls fail within the same 20 ms. The API has no request queue, serves at most 1,500 requests/second, and returns 503 to anything beyond that. What does the API see when the first retries fire at 09:00:01?
MCQ-2A worker consumes from a queue that guarantees at-least-once delivery. For each message it runs `UPDATE accounts SET balance = balance + ? WHERE id = 42` with the message's amount, then acks. The account starts at 1000. The producer publishes two messages: +100 and +200. The worker processes the +100 message, but its ack is lost in a network partition, so the broker redelivers it and the worker processes it again. The worker then processes the +200 message normally. What is the balance?
MCQ-12A payments consumer handles `charge` messages: it inserts the message key into `processed_keys` (unique index on the key column), then charges the card, then commits the offset. The producer builds the key as `charge-{orderId}-{epochMillis}`, reading the clock at publish time, and republishes the same charge up to 3 times whenever a publish times out after 500 ms. One order's card is charged 4 times, all within 2 seconds, and `processed_keys` holds 4 rows for that order with 4 distinct keys. Rows live for 24 hours. What happened?
MCQ-15A consumer applies account balance updates. Each message carries (accountId, version, delta), and the consumer keeps one row per account with the last applied version and the running balance. It applies a message only when the message's version is greater than the row's stored version, adding the delta. The producer retries on timeout, so a message can arrive after a newer one. Account A's row currently holds version 4, balance 250. Four messages for A arrive in this order: (v6, +60), (v5, +40), (v8, +50), (v7, +30). What balance does the row hold after all four are processed?
MCQ-13An order service commits `INSERT INTO orders` in Postgres 16 and then calls `kafka.send("orders.created")` as a separate step. A rolling deploy kills the process between the two on about 0.3% of orders: roughly 1,100 orders last month got no event. The team moves the send into an outbox: the order insert and an `INSERT INTO outbox` commit in one transaction, and a relay reads unsent outbox rows, publishes them to Kafka, then marks them sent. What does this design change?
MCQ-17An order service commits the order row to Postgres and then publishes an `order.created` event to Kafka. The producer is configured with `retries=0`, and there is no outbox table. A 90-second network partition between the service and Kafka begins. During it, 1,200 orders commit successfully, and every publish attempt fails after 3 s. The partition then heals and the service keeps running normally. What state does the system settle into?
MCQ-9An order service commits the order row and an outbox row in a single Postgres transaction. A relay process then runs `SELECT * FROM outbox WHERE sent = false`, publishes each row to Kafka, and marks it sent with a second `UPDATE`. A relay instance publishes outbox row 4471, Kafka acknowledges the write, and the instance is killed before the `UPDATE` runs. What happens to row 4471?
MCQ-1A payments consumer reads from Kafka with isolation.level=read_committed, writes each record to Postgres with a plain INSERT, then commits its offset through sendOffsetsToTransaction. The producer runs with enable.idempotence=true; the topic is written with acks=all and min.insync.replicas=2, and unclean.leader.election.enable=false. The pod is OOM-killed partway through a batch, and one payment row appears twice. Which mechanism produced the duplicate?
MCQ-24What is the correct place for a side effect relative to a transaction?
MCQ-20A checkout API publishes a `charge.requested` message to RabbitMQ and returns HTTP 202 to the mobile client. The API has a 200 ms latency budget and the payment gateway's p99 is 2 s, so the charge runs in a separate worker. The gateway returns a hard decline (`do_not_honor`) for this card, and the customer is left on a "confirming your order" screen. Which design handles that decline correctly?
MCQ-21Which is a legitimate reason to process work synchronously instead?