Cloud Run instances may shutdown at any time

A bit of a surprise for me, I thought I’d note it down. I’ve been using Cloud Run for serverless hosting of containerized apps. The whole experience is really slick. I can provide a source directory for something like a Java app or a nodejs app, and Cloud Run will build the container for me, when I use something like

gcloud run deploy my-service –source . –allow-unauthenticated –region us-west1

You can also set minimum and maximum instances with these options:

–min-instances 1
–min-instances 2

But what is “minimum” anyway? What I did not realize is this fact, taken from the Cloud Run documentation:

For Cloud Run services, an idle instance can be shut down at any time, including instances kept warm via a minimum number of instances.

You have been warned.

What this means to me is, I need to design my services so that they can always start up, and re-configure themselves. Any state they maintain in memory needs to be … persisted somewhere, so that in the case of shutdown and restart, that state can be re-applied.

I should not have been surprised by this.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.