PHP is accessed across servers and gets very slow data.

Source: Internet
Author: User
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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.