Entity framework very slow to load for first time

后端 未结 3 1471
-上瘾入骨i
-上瘾入骨i 2021-02-10 13:57

I\'m using EF 4 on my web site and have found a very disturbing problem - the first run load time is extremely slow. (about 20-30 seconds). After the first run - it will work re

相关标签:
3条回答
  • 2021-02-10 14:17

    I would do a little more research to identify that it is a EF, DB or IIS. I think IIS looks to be the likely culprit, as @E.J. Brennan stated.

    In IIS I would ensure the IIS application pool has not recycled, while it is normal the frequency can be managed to make it less of an impact on end users. EF is probably not the problem, but the caching in the app or DB could hide an underlying SQL issue. Capture the query and analyze the execution plan to ensure it is optimal.

    Hope this help pinpoint the issue.

    0 讨论(0)
  • 2021-02-10 14:24

    Could be EF, but just as likely could be that your app pool is getting recycled on IIS or a combination.

    If there are going to be slow periods of usage on your website, and you want each page to load fast for a visitor that happens along, in the past I have setup a timed job to hit my website at specific intervals (about 5 minutes worked for me), and that made sure that it was always ready to go when a visitor came along.

    Very easy to do if you have access to a task scheduler.

    0 讨论(0)
  • 2021-02-10 14:26

    I was having this problem as well, I found out that it had to do with a large number of views in my database.

    Performance Considerations (Entity Framework) really helped and the steps for mitigating the impact of generating views brought down a 45-60 second initial load to 3-4 seconds.

    0 讨论(0)
提交回复
热议问题