Long Initial Connection Time

I’m trying to figure out why I keep getting a very long initial connection time on my site. It doesn’t happen all the time, but very frequently.

Test Results on My Site

What does this initial connection time mean? Been optimizing the heck out of my site and server, but this problem won’t go away. What are all the things that could be causing such a long initial connection time? Thanks in advance for any help! Been working at this for months now.

Maybe this will help you out a bit:


Odds are (highly) that your Apache server hit the MaxClients and isn’t able to respond to new connections until some pending requests have been processed. Apache is a pain in the ass to configure well to deal with persistent connections and php. Depending on how you have it configured, it could be using up one of the clients for the duration of a connection, not just when it is responding to actual requests.

If I HAVE to use apache for something these days I will usually put nginx in front of it as a reverse proxy and have it handle the connections and apache only comes into play for responding to individual requests. If I have a choice I usually use Nginx with php-fpm directly and it scales a lot better (at least to my ability to be able to configure things - I’m sure someone somewhere can configure apache just the right way to handle lots of persistent connections for php content but I haven’t seen it yet).

Thank you guys for your response. Turned out that our server was tuned perfectly. There was a problem on the network with our DNS. That was the reason for our long connection time. Thanks again for your help guys!
By the way, here are the results after the fix. :slight_smile: http://www.webpagetest.org/result/130326_F1_1DG9/

Really? In your test results the DNS lookup completes after 24ms. If the problem was with your DNS wouldn’t you expect to see the teal colored bar extend for 20 seconds instead of the orange Initial Connection bar?

As long as the problem has been fixed, that’s great. But for anyone landing in this thread with similar symptoms, take it with a grain of salt.

Yeah, I was wondering the same thing but I was thinking that it might be possible that the server was doing some form of reverse-DNS on inbound connections before accepting them and that THAT might explain the DNS piece that helped but not the site’s DNS itself (just conjecture on my part though).

Hey guys, it turned out that it was actually caused by a wrong entry in our DNS. Our DNS had 1 entry that was correct with the server’s actual IP address, the other entry was an error that had the wrong IP. Deleting that entry did the trick. This problem escaped me for so long b/c I didn’t think to even check the DNS - taking for granted that it would just be correct.

I’m 7 years late but I just wanted to contribute to this answer. In my case, it was also a DNS issue, but not two IPs. I had a url redirect that was conflicting with my a record. So I had:

URL redirect @ www
CNAME www www.myshopify.com
A @ the_shopify_ip

The (namecheap default) URL redirect record created by the system for @ Host with ‘http://www.my_domain.com/’ value was conflicting with my A record configured for the same host
Deleted URL redirect, and that fixed it!

i’m running my test on a private instance for one of our internal web application. Below is my script.
When i run the script in the UI, response time for all pages are good. But if i run the same using the REST API’s with Jmeter, the last step is always taking 30 to 40s to start rendering the first byte.

navigate url
clickAndWait id=logonBtn
setValue id=idToken1 username
setValue id=idToken2 password
clickAndWait id=loginButton_0
navigate https://dev-upm.devops.fds.com/recommendations?enablePfm=true
execAndWait document.getElementById(‘deptDropdown’).getElementsByClassName(‘item’)[2].click();
execAndWait document.getElementsByClassName(‘ag-row’)[12].click();
clickAndWait id=openWorkBookBtn
clickAndWait id=generateManageBtn

Not sure, what am i missing in both the test. Appreciate your help.