0

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:

  1. Readiness Probes: Implementing readiness probes reduced the first call time to around 200-300ms, but this is still too slow for our requirements.

  2. 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.

  3. 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

  4. 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.

1
  • You need Ahead of Time compilation to avoid slow cold starts. Commented Jun 12, 2024 at 11:19

1 Answer 1

0

an alternative to reduce the code start, is to think if you can ajust the IoC to using Lazy at injections, this can save some time on code start, but your app will need more processor time on each request.

See:

That's it. 😉

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.