We have high con-current traffic on server setup, when the traffic crossing 100+/sec, we facing the 'too many connections' issue with PHP & MySQL. We have separate AWS nodes for Application(PHP - 5.4.34) and Database(MySQL - 5.5.40).
- In the MySQL we have 3500 max connections limit and also we adjusted the variables in MySQL.
- On the high traffic time, the DB node CPU utilization not exceeds 10% and RAM usage below 4GB. But still we are facing the connections issue with application node.
- Using the MyISAM engine for Database.
- Used the mysql_connect function and closed the connection on every page completion.
- We monitoring the DB with Monyog tool, in that there is no slow queries or queue's.
We googled for the solution, but still we didn't get any valuable solution on the issue.
Edit:
Here are further more details on our server setup, we are using the Apache prefork mpm and current mpm setup below.
StartServers 300
MinSpareServers 300
MaxSpareServers 350
ServerLimit 1000
MaxClients 1000
MaxRequestsPerChild 99999
PHP Configuration:
memory_limit : 2048
max_execution_time : 0
timeout : 15
keep_alive : 0ff
keep_alive_timeout : 5
AWS EC2
App Node :
Core : 8 vCPUs
CPU utilization : 89%
RAM : 2048MB out of 30.5GB
Connection : mysql_connect API
its consume more CPU utilization and low RAM usage.
Edit:(Updates)
We updated the connectivity API to PDO and implemented the changes in the package. With the test run, we found same issue again. With the PDO update, we changed the Apache configuration too.
DB connection error: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '172.31.26.180' (99)