Google Cloud Run supports minimum instances - yes!

Share on:

This was one of the features that I was waiting for months. Google Cloud Run is really easy to use, and I consider it production worthy, especially for small projects! Up until now, the scheduled container if it was not accepting any request, it was being suspended (similar to what happens to λ on aws, for those that have played with that stack). Then if new requests were issued, the container would spin up again, but you would have to pay the initialization cost, and the fact that some requests could fail while your container was starting, or deal with retries and idempotency.

I always thought that Google Cloud Run It was standing between the λ/Functions world, and those that still have small services packaged and deployed as containers (coming from Kubernetes or docker).So it really made your life easy if you wanted to spin your small service which was packaged as a docker container but then you had to live with the 'suspension , a behaviour from the λ world / functions world. (See cold starts etc).

This is now resolved. Here is a sample of my gitlab-ci deploy step! Currently, the feature is available under the _beta components of the gcloud cli. In the settings below, I opt for 1 container always running and hard limit of 1 again so that it won't autoscale - since I don't have a lot of traffic!

Make note, that of course there is some extra billing imposed (but is very reasonable).

 1deploy:
 2stage: deploy
 3image: google/cloud-sdk:alpine
 4cache: { }
 5before_script:
 6  - |
 7  gcloud components install beta --quiet
 8  gcloud --quiet components update
 9  gcloud auth activate-service-account --key-file ${SA} --project ${PRJCT}  
10script:
11  - |
12  gcloud beta run deploy $SERVICE_NAME --image ${GCR_IMAGE}:${BUILD_VERSION} \
13  --min-instances=1 \
14  --max-instances=1 \
15  --platform=managed \
16  --region=europe-west1  
17only:
18  - master

Very nice! Keep it up google cloud run!