Since about 2 weeks I\'m dealing with one of the weirdest problems in LAMP stack. Long story short randomly connection to MySQL server is failing with error message:
<
I had this problem and solved it using persistent connection mode, which can be activated in mysqli by pre-fixing the database hostname with a 'p:'
$link = mysqli_connect('p:localhost', 'fake_user', 'my_password', 'my_db');
From: http://php.net/manual/en/mysqli.persistconns.php :
The idea behind persistent connections is that a connection between a client process and a database can be reused by a client process, rather than being created and destroyed multiple times. This reduces the overhead of creating fresh connections every time one is required, as unused connections are cached and ready to be reused. ...
To open a persistent connection you must prepend p: to the hostname when connecting.