After experiencing CPU saturation and service degradation during audio processing on his web server, the author migrated compute-intensive FFmpeg tasks to a background worker system using Cloudflare Queues and Containers. The article reflects on the trade-offs of the original 'simple-first' architecture, which served hundreds of episodes before needing to scale. It emphasizes waiting to introduce architectural complexity until actual system constraints demand it.
Key points
Adopt a 'simple-first' design approach, introducing complex infrastructure only when performance bottlenecks occur.
Running compute-intensive tasks like FFmpeg inline on a web server will eventually cause CPU quota exhaustion and request blocking.
Decoupling tasks via asynchronous queues prevents heavy background jobs from impacting web server responsiveness.
When using queues, ensure the main thread returns an early acknowledgement (e.g., 202 Accepted) to prevent worker-side blocking during long-running tasks.