Tag Archives: asyn­c

Scaling a basic nodejs application using clusters


via Scaling a basic nodejs application using clusters | JavaScript.

Nodejs derives is power from the asyn­chornous nature of javascript. How­ever, the lan­guage also has one major caveat — its sin­gle threaded nature. This directly impacts the scal­a­bil­ity in nodejs appli­ca­tions because if some of your requests con­sume con­sid­er­able proces­sor time then your thread is blocked and wont be able to process other incom­ing requests.

If you have a machine with mul­ti­ple cores, you can take advan­tage of this archi­tec­ture by spawn­ing mul­ti­ple nodejs processes upto as many cpu’s as are avail­able to you such that each of these node processes lis­ten on the same port. Such an arrange­ment is known as a nodejs cluster.