I was playing around with ping, seeing if my ping was faster than my screen refresh (it is, sometimes) and I decided to ping localhost.

I run an apache webserver which gives a 403 error on localhost. When I ping it, I get a delay of 0.058 ms. Sometimes it's as high as 0.10 2ms

What does this delay represent - surley my computer to my computer should be instant, and why is there such variation - from 0.027 to 0.102 is almost 400% variation.

  • 2,367
  • 2
  • 16
  • 23
  • If apache isn't configure to respond to localhost, what problem is caused, but what literally is a 0 ms delay? Questions should be practical questions, about problems you actually face, I am not clear on what problem your attempting to solve. – Ramhound Sep 09 '16 at 23:23
  • @Ramhound it is configured to respond - but it's got 3 virtual servers and directory listing is disabled. So localhost does something. – Tim Sep 09 '16 at 23:24
  • I am still not clear what problem 0 ms delay has. If you had a delay greater then 1 ms I can understand the question. – Ramhound Sep 09 '16 at 23:26
  • @Ramhound my reply was not 0, it was 0.1. I'm asking why it is not 0 – Tim Sep 09 '16 at 23:40
  • Because if you send a packet out, and the time it takes to receive a response, is not 0 ms. For the purposes of network latency though, packet response time of less then, is basically 0 ms. – Ramhound Sep 09 '16 at 23:51

2 Answers2


surley my computer to my computer should be instant

0.102ms is the same as 0.102x10^(-3) seconds or 0.000102 seconds. It doesn't get much more "instant" than that.

During this tenth of a thousandth of a second your system has to:

  • read the ICMP echo request from the rxqueue* of the loopback device
  • build a corresponding ICMP echo reply packet
  • write the reply packet to the txqueue* of the loopback interface
  • read the packet back from the rxqueue* for ping to calculate the RTT.

Your concern seems to be that this RTT is not constant. This is explained by the fact that your system is doing a ton other stuff while doing this process.

I run an apache webserver which gives a 403 error on localhost. When I ping it,

If you're using the ping command it doesn't really matter whether you run a webserver or not. If you're using the webserver response time as a "ping" there's quite a few additional layers the packet needs to go through.

(*): this isn't entirely true, any logic below layer 3 is obviously short-circuited, but the point is it will go through the whole stack

  • 1,356
  • 8
  • 13
  • I guess it seems like a long time compared to a 3.2GHz CPU - that CPU could do those actions in about 0.000000003 seconds... 0.1ms on the scale of the CPU feels like a year – Tim Sep 09 '16 at 22:49
  • @Tim it could, if it wasn't doing anything else. Also, it's not only the CPU involved, RAM and its bus should be considered as well. As a side note, I usually do network performance tests on the loopback interface of routers to measure their upper bound: if it's below 1gbps I certainly don't want that router on a 1gbps link. – GnP Sep 09 '16 at 23:13

There are many factor which affect delay other than the physical distance the signal has to travel including:

  • Processing Delay: The time it takes to process the packet to determine where it should be sent or to perform error checking to make sure it hasn't been corrupted in transit. Packets may also be kept in a queue before the CPU is ready to process them.
  • Transmission Delay: The time it takes for the bits of the packet to physically be put "on the wire".
  • Propagation Delay: The transit time of the packet in the network. The speed of light and the material that the packet is travelling through is king here.

ICMP packets are generally seen as low priority and all have to be processed by your systems CPU which is where the variation in the delay is being introduced from.

Mark Riddell
  • 712
  • 4
  • 7
  • 1
    "The speed of light and the material that the packet is travelling through is king here." Yeah, difraction in the kernel's tcp/ip stack is a b**** ;-) – GnP Sep 09 '16 at 21:43