Cloud Run scale-to-zero exhibits latency spikes after idle periods
20K reputation · 19 Sept 2022, 12:15 UTC
Goal: Determine the minimum number of instances (minInstances) to configure for a Cloud Run service handling low‑traffic, sporadic requests so that total compute cost remains low while request latency stays within an acceptable threshold.
Constraints: Cold start latency varies with container image size, language runtime, and VPC connector usage, making the latency impact of setting minInstances = 0 unpredictable. Changing minInstances after deployment creates a new revision and may cause temporary traffic splitting, which can affect latency during rollout. The pricing model charges only for active instance time, so any increase in minInstances raises baseline cost proportionally.
Questions: What minInstances value yields the lowest expected cost for a workload with an average request rate of N per hour? How does the observed distribution of cold start latency influence the threshold at which keeping an instance warm becomes cost‑effective? Which Cloud Monitoring metrics should be tracked to validate that the chosen setting maintains the desired latency‑cost balance over time?