How fast is 127.0.0.1?

Solution 1:

No all 127.0.0.1 traffic never hits the physical network, it gets processed by a loop back adapter in the kernel.

Solution 2:

You don't mention a particular OS but for most all that happens is that the data travels down the stack until it gets to IP at which point it's pretty much sent back. That's a massive oversimplification but means that the entire process is usually CPU bound so its performance is therefore directly linked to CPU speed plus stack efficiency. In practical terms modern CPUs and OSs should be able to 'bounce' loopback traffic considerably faster than 40Gbps - which is the fastest NIC I think I'm capable of buying today. Hope this helps.


Solution 3:

You may be interested in the "Loopback Fast Path" feature Microsoft added in Windows 8 and Windows Server 2012. See:

http://blogs.technet.com/b/wincat/archive/2012/12/05/fast-tcp-loopback-performance-and-low-latency-with-windows-server-2012-tcp-loopback-fast-path.aspx

It also provides an illustration of the path taken by the loopback with and without the optimization.


Solution 4:

127.0.0.1 is no faster any other local ip. The local ip fast, because it doesn't use physical device and 2-layers.( It never hits your NIC)

iperf -c 109.191.109.xxx 1111 -t 5
iperf: ignoring extra argument -- 1111
------------------------------------------------------------
Client connecting to 109.191.109.241, TCP port 5001
TCP window size: 49.7 KByte (default)
------------------------------------------------------------
[  3] local 109.191.109.xxx port 32840 connected with 109.191.109.xxx port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec  4.72 GBytes  8.12 Gbits/sec

$ iperf -c 127.0.0.1 1111 -t 5
iperf: ignoring extra argument -- 1111
------------------------------------------------------------
Client connecting to 127.0.0.1, TCP port 5001
TCP window size: 49.7 KByte (default)
------------------------------------------------------------
[  3] local 127.0.0.1 port 56482 connected with 127.0.0.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 5.0 sec  4.62 GBytes  7.94 Gbits/sec

Solution 5:

It depends on what OS you're running, but Windows 2000 had a bug in it where requests on the loopback adaptor would be slow. There's some useless trivia for you!

Please see this kb article for more information.