mysql remotehost localhost

We connect to mysql from php. Normally both php and mysql running in same machine. Sometime mysql running is some othere server. We connect to same server by mysql_connect(‘localhost’,,,,) and mysql_connect(XXXX,,,,) where XXXX may be remote server’s
IP address or remote server URL. My question is there any difference between localhost and remotehost connection? like Speed, performanace, etc.

If the portal has more traffic and lot of heavy transactions are there then, seperating the php and mysql is a good performance optimization. So the apache server’s CPU resource is left to handle php process and free from mysql processings. Mysql load will be handled by another server. So Two CPUs handle php and mysql respectively. Load is distributed. But at the same time mysql should be connected thru LAN or WAN not interenet(http protocol).

Anothere thought for brainstorming is, PHP connects to mysql through Socket or TCP/IP. Socket is faster than TCP/IP-networking. If php and mysql are running in same server then by default socket is used. The keyword ‘localhost’ identified and socket is used. Anything
other than ‘localhost’ TCP/IP is used.

This choice is more of ‘context based decision’ rather than standard solution, which I feel.