A DevOps engineer is optimizing a Cloud Run service that experiences cold starts. The service is written in Python and uses several large libraries. Which change is most effective to reduce cold start latency?
Min instances avoid cold starts entirely.
Why this answer
Setting a minimum number of instances (option B) ensures that a baseline of container instances is always warm and ready to serve requests, eliminating cold starts for those instances. Cold starts occur when a new container must be initialized, including loading large Python libraries, which adds significant latency. By keeping a minimum number of instances running, the service avoids the initialization delay for the first request to each instance.
Exam trap
Google Cloud often tests the misconception that increasing CPU or concurrency directly reduces cold start latency, but the key insight is that cold starts are caused by the initialization of new containers, not by processing speed or request handling capacity.
How to eliminate wrong answers
Option A is wrong because increasing the maximum number of concurrent requests per container does not reduce cold start latency; it only allows each container to handle more requests simultaneously, which can improve throughput but does not prevent the initial startup delay. Option C is wrong because setting a longer request timeout does not address cold starts; it only gives the service more time to respond, which might mask latency but does not reduce the initialization time. Option D is wrong because increasing CPU allocation can speed up request processing but does not eliminate the need to load large Python libraries during a cold start; the startup time is dominated by library loading, which is I/O-bound and not significantly improved by more CPU.