What is it
- Angular front-end app served via nginx on the server or cordova on android
- 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
- 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.