locked
Performance issue loading pages RRS feed

  • Question

  • We have some mvc applications deployed to Azure App services that display long delays when loading a page for the first time.  I understand that there will be some delay the first time but these applications seem to suffer very badly from it - it can take up to thirty seconds for the first time.  This happens to all pages.  Once a page is loading it will perform fine.

    I also have a feeling that this issue seems to get worse the more times we publish to the site. At one point I deleted the web site entirely - created it again and published anew and it seemed ok.

    We are not using shared/free instances - scaling up has no effect.

    We have also tried monitoring with application insights and it does not come up with any issues. 

    Does anyone have any idea about this?

    Thursday, June 28, 2018 10:00 AM

Answers

  • Here I can suggest you to precompile the views, so App services doesn't have to do that for every view that is needed at the time of the request. Adding the below code, might help you with the issue. Below code can be added to MSBuild arguments, this will start and load MVC faster.

    /p:PrecompileBeforePublish=true /p:UseMerge=true
    /p:SingleAssemblyName=AppCode

    For fixing startup of azure app service, you can refer here.

    -----------------------------------------------------------------------------------------------

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    Friday, June 29, 2018 3:54 AM

All replies

  • This problem occurs usually on the application level because of several reasons:

    a.    network requests taking a long time

    b.    application code or database queries being inefficient

    c.    application using high memory/CPU

    d.    application crashing due to an exception

    You can refer troubleshooting steps here. As you told, even after scaling it’s having the issue, I recommend you to check web app’s logs here.

    Ensure that “Always On” is ON in “web app’s, application settings”, which makes sure that the web app will not be unloaded after its in idle mode.

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here.

    • Proposed as answer by Jitendra.S.Tomar Thursday, June 28, 2018 11:07 AM
    • Unproposed as answer by geetarman Thursday, June 28, 2018 12:32 PM
    Thursday, June 28, 2018 11:07 AM
  • I have looked at all the above and do not see any evidence to suggest it is any of the above.  The delay though appears to be occurring before any of our code is actually exectuted.

    Additionally , I dont seem to get such long delays running the website locally even connecting to the database in Azure!

    Always On is On

    Thursday, June 28, 2018 12:37 PM
  • Here I can suggest you to precompile the views, so App services doesn't have to do that for every view that is needed at the time of the request. Adding the below code, might help you with the issue. Below code can be added to MSBuild arguments, this will start and load MVC faster.

    /p:PrecompileBeforePublish=true /p:UseMerge=true
    /p:SingleAssemblyName=AppCode

    For fixing startup of azure app service, you can refer here.

    -----------------------------------------------------------------------------------------------

    Disclaimer: This response contains a reference to a third-party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.



    Friday, June 29, 2018 3:54 AM
  • Just checking in to see if the above suggestions helped or you need further assistance on this specific issue.
    Monday, July 2, 2018 10:58 AM
  • I seem to remember trying this a while ago and noticed no discernable difference so turned it off.  However, I shall revisit this just in case I did something wrong as the timings suggested in the link seem to match. I will update in the next day or so.

    Thanks

    Monday, July 2, 2018 11:07 AM
  • Just checking in if you have had a chance to see the previous response.
    Wednesday, July 4, 2018 9:43 AM
  • I have completed some tests and i have found that setting the 'Precompile during publishing' has little effect for any of the settings whilst the option 'Allow precompiled site to be updateable' is ticked.

    Unticking 'Allow precompiled site to be updatable' and selecting 'Merge all pages and control output to a single assembly' fixes the issue. Page load for a specific screen is down from 18 seconds to 1-2 seconds.

    I have not yet tried any of the other options.

    If you have an a explanation for the above that would be welcome otherwise I shall have to do some more research.

     
    Wednesday, July 4, 2018 1:34 PM
  • You can look into this SO thread (Precompiling for Deployment and Update), which explains pretty well your scenario. 

    -----------------------------------------------------------------------------------------------

    If this answer was helpful, click “Mark as Answer” or “Up-Vote”. To provide additional feedback on your forum experience, click here.


    Thursday, July 5, 2018 5:00 AM
  • Just checking in to see if the above suggestions helped or you need further assistance on this specific issue.
    Sunday, July 8, 2018 2:07 AM
  • Issue sorted thanks
    Monday, July 9, 2018 7:03 AM
  • Glad to know that issue is resolved.
    Monday, July 9, 2018 7:43 AM