Messaging & Event-Driven Questions with Answers

22 practice questions on Messaging & Event-Driven (System Design) with answers and step-by-step solutions. Try 10 samples below, then practise all 22 free in the AptiNest app.

Sample questions

Question 1Easy

Event-driven architecture means services:

  1. Share one database
  2. Poll a central server every second for new instructions from the scheduler
  3. React to published events instead of calling each other directly
  4. Call each other synchronously in a chain

Answer: C. React to published events instead of calling each other directly

Explanation

An OrderPlaced event can trigger billing, email and analytics independently, loosely coupling them.

Step-by-step solution

  1. Services publish events.
  2. Others subscribe and react.
  3. No direct calls.

Why the other options are wrong

  • A. Sharing DB is coupling.
  • B. Polling is not event-driven.
  • D. Sync chain is request-driven.

Question 2Easy

In Kafka, ordering is guaranteed:

  1. Only when messages are smaller than one kilobyte
  2. Across all topics in the cluster
  3. Across all partitions of a topic
  4. Within a single partition

Answer: D. Within a single partition

Explanation

Each partition is an ordered log; to keep events for one entity in order, use the entity ID as the message key.

Step-by-step solution

  1. A Kafka partition is an ordered log.
  2. Messages inside one partition keep their order.
  3. There is no order guarantee across partitions or topics.
  4. So ordering is guaranteed within a single partition (option D).

Why the other options are wrong

  • A. Message size does not decide ordering.
  • B. Kafka does not order messages across all topics.
  • C. Kafka does not order messages across all partitions of a topic.

Tip: Kafka orders within a partition; use the entity ID as the key to keep one entity in order.

Question 3Easy

Which task is a good fit for asynchronous processing via a queue?

  1. Generating a PDF invoice after an order
  2. Returning search results the user is waiting for
  3. Validating the CSRF token on a form submission before it is accepted
  4. Checking a password during login

Answer: A. Generating a PDF invoice after an order

Explanation

Work the user does not need to wait for can be queued; login and search results are needed immediately.

Step-by-step solution

  1. Generating a PDF invoice takes time.
  2. The customer does not need to wait for it on the order page.
  3. Work the user does not wait for suits a queue.
  4. So generating the invoice after the order is the good fit (option A).

Why the other options are wrong

  • B. Search results are needed immediately, so they should not wait in a queue.
  • C. A CSRF check must happen before the form is accepted, so it is synchronous.
  • D. Login must check the password right away.

Tip: Queue work the user does not need to see right away; keep login, checks and search synchronous.

Question 4Easy

Fan-out in messaging refers to:

  1. Spreading a single consumer across many CPU cores to process one message faster
  2. Compressing many messages into one
  3. One message delivered to many consumers or queues
  4. Many producers writing to one queue

Answer: C. One message delivered to many consumers or queues

Explanation

For example, one event sent to email, SMS and push notification queues.

Step-by-step solution

  1. Fan-out means one input spreading to many outputs.
  2. In messaging, one message goes to many consumers or queues.
  3. Pub/sub topics are the typical example.

Why the other options are wrong

  • A. That is parallelism within a consumer.
  • B. That is batching.
  • D. That is fan-in.

Question 5Medium

A Kafka topic has 6 partitions and a consumer group has 8 consumers. What happens?

  1. 6 consumers each read one partition; 2 sit idle
  2. All 8 read every partition
  3. Each consumer reads 0.75 partitions
  4. Kafka automatically creates 2 extra partitions so that every consumer has work

Answer: A. 6 consumers each read one partition; 2 sit idle

Explanation

Within a group each partition goes to only one consumer, so consumers beyond the partition count are idle.

Step-by-step solution

  1. Within a consumer group, each partition goes to only one consumer.
  2. There are 6 partitions, so only 6 consumers can each get one.
  3. The other 2 consumers have no partition to read.
  4. So 6 consumers each read one partition and 2 sit idle (option A).

Why the other options are wrong

  • B. Within a group each partition goes to one consumer, not to all of them.
  • C. A consumer cannot read a fraction of a partition; the split is whole partitions.
  • D. Kafka does not add partitions on its own to match consumers.

Tip: A consumer group can use at most one consumer per partition.

Question 6Medium

Most message brokers offer 'at-least-once' delivery. What must consumers handle?

  1. Messages being processed by every consumer in the group at the same time
  2. Duplicate messages, so processing should be idempotent
  3. Messages arriving encrypted
  4. Messages that never arrive

Answer: B. Duplicate messages, so processing should be idempotent

Explanation

If an acknowledgement is lost, the broker redelivers, so a message may be processed twice.

Step-by-step solution

  1. At-least-once may redeliver a message.
  2. So duplicates can happen.
  3. Consumers should be idempotent.

Why the other options are wrong

  • A. Groups deliver each message to one member.
  • C. Encryption is unrelated.
  • D. At-least-once means no loss.

Question 7Medium

Why should event payloads be versioned or evolved carefully?

  1. Versioning makes messages travel faster through the network
  2. Consumers deploy independently and may expect the old shape
  3. Events cannot contain numbers
  4. Brokers reject payloads over a fixed version

Answer: B. Consumers deploy independently and may expect the old shape

Explanation

Adding optional fields is safe; renaming or removing fields can break consumers that have not upgraded.

Step-by-step solution

  1. Consumers are deployed on their own schedules.
  2. A consumer that has not upgraded still expects the old event shape.
  3. Renaming or removing a field can break that consumer.
  4. So consumers may expect the old shape, which is why option B is right (option B).

Why the other options are wrong

  • A. Versioning does not change how fast messages travel.
  • C. Events can contain numbers; that is not the reason for versioning.
  • D. Brokers do not reject payloads for a version number; the risk is for consumers.

Tip: Add optional fields only; do not rename or remove fields that consumers rely on.

Question 8Medium

CQRS (Command Query Responsibility Segregation) means:

  1. Using SQL for both reads and writes in one table
  2. Caching every query result
  3. Separate models for writes and reads
  4. Queuing every command until a nightly batch job applies all of them together

Answer: C. Separate models for writes and reads

Explanation

Commands update a write model; queries read from views optimised for reading, often updated asynchronously.

Step-by-step solution

  1. CQRS splits commands, which change data, from queries, which read it.
  2. The write model and the read model can be shaped separately.
  3. Read views are often updated asynchronously from the writes.
  4. So CQRS means separate models for writes and reads (option C).

Why the other options are wrong

  • A. CQRS usually separates models, not one table for both.
  • B. Caching every result is a separate technique.
  • D. CQRS does not queue commands for a nightly batch.

Tip: CQRS: one model to change data, another to read it.

Question 9Hard

A consumer keeps crashing on one malformed message, which is redelivered forever and blocks the partition. The best fix is:

  1. Add more partitions
  2. Cap retries, then route the message to a dead-letter queue
  3. Increase the consumer's memory
  4. Turn off acknowledgements entirely so the broker never redelivers anything

Answer: B. Cap retries, then route the message to a dead-letter queue

Explanation

A retry limit plus DLQ isolates poison messages while the rest of the stream keeps flowing.

Step-by-step solution

  1. A poison message blocks progress.
  2. Capping retries stops the loop.
  3. A dead-letter queue stores it for inspection.

Why the other options are wrong

  • A. More partitions don't fix it.
  • C. Memory isn't the problem.
  • D. Disabling acks loses messages.

Question 10Hard

A service updates its database and then publishes an event. If it crashes between the two, the event is lost. Which pattern fixes this?

  1. Read-through caching
  2. Transactional outbox
  3. Sticky sessions
  4. Two-phase commit with the browser

Answer: B. Transactional outbox

Explanation

The event is written to an outbox table in the same DB transaction, then a relay publishes it reliably.

Step-by-step solution

  1. The service writes to its database and then publishes an event.
  2. A crash between those two steps loses the event.
  3. A transactional outbox writes the event to an outbox table in the same transaction as the data.
  4. A relay then publishes from that table, so the event is not lost (option B).

Why the other options are wrong

  • A. Read-through caching is about reads and does not publish events.
  • C. Sticky sessions route users to a server and do not protect events.
  • D. Two-phase commit with the browser is not a practical fix for this.

Tip: Write the event in the same transaction as the data, then publish it from an outbox.

Practise all 22 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all System Design topics · All topics