Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can a Node.js application deployed as a Cloud Run app take advantage of all the cores available?

We are developing a Node.js application and want to deploy it on Google Cloud Run. From this post I am given to understand that it is not a good idea to use PM2 (even in the form of pm2-runtime) inside a Docker container because by definition a container should only run one process inside it. In that case how does one take advantage of all available cores on a VM? Should I manually use Node.js cluster module in my application or am I over-thinking this - meaning is Cloud Run smart enough to automatically create X containers where X = # of CPU cores on a VM? in that case if i am not mistaken, there is nothing I need to do.

Solved Solved
1 1 979
1 ACCEPTED SOLUTION

Cloud Run is a very managed service, and it takes care of instance scaling and per-instance concurrency without much configuration. If we look at the contract for Cloud Run containers, it’s mentioned that the container may run simultaneously across the available cores allocated to each instance. By default, a single CPU is allocated to each instance, but this can be adjusted up to 8 (preview) or 4 (stable) maximum. 

You can also define how many concurrent requests should each instance handle, which helps reduce the instances created in proportion to any increase in requests to your application.

View solution in original post

1 REPLY 1

Cloud Run is a very managed service, and it takes care of instance scaling and per-instance concurrency without much configuration. If we look at the contract for Cloud Run containers, it’s mentioned that the container may run simultaneously across the available cores allocated to each instance. By default, a single CPU is allocated to each instance, but this can be adjusted up to 8 (preview) or 4 (stable) maximum. 

You can also define how many concurrent requests should each instance handle, which helps reduce the instances created in proportion to any increase in requests to your application.