Link to home
Start Free TrialLog in
Avatar of star6868
star6868

asked on

How to accelerate PHP-mysql persistent connection?

My server IP is '11.0.0.17' (local), with APACHE, PHP, MYSQL

I use following php script for mysql connection:

<?php
//$link = mysql_connect('localhost', 'test', 'password');
$link = mysql_connect('11.0.0.17', 'test', 'password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);

?>

I use mysql_connect, with real IP, prepare for Remote connection, but it seem slow
- If I use command: $link = mysql_connect('localhost', 'test', 'password'); ---> connect very fast, complete immediately!
- But when I use command: $link = mysql_connect('11.0.0.17', 'test', 'password'); ---> connection completed in about 5 seconds. --> very SLOW. (Press F5 to refresh is also slow!)

I also use mysql_pconnect to replace, but it's the same!
How to make connection faster with real IP ?
Avatar of star6868
star6868

ASKER

I want to explain more: when this script run with "'localhost" parameter, it run very fast, but when it run with Real IP, it run slow (take 5 second to complete script)
I need solution for Real IP (remote connection)!

Thanks very much!
ASKER CERTIFIED SOLUTION
Avatar of star6868
star6868

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial