Node.js · Senior · Question 59 of 75
Why should a horizontally scaled Node.js service be stateless?
- 1Node.js can't store data in memory
- 2Stateless services use less CPU
- ✓Correct answer: Any instance can handle any request, so instances can be added, removed or restarted freely; state lives in a DB, cache or object storage
Explanation
In-memory sessions or local uploads break when the next request goes to another instance or the pod restarts.