liveBook · Manning

Work queue pattern

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A job queue is a processing pattern that records and schedules heavyweight tasks for asynchronous execution and retry after failure.

A work queue records heavyweight jobs for later processing instead of making the user-facing operation wait. A worker microservice consumes the queued jobs, while the database preserves their sequence across application crashes. section 11.4.7

A work queue provides three practical safeguards:

  • It defers CPU- and storage-intensive work until after the triggering operation, such as a video upload. section 11.4.7
  • It resumes after an application crash by reloading unfinished jobs from the database. section 11.4.7
  • It retries individual jobs that fail because unsuccessful jobs remain unmarked as complete. section 11.4.7
  • It controls processing workload rather than requiring the application to handle every queued task at once. section 11.4.7

Video processing after upload

A video service records thumbnail-generation or lower-resolution-conversion jobs after uploads arrive. When many users upload videos together, the job queue stores the workload and lets processing continue even if the processing microservice or application crashes. section 11.4.7

Figure 11.15 A job-queue microservice manages a queue of video thumbnail- generation jobs.

Use the diagram to trace a job-queue microservice managing video thumbnail-generation jobs. section 11.4.7

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Explains database persistence, crash recovery, failed-job retry, and workload control, but stops short of implementation details.
Examples
Uses video thumbnail generation, lower-resolution conversion, and a surge of 1,000 simultaneous uploads.
What it assumes
Assumes a microservices application and a database capable of retaining queued job state.
What you can do after
Operate deferred processing that survives application crashes and retries jobs whose workers fail.
How it connects
Connects microservices, databases, message queues, retries, and fault tolerance.

Also explained in

Compare how 4 books explain work queue pattern →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.