I am now code on Server A, database on Server B.
Accessing server B from Server A will be very slow to get the data.
If you use server A to access server A, the speed is normal.
Is there any way to solve the problem of getting data from cross-server access very slowly?
Reply to discussion (solution)
In what way to access the, paste code
The main problem is the network channel between the two servers.
In what way to access the, paste code
$host = ' Remote server ID address: 3306 '; $root = ' user name '; $pwd = ' password '; $con = @mysql_connect ($host, $root, $pwd); mysql_query ("Set names ' UTF8 '"); @mysql_select_db ("XS", $con) or die (Mysql_error ());
This.
The main problem is the network channel between the two servers.
I this is the server is not a computer room. is a server in two regions, sometimes from server A to Server B to submit data, such as a circular query, sometimes can only query a portion of it, not all are queried.
This is not due to cross-server + cross-region access.
This is the network channel problem. Network poor.
Conditions allow the best to get in a room.
As far as I know, it's all crowded into a room.
Ping the remote server ID, see the delay is not big
Does the database have a reverse resolution for that machine?
This is the network communication problem of two servers, if you are requesting the domain name address, it is recommended to switch to request IP directly, reduce the parsing time
The best database and server do not be too far away, if you really want to separate it, you can use the database cache
Obviously you're using a MySQL database (Oracle, SQL Server) does not appear Zhezhongqingkuang
Because the current MySQL does not support distributed applications
When accessing the database remotely, the slow point is normal. Because there are many network nodes, each node will have a delay
PHP program should use long connection
It's best to do a database mirroring locally
If read frequently, you can read the data to the left layer of cache, such as memcache, can also solve some problems
It's a good idea to do a local data mirroring.
Does the database have a reverse resolution for that machine?
Does turning off DNS reverse resolution cause other problems?
3Q got it. Thank you.