Skip to slide
188 / 221

CH 16 · Scaling and Infrastructure · 05/11

Read as one page

Move heavy work off the request path

CPU/memory-heavy or slow work (document conversion, OCR, large bulk extraction) shouldn't run inside the request that holds a user's connection. As load grows, move it to background workers fed by a queue:

  • The request enqueues a job and returns quickly (with a processing status; Chapter 9).
  • Workers pull jobs, do the heavy work, and update status; the client polls or subscribes for completion.
  • Workers scale independently of the web tier, so a burst of uploads doesn't starve interactive chat.

As emphasized in Chapter 10, design for this from the start with status fields even if you begin synchronous; the migration to workers is then localized.

Finished this idea?

Your learning progress stays in this browser.