Sample questions
Question 1Easy
Event-driven architecture means services:
- Share one database
- Poll a central server every second for new instructions from the scheduler
- React to published events instead of calling each other directly
- 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
- Services publish events.
- Others subscribe and react.
- 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:
- Only when messages are smaller than one kilobyte
- Across all topics in the cluster
- Across all partitions of a topic
- 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
- A Kafka partition is an ordered log.
- Messages inside one partition keep their order.
- There is no order guarantee across partitions or topics.
- 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?
- Generating a PDF invoice after an order
- Returning search results the user is waiting for
- Validating the CSRF token on a form submission before it is accepted
- 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
- Generating a PDF invoice takes time.
- The customer does not need to wait for it on the order page.
- Work the user does not wait for suits a queue.
- 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:
- Spreading a single consumer across many CPU cores to process one message faster
- Compressing many messages into one
- One message delivered to many consumers or queues
- 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
- Fan-out means one input spreading to many outputs.
- In messaging, one message goes to many consumers or queues.
- 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?
- 6 consumers each read one partition; 2 sit idle
- All 8 read every partition
- Each consumer reads 0.75 partitions
- 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
- Within a consumer group, each partition goes to only one consumer.
- There are 6 partitions, so only 6 consumers can each get one.
- The other 2 consumers have no partition to read.
- 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?
- Messages being processed by every consumer in the group at the same time
- Duplicate messages, so processing should be idempotent
- Messages arriving encrypted
- 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
- At-least-once may redeliver a message.
- So duplicates can happen.
- 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?
- Versioning makes messages travel faster through the network
- Consumers deploy independently and may expect the old shape
- Events cannot contain numbers
- 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
- Consumers are deployed on their own schedules.
- A consumer that has not upgraded still expects the old event shape.
- Renaming or removing a field can break that consumer.
- 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:
- Using SQL for both reads and writes in one table
- Caching every query result
- Separate models for writes and reads
- 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
- CQRS splits commands, which change data, from queries, which read it.
- The write model and the read model can be shaped separately.
- Read views are often updated asynchronously from the writes.
- 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:
- Add more partitions
- Cap retries, then route the message to a dead-letter queue
- Increase the consumer's memory
- 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
- A poison message blocks progress.
- Capping retries stops the loop.
- 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?
- Read-through caching
- Transactional outbox
- Sticky sessions
- 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
- The service writes to its database and then publishes an event.
- A crash between those two steps loses the event.
- A transactional outbox writes the event to an outbox table in the same transaction as the data.
- 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 →