Entity framework core 2.1 (code first) slow startup time and first call time RRS feed

  • Question

  • It took 16 sec to startup EF core in Azure function. Database is not big (100 tables). I use code first approach

    I wonder how it could be improved.

    Could you please help to find a right solution.

    Thanks in advance.


    Tuesday, June 18, 2019 8:46 AM

All replies

  • I wonder how it could be improved.

    If you are concerned about speed, then you'll switch to Dapper, a micro ORM.



    Tuesday, June 18, 2019 9:22 AM
  • Its not an issue with EF Core performance. It has to do with Azure Function "cold starts". You can read about it here.


    A simple explanation is that the Azure Functions consumption plan adds and removes instances of the functions host dynamically. This means that when your function is triggered, there might not be an instance available to handle it immediately. If that's the case, a new instance of the functions host is started on demand, resulting in a brief delay before it handles it's first request - this is called a "cold start".

    I would not be doing EF Code First from an Azure Function, if you still want to go down this path - then you will need to look into different options (see below).
    Unrelated to EF Core, there are ways to avoid "cold starts".

    1. You can create a Warm Up Request
    2. Change from a Consumption Plan to an App Service Plan
    3. Use a Premium Plan. A Premium plan would have some dedicated instances that were always on which would eliminate cold starts and could still elastically scale out beyond that in the same way that the consumption plan does.

    william xifaras

    Saturday, July 13, 2019 6:16 PM