PonyTricks
PonyTricks

Reputation: 1798

Connecting to SQL Server database on same server as website: localhost or ip adress?

This might be a pretty simple question, but if there really is a difference, it can make a huge impact on the performance :)

I have a dedicated server hosting my websites and my MSSQL databases.

So here it goes: Will the performance on the website be better using localhost connecting to the MSSQL database instead of fx. mssql.domain.com (or direct ip adress) ?? :)

Upvotes: 2

Views: 569

Answers (4)

Aditya Naidu
Aditya Naidu

Reputation: 1380

Using either will not make a difference. But localhost is preferable due to the following: 1 if the ip address changes in the future there will be changes to the code/config file

Upvotes: 1

Techboy6601
Techboy6601

Reputation: 120

Localhost is your best bet, because if you use a IP PHP has to start a new thread and stuff. It's also a plus if you have a dynamic IP or have it changed.

Upvotes: 1

Oded
Oded

Reputation: 499142

No difference whatsoever.

So long as the three resolve to the same SQL server instance and use the same route.

Upvotes: 1

Abe Miessler
Abe Miessler

Reputation: 85096

It shouldn't make a difference.

If you have dev/test/prod servers it might make your life easier if you can just specify localhost instead of changing the server name with each new environment, but it won't affect performance.

Upvotes: 1

Related Questions