Node.js · Senior · Question 41 of 75
Why should long-running or CPU-heavy work be moved out of the HTTP request path?
- 1Workers use less memory than HTTP servers
- ✓Correct answer: Requests stay fast and predictable, and the work can be retried, scaled and monitored separately
- 3HTTP doesn't allow responses longer than 1 second
Explanation
Return 202 Accepted with a job ID and let clients poll or receive a webhook or event. Keep jobs idempotent.