Back to the Catalog
system-design
nodejs

Scaling a Node.js Service

13 questions

A single Node process runs your JavaScript on one event-loop thread — so scaling it is a system-design problem, not a config flag. Build intuition for statelessness as the precondition for horizontal scaling, cluster vs. worker_threads, moving shared state into Redis, why sticky sessions are a smell, graceful shutdown and connection draining on SIGTERM, liveness vs. readiness probes, and keeping CPU-bound work off the event loop. Code snippets and the libuv thread-pool facts are verified against current Node.

Questions

  1. Not answered. Why do users get randomly logged out after scaling to three instances?
  2. Not answered. Which tool idiomatically moves CPU-bound work off the event loop?
  3. Not answered. Which statements about cluster vs. worker_threads are true?
  4. Not answered. How does cluster distribute incoming TCP connections by default?
  5. Not answered. Where should the shared session state live?
  6. Not answered. Which of these are genuine drawbacks of sticky sessions?
  7. Not answered. What should a Node process do on SIGTERM to shut down gracefully?
  8. Not answered. Why does server.close() hang even with no requests in flight?
  9. Not answered. How do failing liveness and readiness probes differ in Kubernetes?
  10. Not answered. What should a Pod do first when it receives SIGTERM?
  11. Not answered. While one /report request runs, what happens to other requests?
  12. Not answered. How many threads does libuv's thread pool have by default?
  13. Not answered. Which signal asks a container to shut down gracefully?