LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-18-2017, 01:30 PM   #1
bmxakias
Member
 
Registered: Jan 2016
Posts: 254

Rep: Reputation: Disabled
Question 127.0.0.1 vs localhost


Hello

Reading on the net i found that localhost (FOR LINUX) it will be a bit faster as it uses sockets but in practice some times it seems 127.0.0.1 to perform better for some users

What do you use on your php config files to connect to the database?

What's your experience about this?

Thank you
 
Old 12-18-2017, 01:38 PM   #2
Timothy Miller
Moderator
 
Registered: Feb 2003
Location: Arizona, USA
Distribution: Debian, EndeavourOS, OpenSUSE, KDE Neon
Posts: 4,003
Blog Entries: 26

Rep: Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521Reputation: 1521
I use localhost, but only because it's easier for me to type, I've never really tested to see a performance difference.
 
Old 12-18-2017, 01:47 PM   #3
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Code:
strace ping -c1 localhost 2>&1 | wc -l
132
strace ping -c1 127.0.0.1 2>&1 | wc -l
88

Last edited by !!!; 12-19-2017 at 03:37 AM.
 
1 members found this post helpful.
Old 12-18-2017, 02:17 PM   #4
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,973

Rep: Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623Reputation: 3623
I too would think that an uncached name would have to look up localhost in hosts file. The faster should usually be proper IP address.
 
Old 12-18-2017, 02:56 PM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Me? I rely on the instructions in /etc/hosts
Code:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
A co-worker has made "adjustments" in the past (using "Poor Man's DNS" for context)
I yell, he cries. I fix.
MTAs complain a lot if there isn't one set.

Good Luck.
 
Old 12-19-2017, 04:06 AM   #6
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,474

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Quote:
Originally Posted by bmxakias View Post
Reading on the net
Always a dangerous thing!
Quote:
Originally Posted by bmxakias View Post
i found that localhost (FOR LINUX) it will be a bit faster as it uses sockets but in practice some times it seems 127.0.0.1 to perform better for some users

What do you use on your php config files to connect to the database?

What's your experience about this?

Thank you
On the VERY RARE occasions where I've had the database on the same server as php/apache I've tended to use localhost.

In general though I tend to split the web and database functionality across multiple virtual servers.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
127.0.0.1 points to localhost Emil M Linux - Networking 2 09-06-2011 03:31 AM
localhost not working but 127.0.0.1 does xeross Linux - Networking 4 10-13-2008 03:30 PM
127.0.0.1 v localhost.localdomain Bill Barrington Linux - Software 2 06-28-2003 07:47 PM
Localhost 127.0.0.1 may be forged ?? Mzee Linux - Networking 14 03-20-2003 01:51 PM
localhost vs computer name vs 127.0.0.1 modeler4547 Linux - General 0 02-26-2003 05:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:07 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration