Chapter 7 checkpoint

Asynchronous processing and events

Every question from this chapter’s lessons, grouped by the lesson that teaches it. Answer each one right to finish; you can try again whenever you like.

0 of 17 answered right

7.1 Queues, task queues and log-based message brokers

0 of 5 answered right
Open the lesson
Question 1
A server has 200 worker threads, and each request holds a thread for 5 seconds while a PDF renders. At most how many requests per second can it sustain?
RPS

Answers within 2% count.

Question 2
An upload endpoint now puts a transcoding job on a queue instead of doing the work. What should it answer straight away?

Question 3
Match each system to how it treats messages.

Question 4
A Kafka topic has 12 partitions, and a consumer group runs 20 consumers on it. How many of them are actually consuming?
consumers

Answers within 1% count.

Question 5
Producers publish 12,000 events a second, 1 KB each, to a Kafka topic with 6 partitions. One consumer group reads them and writes each to a database. Which component falls behind?

7.2 Delivery guarantees, ordering and idempotency

0 of 4 answered right
Open the lesson
Question 6
A payment consumer reads charge events from an at-least-once queue. How should it make sure a redelivered event never charges a customer twice?

Question 7
Match each delivery guarantee to what it means.

Question 8
A consumer first sets a Redis key for each message id with SET NX, then applies the payment in the database. After a crash, some payments were never applied, though their messages were redelivered. Why?

Question 9
Each customer’s deposits and transfers must be processed in order, but customers are independent of each other. How do you get that ordering without a single bottleneck?

7.3 Backpressure, queue lag and dead-letter queues

0 of 4 answered right
Open the lesson
Question 10
For 10 seconds, 12,000 jobs per second arrive. There are 20 workers, each handling 500 jobs per second. Afterward arrivals drop to 2,000 per second. How many seconds does the backlog take to drain?

Answers within 5% count, in any unit you choose.

Question 11
One malformed message makes the consumer of a Kafka partition throw every time it reads it, and nothing behind that message is processed. What fixes it?

Question 12
A client retries with full jitter: it waits a random time between 0 and min⁡(M,B⋅2i)\min(M, B \cdot 2^i), with base B=100B = 100 ms, cap M=30M = 30 s and ii the attempt number. What is the longest it can wait on attempt i=5i = 5, in seconds?

Answers within 2% count, in any unit you choose.

Question 13
Why add random jitter to exponential backoff?

7.4 Event sourcing, CQRS and the transactional outbox

0 of 4 answered right
Open the lesson
Question 14
A service inserts an order into its database and then publishes an OrderPlaced event to Kafka from application code. What can go wrong?

Question 15
Put the steps of the transactional outbox in order.
  1. 1
    Insert the order and an outbox row in one transaction
  2. 2
    A relay reads the outbox, by polling or from the change log
  3. 3
    The relay publishes the event to the broker
  4. 4
    Consumers apply the event idempotently
  5. 5
    Commit the transaction

Question 16
What is event sourcing?

Question 17
When does Martin Fowler suggest using CQRS?