How would you use more than one CPU core in Node?

Node.js basics · Experienced

Model answer

Run several processes: the cluster module, or a process manager such as pm2 in cluster mode, behind a load balancer. For CPU-heavy tasks inside one app use worker threads. Make the app stateless (sessions and caches in Redis or the database) so any process can serve any request.

Learn this topic

What Is Node.js? Install It and Run Your First Script in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions