Kubilay Bayraktar
Kubilay Bayraktar

Reputation: 61

High response duration on first request for .net core api on Azure

I have deployed a .Net Core API to Azure as an App Service.
I have set the Always on feature to true.
When I log the requests, I see that Azure Always on requests are coming every 5 minutes.

always on logs

My usage with API is HTTPS but Always on requests are sending with HTTP. I don't know if this is the case

azure vs usage logs

For the first request, it is sometimes 10 seconds, but after the first request, it is around 100ms.

What is missing here?

I have logged the durations: durations

Upvotes: 0

Views: 736

Answers (1)

rickvdbosch
rickvdbosch

Reputation: 15561

There are quite a few reasons why this might be the case:

  1. You're connecting to resources that take time connecting to the first time
  2. Some information is being cached and needs to be read the first time
  3. There is initialization code present
  4. Lazy instantiation of (static/singleton) instances
  5. ... other ...

Add some logging to your application, maybe enable Application Insights if you haven't done so already and go try to find the culprit.

Upvotes: 1

Related Questions