8
2
I've noticed that pinging by hostname is slower than using the IP address. For example, in the Linux command line:
$ time ping google.com -c 1
PING google.com (150.101.213.160) 56(84) bytes of data.
64 bytes from 150.101.213.160: icmp_seq=1 ttl=61 time=14.4 ms
--- google.com ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 14.425/14.425/14.425/0.000 ms
real 0m5.251s
user 0m0.003s
sys 0m0.005s
$ time ping 150.101.213.160 -c 1
PING 150.101.213.160 (150.101.213.160) 56(84) bytes of data.
64 bytes from 150.101.213.160: icmp_seq=1 ttl=61 time=14.5 ms
--- 150.101.213.160 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 14.537/14.537/14.537/0.000 ms
real 0m0.019s
user 0m0.001s
sys 0m0.004s
I thought at first it was the DNS server taking a while to resolve, but when I ping by hostname, the first line appears almost immediately, showing that the IP address has already been determined. The five-second pause is after this DNS resolution, just before the (first) ping is received.
Are you really worried about a .100 ms rtt difference and a .001 sec system difference? You would need to repeat this test about a tne thousand times to actually determine once is faster then the other. – Ramhound – 2014-05-15T16:41:08.530
@Ramhound No, look at the time at the bottom of the output. It's 5 seconds. – Sparhawk – 2014-05-15T16:42:16.007
You cleared out the DNS cache before each test right? Otherwise your test is invalid. – Ramhound – 2014-05-15T16:44:20.017
@Ramhound I'm not sure how to do that. I did test it several times, but I'm not sure if the cache applies to both types of test. – Sparhawk – 2014-05-15T16:55:32.133
You can clear the dns cache by using
ipconfig
. – Ramhound – 2014-05-15T17:33:08.070@Ramhound I'm running Linux, as per the question. – Sparhawk – 2014-05-16T06:02:45.767