I’m experiencing significant cold start delays for my .NET API hosted on Kubernetes. The first API call to any endpoint takes between 500 to 1000ms, but subsequent requests to the same endpoint take less than 10ms. Other endpoints also respond significantly faster after the initial call.
Details:
-
Environment: .NET API running in Kubernetes
-
Issue: High latency on the first request to any endpoint
-
Expected Performance: First request should be significantly faster, ideally close to subsequent requests
Question:
How can I further reduce the cold start latency of my .NET API on Kubernetes? Are there any best practices or configurations specific to .NET and Kubernetes that can help with this issue?
Thank you for your help!
What I’ve Tried:
-
Readiness Probes: Implementing readiness probes reduced the first call time to around 200-300ms, but this is still too slow for our requirements.
-
Standard Weather API Deployment: We also deployed a standard weather API on our cluster and observed that the first call takes about 40ms, but subsequent requests take less than 1ms.
-
Pod Resource Limits: We tried to manipulate pod resource limits as which had some effect – first call is faster but still significantly slower than fallowing requests
-
Tracing: We used tracing to analyze the execution flow and did not find any particular place that takes up 90% of the time during the cold start.
Dawid is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.