What are clusters and worker threads, and when would you use them?
Worker threads are for when you want to run long-running synchronous tasks, and you don't want to block the event loop. It runs the code in a separate thread, and can communicate the results back to the main thread.
Cluster workers are separate instances of your Node process, which are primarily used for load balancing incoming requests across multiple processes, to take advantage of multi-core processors.
Comments
Post a Comment