Adjust the number of concurrent databases in the production environment and the number of concurrent databases in the environment
During development and testing, we often do not care much about the concurrency configuration related to the database, because the system concurrency is not large during development and testing. Therefore, setting these parameters correctly does not affect the result. However, after the production environment is installed, the concurrency of the system is greatly increased, if you do not pay attention to the concurrency configuration of the database, the database will become the final concurrency bottleneck of the system. Based on my concurrent tests in the actual project for a period of time, I found that the number of database concurrency needs to be configured in a few places, I hope to share with you, can take less detoursConcurrent Database Configuration
- View the maximum number of connections of the mysql database server
Show variables like 'max _ connections '; (view the current maximum number of connections) show global status like 'max _ used_connections'; (view the maximum number of connections in the database history)
- Modify mysql configuration file my. cnf
Max_connections = 3000 keep Max_used_connections/max_connections = around 85%
- Modify the configuration of the data source in the program. (This is very important. I forgot to modify the configuration here and only changed the database. As a result, the historical concurrency of the database has been increasing.
No) <property name = "maxActive" value = "500"/> <property name = "maxIdle" value = "10"/> <property name = "initialSize" value = "10" />