Performance comparison of Node.js fork vs async inside Kubernetes / Docker

10/22/2019
  • Node.js "fork"ed process runs in separated thread
  • Each thread gets separated CPU core
  • If child processes count > CPU cores count then, as far as I understand, 1 CPU core will handle > 1 node.js thread which, of course, has got less performance if compare to 1 core -> 1 thread case.
  • If you use Kubernetes with Docker containers CPU core resource is split for all Docker containers.

Now the question. I can either

  1. Put some hard-weight runtime (not once-executed) logic in the child process. But then count of node.js threads increases by 2 times (don't forget, there is a load balancer that manages containers).
  2. In the other hand, handling this separated logic asynchronously in the main thread saves resources (less parallel CPU processes) but then main node.js process is going to be much slower because count of EventLoop tasks will be much bigger. Which criteria for picking up the forking or async option can you suggest?
-- WeekendMan
docker
kubernetes
load-balancing
node.js

0 Answers