I have 2 servers on different geographical locations Singapore and India. 

I need to connect server 1 from a php script at server 2. script looks like this:

```
<?php 

echo microtime(true)."\n";
$con = mysql_pconnect('server1','username','password');

$db = mysql_select_db('database_name',$con);                      

echo microtime(true)."\n";

$q = "select * from tablename where id='35'";
$result = mysql_query($q);

echo microtime(true)."\n";

?>

```

The out put of this script is like this:

```
1373977322.9081
1373977324.377
1373977324.6625

```

As you can see the time between the 2nd and 3rd is around 2 seconds, which means **mysql\_pconnect** is taking more 2 seconds. And time between 3rd and 4th(select query) is very less. 

Also if I run this script on server1 connecting it to server1 itself it takes 20 ms. 

Can't figure out why connection time is soo long. I have also tried some things like **skip-name-resolve** and persistent connections. but :(

How can I debug this thing???