Google Cloud recently introduced startup CPU boost for Cloud Run and Cloud Functions 2nd gen, a new feature that allows developers to significantly reduce the cold start time of Cloud Run and Cloud Functions. The new capability is currently in preview.
With Cloud Run, developers can run their software container applications on Google Cloud's infrastructure and automate various maintenance tasks. Similarly, Cloud Functions allow developers to host software on Google Cloud's infrastructure and automate tasks. Moreover, the Cloud Function became generally available (GA) recently, including several improvements.
Cloud Run and Cloud Function have both been upgraded with a startup CPU boost, which improves the performance of workloads deployed on them by reducing application startup time. Earlier, applications could experience so-called "cold starts" - latency encountered in processing a request due to the startup of a new container instance to serve that request. Hence, Google introduced minimum instances to reduce cold starts. However, as Steren Giannini, group product manager at Google Cloud, explains in a blog post:
Minimum instances can be used to remove the cold-start encountered when going from zero to one instance, but min-instances aren't a solution for all cold-starts as traffic scales out to higher numbers of instances. As part of our continued efforts to give you more control over cold start latency, startup CPU boost can help speed up every cold start.
In addition, Giannini also responded in a tweet on the costs of startup CPU boost and idle instances:
They are complementary: - Min instance is here mainly for the "0->1" case and completely eliminates cold starts - Startup CPU Boost is here for N->N+1 and speeds up cold starts but does not eliminate them. Use both, notably because CPU Boost doesn't impact your bill much.
With startup CPU boost, more CPU is dynamically allocated to a container during startup, allowing it to begin serving requests faster. The company claims that the startup time was cut in half for some workloads they measured with this capability. For Java applications, for instance, Google's internal testers and private preview customers reported:
- up to 50% faster for the Spring PetClinic sample application
- up to 47% faster for a Native Spring w/GraalVM service
- up to 23% faster for a plain Java Cloud Functions
Developers can currently enable startup CPU boost for their existing Cloud Run service with one command (or clicking a checkbox in the console). At the same time, Cloud Functions will use the capability by default.
Lastly, note that 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.