System Design · Module 11
Queues, background jobs and event streams
- Lessons
- 15
- Free
- 0
- Reading
- ~5 h
Your progress
0 / 15 lessons done
Sign in to trackLessons
- Asynchronous processing: moving work off the request pathA slow email provider should not delay checkout. Moving work into the background separates those failures, but creates obligations to store, retry and monitor the work.
- Job queues vs event streamsBackground workers often start with one queue. Adding another business function can silently split work that both functions needed to receive.
- Delivery guarantees: at-most-once, at-least-once, exactly-onceWorkers crash after saving results, and network timeouts hide successful operations. You need to know when to retry and where duplicate protection must live.
- Event schemas: evolving events without breaking consumersServices deploy independently, but their events remain in queues, logs and archives. A harmless-looking field change can stop receipts or silently corrupt financial reports.
- Pub/sub: delivering one event to many consumersOne business event often starts work in several services. Pub/sub separates those responsibilities, but subscription boundaries determine whether work is shared, duplicated or missed.
- Postgres as a job queue: SKIP LOCKEDA service can use its existing database to schedule durable background work. The difficult parts are concurrent claiming, crash recovery and protecting database capacity.
- Queue lag: detecting and handling backlogsA queue can accept work long after workers stop keeping up. You need to detect the growing delay before customers miss receipts, exports or notifications.
- Dead-letter queues: isolating failing messagesBackground workers need a way to stop retrying broken work without losing evidence. You will use dead-letter queues to keep valid jobs moving and make failed jobs recoverable.
- Kafka: partitions and consumer groupsKafka applications often fail because their partition keys, consumer groups and saved progress do not match their processing rules. These choices determine whether adding workers helps and what happens after a crash.
- Stream processing: computing over live dataLive dashboards, rolling scores and operational alerts need answers before all their input has arrived. You must define when an answer appears, when it changes and how recovery avoids counting twice.
- Event sourcing and CQRSOrder histories and read-optimized screens often need different representations of the same business facts. These patterns help you separate them, but also create new responsibilities around concurrency, replay and stale reads.
- Distributed job schedulingReports, renewals and cleanup jobs must survive deployments and outages. Their hardest failures happen between deciding that work is due and recording that somebody must do it.
- Workflow orchestration: multi-step jobs as DAGsImports, media processing and fulfillment often need several jobs to finish in a particular order. Orchestration makes that order explicit and gives operators a durable record of unfinished work.
- Design: a notification serviceNotifications cross several failure boundaries before reaching a person. You need to separate saved work, provider acceptance and delivery, then decide what to retry at each boundary.
- Design: a durable event log like KafkaEvent infrastructure becomes part of your data system. Its acknowledgement rules, recovery behavior and retention policy determine whether downstream services can trust and rebuild their state.
Practise with
Terms this module teaches 44
Open glossaryAmbiguous submission
An external operation whose outcome is unknown because the caller did not receive or save conclusive evidence.
Background worker
A program that executes stored work independently of the request that created it.
Command Query Responsibility Segregation
Using separate models for changing information and reading it. The models can share a database and need not use event sourcing.
Consumer offset
A position in a partition used to identify where a consumer should read or resume.
Dead-letter queue
A queue that isolates messages removed from normal processing because they need investigation or recovery.
Directed acyclic graph
A graph whose edges have a direction and contain no directed cycle.
Event log
A retained ordered sequence of records that readers can revisit using positions.
Event schema
The contract describing an event’s fields, types, presence rules and business meaning.
Event sourcing
Storing accepted business facts as the authoritative history from which current state can be reconstructed.
Event stream
An ordered sequence of recorded facts; a retained stream keeps facts available independently of readers’ processing progress.
Job lease
Stored permission for one attempt to process a job until a deadline, after which recovery may make the job available again.
Job queue
A messaging arrangement that tracks pending work and distributes deliveries among interchangeable workers.
Kafka consumer group
Consumers that share partition assignments and maintain a group’s restart positions. Each partition has at most one assigned owner within an ordinary group at a time.
Kafka offset
A numeric position within one Kafka partition. A committed consumer offset identifies where that group should resume.
Kafka partition
An ordered log within a Kafka topic, with its own record offsets.
Kafka topic
A named stream of records divided into partitions.
Message acknowledgement
A signal from a consumer that lets a messaging system record an item as finished.
Message queue
A buffer where producers leave messages and consumers take them later, so the two sides don’t have to run at the same speed or the same time.
Partition
One ordered sequence within a topic, stored and processed as a unit.
Poison message
A message that repeatedly fails processing because of its contents or a consistently triggered processing defect.
Processing checkpoint
Durable recovery information recording how far a processor has committed its work.
Processing time
The time on a worker’s clock when it processes an event.
Provider acceptance
A provider’s acknowledgment that it has accepted a message for further processing, not proof that a recipient received or read it.
Queue backlog
Accepted work that has not yet reached its required successful outcome. Its exact scope must state whether assigned and delayed jobs are included.
Queue drain rate
The amount by which successful completion throughput exceeds arrival throughput, expressed in matching work units per second.
Queue lag
How far processing has fallen behind incoming work, measured using unfinished work and elapsed time.
Read model
A stored representation of data shaped for particular queries, often maintained from an authoritative write model.
Read projection
A derived view of accepted data, organized to answer particular read queries efficiently.
Request path
The operations that must finish before a server can return a response to a request.
Retention
The policy that controls when stored messages or events expire.
Schedule catch-up policy
The rule that determines whether missed scheduled occurrences are replayed, combined into a recent occurrence, or skipped.
Schedule occurrence
One intended execution of a schedule, identified by the schedule and its intended execution time.
Schema compatibility
Whether records written under one schema can be read under another schema. The direction depends on which reader and writer are newer.
Schema registry
A shared store of schema revisions that can check proposed changes against a configured compatibility policy.
SKIP LOCKED
A PostgreSQL locking option that skips rows whose requested row locks cannot be acquired immediately.
Stream processing
Continuously computing results from an ongoing sequence of events, often retaining state between events.
Subscription
A receiver’s registered interest in messages, with independent delivery progress when the messaging system supports it.
Topic
A named category to which publishers send messages and from which subscriptions select messages.
Trigger
A rule deciding when a streaming computation emits a result.
Visibility timeout
The period during which a received queue message is hidden before it becomes available for another attempt if it remains unfinished.
Watermark
An estimate of event-time progress used to decide when to publish results and retire old state.
Window
A rule that groups stream events into finite intervals for computation.
Workflow join
A dependency condition that combines upstream task outcomes to decide whether downstream work may start.
Workflow orchestration
Coordinating related tasks by recording progress and deciding which task may run next.