System Design · Senior · Question 5 of 75
Why put a message queue between the API and a heavy-task worker?
- ✓Correct answer: To decouple intake from processing and smooth out load spikes
- 2To make processing synchronous and guarantee a 10 ms response
- 3To replace the database with faster storage
Explanation
The API quickly accepts the request and enqueues a task (report generation, video processing), and workers process it at their own pace. Load spikes are smoothed out, and a worker failure doesn't lose the task. The client learns the result via status polling, SSE or a notification.