lundi 3 novembre 2014

PHP mysqli_connect cache DNS


Vote count:

0




One PHP script must connect with a remote Mysql erver using a DNS like "slave.domain.com". This DNS is defined in the remote DNS server and tied to 3 differents IPs. Every connection via mysqli_connect("slave.domain.com") always gets the same IP, so it seems there is a kind of cache in some layer (PHP, Zend, MySQL driver for PHP...). Nevertheless using - in the same script - the PHP function gethostbyname() I get different IPs every time I run the script. (ping from console also gets different IPs) Why does mysqli_connect always connect with the same IP? Who is caching the DNS? How can I disable/flush this caching?


(Local) PHP Version: 5.5.9-1 over Ubuntu 14.04 - (Remote) MySQL Version: 5.6 over Ubuntu 14.04


[I know I can solve the problem using mysqli_connect(gethostbyname("slav.domain.com")) but I'd like to know what is happening and who is caching the DNS]



asked 1 min ago







PHP mysqli_connect cache DNS

Aucun commentaire:

Enregistrer un commentaire