Skip to slide
Chapter 16 · Scaling and Infrastructure
158 / 191

CHAPTER 16 · Scaling and Infrastructure · 4 / 10

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.

← → arrow keys work too