MySQLi抛出mysqli :: __ construct():( 08004/1040):连接太多

MySQLi error 2 Too many connections is thrown on our Centos server.

I am testing the application by simulating a ton of requests from another external server.

In my application, I am creating the connection only once. And then reusing it by passing $glob_conn as a global variable inside functions.


I've checked and tried some suggestions online:

Setting /proc/sys/net/ipv4/tcp_fin_timeout to 3 (from 60)

Then made the connection persistent:

$glob_conn = new mysqli(p:127.0.0.1, config_mysql_db_user, config_mysql_db_password, 'uni_partner');

As you can see there are not many connections waiting:

# netstat -anlp | grep :3306 | grep TIME_WAIT -wc
2

# netstat -anlp | grep :3306 | grep ESTABLISHED -wc
304

All to no avail. When I introduce a lot of clients, the same error is returned.