Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in AWS by (19.1k points)

Seeing as how the node is single threaded, If I have node server running on an Amazon EC2 instance with 4 EC2 Compute units will it run any faster / handle more load than if I have 2 EC2 Compute units?

Does CPU utilization on Amazon require a program to be multithreaded to fully use all resources?

1 Answer

0 votes
by (44.3k points)

The short answer to your question is that adding additional cores so as to boost your node performance won't work if all you do is write "standard" single threaded javascript (you are going to be bound by a single CPU).

The reason is that node.js uses an event loop for processing, therefore if all you're doing is initiating a single node.js process without anything else, it'll not be multi-threaded and thus not use more than one CPU (core).

However, you can use the node.js cluster API to fork the node process so you can take advantage of multiple CPUs (cores): https://nodejs.org/docs/latest/api/cluster.html. If you write your code that approach, then having additional compute units will assist you.

There is one caveat, in which EC2 compute units are detailed per instance. For some instances, you can get more "compute units" per virtual core. So if you choose an instance that has two compute units per virtual core versus one that has one per core, you will be able to execute node on a CPU that has more compute units. However, it's like after 2 compute units the computing power is split per core which suggests you will not get any benefit from the multiple cores.

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...