Php - Connecting to a remote database is very slow

I have a new VPS server, and I'm trying to connect it to another server from the same provider. When I connect via mysql command line tool, the connection is very fast.

When I use PHP to connect to a remote database, the connection time can take up to 5 seconds. Requests are then completed quickly.

This is not limited to mysql, using file_get_contents () to download a file from any other server gives the same lag. Using wget to get the file does not have this lag.

I have configured DNS queries from PHP using dns_get_record () and they are fast (1-2 milliseconds).

Any thoughts on what in php config might trigger this?

Thank.

+3
source share
2

PHP 5.1.6 PHP 5.2.6, . DNS PHP, 5 :

gethostbyname('example.com')

, IPV6 ( , ), .

+1

, PHP, - CGI. , PHP , .

-. , , PHP , -.

+2

Source: https://habr.com/ru/post/1699309/


All Articles