Google’s Function as a Service (FaaS) offering Cloud Functions now supports minimum ('min') instances. With this new feature, Google aims to take away a well-known friction point of FaaS called "cold-starts".
Last October, the company introduced several new updates to Cloud Functions, including a max-instances feature allowing developers to limit the degree to which their functions will scale in response to incoming requests. Usually, functions scale down to zero after being idle for a while. However, scaling down to zero means it can take a few seconds before the function initializes and starts serving requests. So now Google is introducing min-instances to enable developers to configure several instances for Cloud Functions for low demand periods, thus minimizing cold starts. In addition, charges for idle functions while minimum instances are configured are at a different rate.
Today, a developer can create a function in the Google Console and specify the minimum and the maximum number of instances in the auto-scaling section. Moreover, a developer can also set a minimum instance limit using the gcloud command-line tool. By specifying the minimum number of instances greater than zero, the performance also increases.
Source: https://twitter.com/rtarnec/status/1392882183463919624/photo/1
Vinod Ramachandran, product manager at Google, and Kelsey Hightower, developer advocate at Google, wrote in a Google Cloud blog post:
By specifying a minimum number of instances of your application to keep online during periods of low demand, this new feature can dramatically improve performance for your serverless applications and workflows, minimizing your cold starts.
In addition, a respondent on a Reddit thread about the configuration of the minimum instance wrote:
The model I deployed is just a normal python cloud function with a hugging face model loaded. There is a flask API running in the function, and it returns predictions given a string of text.
Execution times are <300ms, but the cold-starts can take up to 20s, so avoiding them was super important to us.
Other public cloud vendors AWS and Microsoft also have a FaaS offering and deal with cold-starts differently. With AWS Lambda, for instance, developers can leverage the provisioned concurrency feature, while with Azure Functions, they can choose to run Functions in another App Service Plan.
Lastly, guidance, documentation, and pricing of Google Cloud Functions are available on the landing and pricing pages. And for minimum instances, there is a specific tutorial available on GitHub.