Nodejs cluster and auto scaling

234 views
Skip to first unread message

Artem Alekseev

unread,
May 4, 2016, 2:33:48 AM5/4/16
to Google App Engine
Hi, please explain how does autoscaling work for nodejs in app engine?
What if I use kode clustering to apawn workers for each cpu core? Do I need to catch an event from app engine to start spawning more workers?

Nicholas (Google Cloud Support)

unread,
May 4, 2016, 11:59:00 AM5/4/16
to Google App Engine
Thanks for sharing your questions with the community.

With App Engine, NodeJS is run in the flexible environment. If using the NodeJS runtime, An Overview of App Engine is a good starting point that discusses scaling on the platform albeit briefly. The application is run within a Docker container and is replicated to meet demands. Scaling is not handled within the NodeJS application. The application must simply receive requests and send responses. Depending how you configure your Service scaling settings, the application in its entirety will be replicated to handle additional requests if no instances are available. You can also configure Resource settings to specify the cores, memory and disk allocated to each instance.

If the above articles are not helpful, perhaps asking more specific questions or giving some examples of what you intend to implement can help us provide you with more appropriate information.

Hope this helps! 

Artem Alekseev

unread,
May 4, 2016, 12:38:29 PM5/4/16
to Google App Engine
I use node as a TCP server. And also use internal node clustering, so that i have one point of TCP connection (IP,PORT), and node starts workers(separate processes) and balances my TCP requests by sending them to different instances of node processes. Don't I need to use clustering with app engine? And Why.
As I understand now, app engine scales automatically, but nodejs is a single core app, and it needs to use processes ro handle simultanious tasks in more efficient way

Adam (Cloud Platform Support)

unread,
May 7, 2016, 7:30:47 PM5/7/16
to Google App Engine
The VMs running your Node instance are what scales. Autoscaling happens automatically based on the scaling settings you set in your app.yaml - no other configuration is required. When needed, additional virtual machines are created which contain a clone of your application container, and traffic is load balanced between them.

This is completely independent of Node's cluster module which you can still use, although it only makes sense if you use VMs with more than one core. You might see better scaling performance if you use fewer VMs with many cores + cluster than if you use many single core VMs without it, but you may need to tweak your scaling config to find the optimal balance between performance and resource burn.

I would recommend starting with App Engine's automatic scaling configuration, and experimenting with multi core instances later as an optimization step if needed.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages