Will Node.JS deployed on Google CloudRun utilize multiple cores?

Viewed 198

I have a Node.JS app that I've deployed to Google CloudRun. When configuring CloudRun, you can choose how many cores it will use. Since Node.JS is single threaded, is there any advantage of specifying more than 1 core in the CloudRun instance? Will it ever use a second core?

If not, is the best-practice for deploying Node.JS to CloudRun to always use one core, and then let CloudRun scale number of instances based on requests count?

2 Answers

I do not know the answer and I am making educated and experienced assumptions. IMHO yes, multiple cores are a benefit to Cloud Run applications.

  1. Requests can be overlapped, which means that multiple cores could be used if available.

  2. CPU always allocated could take advantage of threading and multiple cores.

How to choose the appropriate CPU allocation

A well-known and respected GDE wrote an article that says yes.

Cloud Run performances with multiple CPUs

Node.js is single-threaded but some libraries are not single-threaded for example crypto module.

So when you execute a function from this module, it will utilize the libuv thread pool and execute the function in parallel.

So yes, Node.js does benefit from multi CPU in Cloud Run.

Related