Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"localhost" vs "127.0.0.1" performance

I've setup an XML-RPC server/client communication under Windows. What I've noticed is that if exchanged data volume become huge, there's a difference in starting the server listening on "localhost" vs. "127.0.0.1". If "127.0.0.1" is set, the communication speed is faster than using "localhost". Could somebody explain why? I thought it could be a matter on naming resolving, but....locally too?

like image 486
ABCplus Avatar asked Aug 08 '14 08:08

ABCplus


1 Answers

Every domain name gets resolved. There is no exception to this rule, including with regards to a local site.

When you make a request to localhost, localhost's IP gets resolved by the host file every time it gets requested. In Windows, the host file controls this. But if you make a request to 127.0.0.1, the IP address is already resolved, so any request goes directly to this IP.

like image 139
fatiherdem Avatar answered Sep 17 '22 08:09

fatiherdem