Some weeks ago my app on App Engine just started to increase the number of idle instances to an unreasonable high amount, even when there is close to zero traffic. This of course impacts my bill which is skyrocketing.
My app is simple Node.js application serving a GraphQL API that connects to my CloudSQL database.
Why are all these idle instances being started?
My app.yaml:
runtime: nodejs12
service: default
handlers:
- url: /.*
script: auto
secure: always
redirect_http_response_code: 301
automatic_scaling:
max_idle_instances: 1
Screenshot of monitoring:




This is very strange behavior, as per the documentation it should only temporarily exceed the
max_idle_instances.Some possible solutions:
Confirm in the console that the actual app.yaml configuration is the same as in the app engine console.
Set
min_idle_instancesto 1 andmax_idle_instancesto 2 (temporarily) and redeploy the application. It could be that there is just something wrong on the scaling side, and redeploying the application could solve this.Check your logging (filter app engine) if there is any problem in shutting down the idle instances.
Finally, you could tweak settings like
max_pending_latency. I have seen people build applications that take 2-3 seconds to start up, while the default is 30ms before another instance is being spun up.This post suggests setting the following, which you could try:
Switch to
basic_scaling, let Google determine the best scaling algorithm (last resort option). This would look something like this:The solution could of course also be a combination of 2 and 4.