Why is the initial connection time for a HTTP request so long?
Asked Answered
L

3

26

My web app sits behind a Nginx. Occasionally, the loading of my web page takes more than 10 seconds, I used Chrome DevTools to track the timing, and it looks like this: enter image description here

The weird thing is, when the page loads slowly, the initial connection time is always 11 seconds long. And after this slow request, subsequent loading of the same page becomes very fast.

What is the possible problem that cause this?

P.S. If this is caused by a resource limitation on my server, can I see some errors/warnings in some system log?

Lyris answered 20/6, 2016 at 10:5 Comment(4)
I am facing same problem. Do you find out solution to this issue or any log file where I can see the exact issue?Advertent
Hi, anyone able to find the core of the problem? @AdarshTiwariIncinerate
Subsequent loads are most like faster due to caching. Try accessing it via Chrome in incognito mode or disable caching to verify this.Myer
This is almost certainly a DNS issue.Azure
L
16

The initial connection refers to the time taken to perform the initial TCP handshake and negotiating SSL (where applicable). The slowness could be caused by congestion, where the server has hit a limit and can't respond to new connections while existing ones are pending. You could look into some performance enhancements in your Nginx configuration.

Lyle answered 20/6, 2016 at 10:39 Comment(5)
I have gone through all the system tuning items mentioned in Nginx documentation, and the problem is still present.Lyris
If there is congestion caused by resource limitation, is there any log file where I can see the problems?Lyris
@Lyris I'm not too sure of the details in Nginx. It's also quite possible it is caused by something out of your hands. Do you get this problem on other sites at all? Otherwise, it could be a firewall or a router between you and the server.Lyle
@GideonPyzer If the Initial connection is 0 that implies the reuse of existing connection?.Opalopalesce
The SSL negotiation is an extra field in Chrome Dev Tools now. The explanation is good tho, it could even be your providers gear like firewall, ddos protection, ...Jetton
G
3

Use dig command to check you domain name resolution process. if return multi answer section, check these ips is valid.

Guiltless answered 13/8, 2018 at 10:26 Comment(1)
As you can see from the screenshot, DNS resolution is an extra field and does not count to the slow part the OP provides. The only valid problem would be a reverse lookup from the server to the client's IP - that could be slow and would count to the "Initial Connection" timer of the client.Jetton
O
1

Double check your DNS records.

I had this same problem. My issue was with my site's DNS records. I had accidentally added a second 'A' record which pointed to another server of mine in addition to my proper front end server. But both were for the same hostname.

So sometimes my client was trying to connect to the front end and everything worked properly. Other times it was trying to hit the other server and that was causing my 21.07 s delay.

When I deleted the incorrect DNS entry it solved things.

Our answered 23/5 at 3:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.