Clustering Node.js on Bluemix

Will a Node.js application on Bluemix automatically scale to run on multiple processors, or do I need to implement this myself using the Node Clustering API? And if I use clustering, will there be more than one CPU available?


source to share

2 answers

Short answer: you need to use a cluster node module to make full use of all cores in each instance. Or you can also just increase the number of instances.

Long answer: every instance of your app that you push to bluemix runs in a master container. Resource management is managed by linux groups. The number of cores per instance is not something you can control. After doing a quick test on Bluemix, os.cpus () showed 4 cores. If you want to use all 4 cores in a single Bluemix instance (watch container) of your node.js application, you should use the node cluster module.

Keep in mind that you can also just increase the number of instances (horizontal scaling), which can lead to almost linear results depending on your bottleneck when using external services. Therefore, if you have 3 instances, each of those instances has 4 cores, and the built-in load balancer distributes traffic among the 3 instances.



Rams' hybrid model makes sense. You may want to do some benchmarking to determine how many processes you want to run in one application container. You can use "cf app" to keep track of the CPU usage of each instance of the application under load, and if it is not completely consuming the CPU then it might make sense to call more processes.

However, please note: * The CPU cannot be a bottleneck, in which case spawning more processes in the application container or scaling more instances of the application container will not help; * The more processes you spawn in one container, the more memory it consumes, so make sure you don't spawn too much and exceed the allocated memory number (otherwise the application container will be killed).



All Articles