configuration - resource limits for application with php and persistent connections (mysqli)
I am trying to use persistent connections from php (5.3.3) to mysql (5.1.57) for web application on apache (prefork). The connections are working as expected, however mysql opens tons of connections.
My question is how to set proper resource counts (apache processes and db connections) to get the best performance of underlying hardware and eliminate false-proof errors.
If I get this right, an example approach would be:
Determine max total connections count for the application itself (depends on your app) = APP_CONNECTIONS.
Determine how many processes your apache serwer may run (depends on RAM) = SRV_PROCESSES.
Ensure all processes will have the possibility to open connection to DB server - DB_MAX_CONNECTIONS = APP_CONNECTIONS * SRV_PROCESSES.
Finally ensure your mysql configuration is capable of handling calculated DB_MAX_CONNECTIONS (this depends on RAM and settings in my.cnf). If not SRV_PROCESSES should be reduced accordingly.
After setting these values right, it should be possible to take full advantage of persistent connections without the need of setting low wait_count (or other walkarounds like killing old processes and finally hitting errors for some users).
In other words in High Load scenario such app configuration should not fail due to misconfiguration.
What do you think? Is this approach right or am I missing something?
I am trying to use persistent connections from php (5.3.3) to mysql (5.1.57) for web application on apache (prefork). The connections are working as expected, however mysql opens tons of connections.
My question is how to set proper resource counts (apache processes and db connections) to get the best performance of underlying hardware and eliminate false-proof errors.
If I get this right, an example approach would be:
Determine max total connections count for the application itself (depends on your app) = APP_CONNECTIONS.
Determine how many processes your apache serwer may run (depends on RAM) = SRV_PROCESSES.
Ensure all processes will have the possibility to open connection to DB server - DB_MAX_CONNECTIONS = APP_CONNECTIONS * SRV_PROCESSES.
Finally ensure your mysql configuration is capable of handling calculated DB_MAX_CONNECTIONS (this depends on RAM and settings in my.cnf). If not SRV_PROCESSES should be reduced accordingly.
After setting these values right, it should be possible to take full advantage of persistent connections without the need of setting low wait_count (or other walkarounds like killing old processes and finally hitting errors for some users).
In other words in High Load scenario such app configuration should not fail due to misconfiguration.
What do you think? Is this approach right or am I missing something?
No comments:
Post a Comment