简体   繁体   中英

Why Angular app http requests hang after about 20 requests to different ASP.NET Core endpoints are made?

What is it

  1. Angular front-end app served via nginx on the server or cordova on android
  2. ASP.NET Core back-end, which connects to MySQL database via Pomelo connector. On production back-end app is served through nginx reverse proxy.

Problem

Requests sent from the Angular app to api take long time (a minute or more) or completely timeout after around 20-50 requests on production (on my local dev environment with IIS server this may happen a couple times a day, sometimes doesn't happen at all for several days).

Maybe this can give someone a clue. I thought that the problem is with EF queries since I retrieve an entity with its children entities (picture, comments, likes, other business-related entities). But when I close angular app and open again - requests again work fine for the next 20-50 of them.

I also assume that this may be because of DbContext issue, which I was told about by one developer.

Where it happens

Both on the dev and prod environment. However, on production it occurs sooner. The production server has 1GB RAM and relatively slow CPU ($5 Digital Ocean droplet).

What I tried

  1. Rewritten EF queries according to the best practices described here

Filtered back-end out I realized that the bottleneck could be in my RxJs extensions in the Angular app. I checked them and it turned out that notifications polling observable is created every time I navigate to a new route. After 20-50 navigation events there are 20-50 polling requests which block everything. Polling mechanism re-write fixed the issue.

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