Visual Studio Accessing Remote Data So Slowly That Its Faster to Publish The Site to See Impact of New Code

PostAlmostAnything 1 Reputation point
2021-09-27T04:13:18.487+00:00

I have a serious problem in which my ASP.Net Core web application has some EF queries that run really slowly. This is evident when I login to the live site and every page I load takes a really long time due to something slowing down queries that involve my ApplicationUser class. Normally I try to resolve such things locally before testing them out on the live server, but the remote connection loads so slow that it is much faster to publish the site and see if new code works.

This problem is worst when the site runs locally with the debugger, but its also so slow when the debugger is off that I almost always get a timeout error after I login. I know the database is not the problem because it runs other sites of mine just fine and I can access it remotely using SSMS with no problems. The problems seem to be EF and Visual Studio. I've never bHow can I make Visual Studio load fast enough to work on this problem?

Other observations include that this seems to be primarily a problem with data accessed using c sharp on Razor Pages. I say this because whenever the data is accessed via javascript connecting the a web api controller it loads much faster, almost right away in some case. Why could the same queries accessed via c sharp load much slower?

The final thing I noticed is that if there are a lot of tabs open in any browser then VS runs much slower. I noticed this when I had a bunch of Chrome tabs open and was running the app in Chrome also. I thought the problem was due to the same browser VS uses also doing other stuff, so I decided to use Edge for debugging my app so that the only thing the browser was being used for was the app. Well there still seems to be a huge slowdown if a different browser has a lot of tabs open. Why would having several Chrome tabs open have an extremely negative impact on an app being debugged by VS and running with Edge?

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
694 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,133 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,571 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Bruce Barker 801 Reputation points
    2021-09-27T20:19:44.1+00:00

    its sounds like your developer box is running out of some resource, probably memory (but also check cpu). You should use task manage and the performance tab.


  2. Zhi Lv - MSFT 32,006 Reputation points Microsoft Vendor
    2021-09-29T05:46:09.477+00:00

    Hi @PostAlmostAnything ,

    For the problem of slow EF core query speed, it is best to share the relevant query statement, so that we can know whether the problem is related to it, and then help you modify the query into an efficient query.

    You can refer the following article to detect the performance issues in your EF application, and then create an efficient querying.

    EF core Performance Diagnosis

    EF core Efficient Querying

    For the VS slowly problem, you may have extensions installed that are slowing Visual Studio down. Try to manage extensions to improve performance. And if you're thinking about upgrading your hardware, a solid state drive (SSD) has more effect on performance than additional RAM or a faster CPU.

    More detail information, refer the following articles:

    Optimize Visual Studio performance

    Visual Studio performance tips and tricks

    Besides, as you said, if you open lot of the browser tabs, the VS run much slower. As we all know, using a lot of tabs does noticeably reduce your Internet speed, and the major reason is RAM usage. Each tab requires memory to function properly, and if you run enough tabs, it starts to overwhelm your computer's RAM. This slows down everything on your system, including your browser's ability to speedily navigate the Internet and download pages and files. And it can eat up some of your bandwidth, leaving you with less for other applications and resulting in slower performance. So, please manage your tabs diligently, closing the ones you don't need and bookmarking them if necessary for later retrieval.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion


  3. AgaveJoe 26,181 Reputation points
    2021-10-14T20:38:57.367+00:00

    It's impossible to provide a code review or troubleshoot without code that reproduces the behavior. There are a few things that caught my eye...

    Identity caches the user's roles and claims within an authentication cookie. Can you explain why you are fetching duplicate data when populating the ApplicationUser? Are you reading the user's claims and role from the ApplicaitonUser? Can you explain how security works in your application?

    Also, ApplicationUser has an Images collection. Images can be larger. Is the Image collection populated on every HTTP request? Keep in mind, streaming Images from a database then to a browser could certainly cause poor performance.

    The same idea applies to messages. How and when are messages populated? Do user messages grow over time? What is the average message size?

    Is there any way you can provide insight on how your application works? Maybe place the application on Git?

    Lastly, Visual Studio does not host a web application. IIS Express (or Kestrel) hosts the app. Maybe you are referring to the Visual Studio debugger?