简体   繁体   中英

Extremely long TTFB while debugging app in Visual Studio

I have .NET Core MVC project with Vue.js framework which I got to maintain.

I ran into an issue which is time to full load app when debugging locally in visual studio (via IIS Express). There is several request (to my API controller) for JSON data that takes about 30-40s TTFB which makes full load in about a 1 minute. But when I ran the single request alone, it takes only about 4s to return data. Even a small 7KB png logo take 17s TTFB, but with the same request alone it takes only 4.5s .

I tried all possible solutions I found on Google, MSDN and SO... Visual Studio options shenanigans, PerfView analysis, Excluding and even hiding "node_modules" file from VS, but nothing seems to improve it even a little.

I have also my own training/test Vue.js (little bit less complex) website on the same machine and there is no problem and TTFB is under 1s .

VS Request:

VS要求

Request Alone:

单独要求

I ran into the same problem with uploading photos to the server and TTFB time was so high without any reason (at the time). After digging through similar issues and debugging many times, I have found out that IIS servers do not hold services in the app pool if there is no request lately. In my case it was the only first endpoint called from FE and they were hosted in different docker images. You can check out my questions to see my similar question.

To solve the issue I added health check endpoints to every single service instance just to keep them awake, to not dropped from application pool of IIS. To do that I implemented health check request with 5 min. interval in my .NET Core Gateway project and problems seem to resolved. If you're running your projects on IIS, I would suggest you to do the same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM