How I fought lags on my website

Overview of the problem and its possible source

It all started innocently enough, I was checking the paginator once again, thinking about how to improve it. And suddenly I was waiting for the page to load for 10 seconds, then 20, then a minute. Surprise, surprise I did not get the response back.
Well, probably screwed up again in a JS file or even worse in Django view. Having done a quick introspection of the code and tested it several times, I did not find any errors.
This suddenly became interesting and f****g depressing _(┐「ε:)_. After all, if the site going to have awesome behavioral factors, I need to fix it. And I began to think what could have happened to the site. There are 4 possible sources of problems:
  • I just have bad internet and poor connection.
  • There are some problems with my website
  • There are some problems with my browser
  • There are some problems with the server
The first option was ruled out, after checking the connection speed and quality, I moved on.

There might be a problem with my site.

The second option had to be sorted out. You see, the delay was not only on the pagination pages, but on the entire site. Even the admin panel experienced delays. What did the usual static pages, the paginator, articles and the django admin panel have in common? Only one thing - models. I thought, hmm ..., maybe I'm somehow making a bad queries? And this option was also out of the question, because I have no influence on how the requests to the database are made from the admin panel.
Then maybe it's the models themselves? I recently changed them a lot and created quite a few migrations. Which of course could have affected the overall speed, but the only way to check this is to delete the entire database and re-fill it again MANUALLY. Yes, of course, it's not that big, 25 articles, 65 definitions, 30 questions, another 20 tools and archives. But damn, I put this option off for later. And judging by the projects I've seen, my 10 migrations are nothing compared to them.
Chevron Fun fact: I found a couple of problems with the paginator during this investigation. For example, I was adding a string and a number where it checked for the need to add a trigger element that would load new posts. How the paginator worked before that, I have no idea (⁄ ⁄•⁄ω⁄•⁄ ⁄)
Chevron Another fun fact: Even though my site wasn't the cause of the latency issues, I tested most of the code for execution time. And where it was very large, I optimized it and made it faster.

Maybe it's a browser problem

The third option was that I had something wrong with my browser. So I switched to Chrome, and believe it or not, it worked. Well..., almost. The lags and delays remained, but Chrome waited and eventually returned the pages I needed. The same thing happened with the admin panel.
stalled request example in chrome
As you can see, Chrome just waited for ten seconds. And in the Chrome documentation it says that the Stalled state means, quote:
Chevron
Chrome documentation
  • There are requests with higher priority.
  • There are already six TCP connections open for this source, which is the limit. Applies to HTTP/1.0 and HTTP/1.1 only.
  • The browser briefly allocates disk cache space.
Now we need to find out what error occurs when trying to reach the server. To do this, we need to dump the network activity during the request to the server. Let's enter chrome://net-export t in the search and we will start recording our dump.
After I caught another stalled request and recorded it, I will need to see the cause. Let's open https://netlog-viewer.appspot.com/#import and go to EVENTS. Find the corresponding event. In my case, it was a request for an article pagination page.
event caused by ERR_HTTP2_PING_FAILED
Another window will open in which you can find a huge jump in time:
an example of work result net dump of chrome
Here you can highlight the error ERR_HTTP2_PING_FAILED . This error says that the "client", that is, the browser, did not wait for a response to the request. So it tried to make another request, and behold, the server responded. And to be sure that this problem is not related to the browser, I also did the following things, which did not help:
  • Updated browsers to the latest versions (I already had them)
  • Cleared cache and cookies
  • Disabled all extensions
  • Disabled experimental feature QUICK ( only for Chrome )
  • Clear DNS cache
You will find a full list of options what could be done in such situation. If, of course, the reason for you is a browser.https://10web.io/blog/resolving-the-err_http2_protocol_error/

Now, it is seems like it is hosting problem

All this left me with the last option, something with the server/hosting provider. But I still didn't find anything. Not in any of the configuration files available to me. And I started thinking about contacting the hosting support service. Although before this step, so as not to blame them in vain, because perhaps I missed something or didn't look closely. It was decided to deploy the site on another hosting and see what would happen there.
Glory to all DNS servers and binary code, it didn't come to this.
Let's go back to the very beginning, where I checked the quality of the Internet. So, I decided to check the IP itself. That is, I’ve change it using VPN. And here it is, without any delays (considering the fact that I use VPN). That is, my IP somehow got into the beget blacklist and now I need to pull it out of there, or just use a proxy to access the site.
This is the small investigation I did. I feel like script kiddy now and a little bit pentester ( ^◡^)

heart
0
3 connected dots
0

Used termins

Related questions