Search code examples
google-cloud-platformgoogle-compute-enginegoogle-cloud-run

Cloud Run Web Hosting limitation


I'm considering a cloud run for web hosting rather than a complex compute engine.

I just want to make an api with node.js. I heard that automatic load balancing is also available. If so, is there any problem with concurrent traffic of 1 million people without any configuration? (The database server is somewhere else (which is serverless like cockroachDB)

Or Do I have to configure various complicated settings like aws ec2 or gce?


Solution

  • For such traffic, out of the box configuration must be fine tuned.

    Firstly, the concurrency parameter on Cloud Run. This parameter indicate how many concurrent request can be handle per instance. It's 80 the default value, and you can set up to 1000 concurrent requests per instance.

    Of course, if you handle 1000 concurrent request per instance (or less) you should require more CPU and Memory. You can also play with those parameters

    You also have to change the max instance limit. By default, you are limited to 1000.


    If you set 1000 concurrent requests and 1000 instances, you can handle 1 million of concurrent request.

    However, you don't have a lot of margins, or your instance with 1000 concurrent requests can be struggle even with max CPU and memory.

    You can request more than 1000 instances with a quota increase request.


    You can also optimise differently, especially if your 1 million users aren't in the same country/Google Cloud Region. if so, you can deploy a HTTPS load balancer in front of your cloud run service and deploy it in all the region of your users. (The Cloud Run services deployed in different regions must have the same name).

    Like that, it's not only one service that will have to absorb 1 million of users, but several, in different regions. In addition, the HTTPS load balancer route the request to the closest region and therefore your optimize the latency, and reduce the egress/cross region traffic.