First request always slow Asp Net Core API RRS feed

All replies

  • Maybe extend the deployment procedure. Add one more step: accessing a function like ‘getversion’ from any browser or with some tool.

    First request probably needs additional time to process the assemblies, initialise some stuffs, etc.

    Friday, May 3, 2019 7:30 PM
  • Hi, 

    I have a WEB API with some GET operations, the problem is each time I deploy to production, first request from each method is always slow compared to the following ones.


    http://localhost/api/getversion delay 1346 ms +/- firts time

    http://localhost/api/getversion delay 70ms next times

    Over internet there is a lot of questions about this, but no answer that work.




    I hope someone can explain the problem and help me to solve it.   My API have a lot of operations Get, Post  and each time I deploy there is a delay in invoking first time those methods.   Some method may delay 6s and next requests 1s is a big difference. 


    First request to any .Net web app on a server will take more time to serve the first request.  There are startup things that get processed, as well as certain things in your code.  After deployment a published app will be compiled by IIS on the first request if any code files were changed.  That is the delay you are seeing.
    Friday, May 3, 2019 8:14 PM
  • From what I understand, the Application Pool must be started, which of course is going to slow things down on first-time execution of the service.  Also if the service sits idle for too long, a timeout, the service is taken out of scope and must be put back into scope when used again. That;s  why there HTTP Keep-Alive.



    If you are using the ADO.NET Entity Framework, then it has cold-query and warm-query that affects first-time execution.


    WebAPI issues can be discussed at the ASP.NET forums.


    • Edited by DA924x Friday, May 3, 2019 8:36 PM
    Friday, May 3, 2019 8:34 PM
  • There is a setting in the newer versions of IIS called start mode which you can set to always running.  
    Saturday, May 4, 2019 10:16 PM
  • Hi JARH000,

    Thank you for posting here.

    Since this thread is related to asp.net core, you could post in the following forum.


    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 6, 2019 1:24 AM