1

I'm at an enterprise where there's generally a very fast internet connection, but every time I visit a web page, it takes a really long time. I tried profiling this in the browser, and the only thing it tells me is that the bottleneck is in Waiting (TTFB). This could have something to do with the fact that I use dnsmasq to route me from hostname.dev domains to the appropriate IP addresses, but I wouldn't know where to go about profiling or troubleshooting this part of the connection process. How would I do that?

I'm on Ubuntu 15.04, by the way.

  • What have you already tried? – darnir Jun 18 '15 at 17:45
5

A common bottleneck for slow page load times is often the DNS Resolution. To test the amount of time it requires to resolve the DNS, try using dig(1).

$ dig example.com

This should give you an output along the following lines

; <<>> DiG 9.10.2-P1 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13362
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;example.com.                   IN      A

;; ANSWER SECTION:
example.com.            1       IN      A       93.184.216.34

;; Query time: 3 msec
;; SERVER: 10.0.0.1#53(10.0.0.1)
;; WHEN: Thu Jun 18 23:19:24 IST 2015
;; MSG SIZE  rcvd: 45

See the last section? It shows how much time it took to resolve the DNS. With dnsmasq, I would assume that you'll be on a couple of milliseconds or less.

If you seem good here, time to test the actual network. First check if connecting to the domain isn't taking too much time. You should try to ping the domain and look at the rtt times. If the rtt is too great, then the connection latency is probably your culprit.

$ ping -c 5 example.com

PING example.com (93.184.216.34) 56(84) bytes of data.
64 bytes from 93.184.216.34: icmp_seq=1 ttl=51 time=204 ms
64 bytes from 93.184.216.34: icmp_seq=2 ttl=51 time=205 ms
64 bytes from 93.184.216.34: icmp_seq=3 ttl=51 time=206 ms
64 bytes from 93.184.216.34: icmp_seq=4 ttl=51 time=205 ms
64 bytes from 93.184.216.34: icmp_seq=5 ttl=51 time=205 ms

--- example.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 204.315/205.415/206.755/0.785 ms

If this is one second or more, you've definitely got a connection bottleneck.

In case you see something wrong with the output of ping(1), you can try to profile the connection better using traceroute(1).

The output of traceroute should help you to profile the connection and see which part of the path from your machine to the server is causing the maximum delay.

If the ping output looks good, check if the server is taking too much time to send a response back. Try wget(1)

$ wget -d example.com

DEBUG output created by Wget 1.16.3.60-fd3a-dirty on linux-gnu.

URI encoding = ‘UTF-8’
--2015-06-18 23:27:55--  http://example.com/
Resolving example.com (example.com)... 93.184.216.34, 2606:2800:220:1:248:1893:25c8:1946
Caching example.com => 93.184.216.34 2606:2800:220:1:248:1893:25c8:1946
Connecting to example.com (example.com)|93.184.216.34|:80... connected.
Created socket 4.
Releasing 0x0000000001afc8d0 (new refcount 1).

---request begin---
GET / HTTP/1.1
User-Agent: Wget/1.16.3.60-fd3a-dirty (linux-gnu)
Accept: */*
Accept-Encoding: identity
Host: example.com
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=604800
Content-Type: text/html
Date: Thu, 18 Jun 2015 17:57:56 GMT
Etag: "359670651"
Expires: Thu, 25 Jun 2015 17:57:56 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (ewr/15BD)
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270

---response end---
200 OK
Registered socket 4 for persistent reuse.
Length: 1270 (1.2K) [text/html]
Saving to: ‘index.html’

index.html                            100%[==========================================================================>]   1.24K  --.-KB/s   in 0s

2015-06-18 23:27:56 (197 MB/s) - ‘index.html’ saved [1270/1270]

Does the output pause at any location for a long time? Then that step is definitely what is causing the delays.

  • Thanks! Looks like DNS is probably the culprit, then. My query time is around 3000ms instead of 3. I'll have to look into speeding up dnsmasq or something. – Jonathan Jun 18 '15 at 20:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.