Thing to note when deploying NodeJS applications to Elastic Beanstalk

When deploying your NodeJS applications on Elastic Beanstalk, there are a few things that you need to consider. As you may know, NodeJS operates on a single-thread event loop, utilizing non-blocking I/O calls. This means that even if the computer has multiple CPU cores, Node.js does not utilize all of them by default. It only uses one CPU core for the main thread that handles the event loop. For instance, if you have a four-core system Node will only use one of them by default. That’s why we are using services like PM2 or some may manage their own clustering to utilize all cores.

At my new job, while load testing a NodeJS application on Elastic Beanstalk with a 4-core CPU, I noticed that the CPU usage is very low. Upon further exploration, I realized that Elastic Beanstalk does not have a built-in feature like PM2. Instead, you have to manage it yourself by either setting up PM2 or managing your own clustering. This means if you haven’t setup PM2 or clustering even if your application is running with a 4-core CPU, it is only using one core.

The key takeaway from this blog is that if you are using Elastic Beanstalk (EB) to deploy your NodeJS application, you need to set up your own clustering or use PM2 to make use of your computer’s cores.

no responses for Thing to note when deploying NodeJS applications to Elastic Beanstalk

    Leave a Reply