We often encounter performance problems in database management and development, which involves the performance optimization of MySQL. By looking up data on the web and trying my own, I think the following system parameters are more critical:
Key parameter one: Back_log
The number of connections required for MySQL to be available. When the primary MySQL thread gets very many connection requests in a very short time, this works, and then the main thread takes some time (albeit very short) to check the connection and start a new thread.
The Back_log value indicates how many requests can be present in the stack for a short period of time before MySQL temporarily stops answering a new request. Only if you expect to have a lot of connections in a short period of time, you need to increase it, in other words, the size of the listening queue for incoming TCP/IP connections. Your operating system has its own limits on this queue size. Attempting to set a limit of back_log above your operating system will be invalid.
When you look at your host process list, you find a lot of 264084 | Unauthenticated user | xxx.xxx.xxx.xxx | NULL | Connect | NULL | Login | NULL to connect the process, it is necessary to increase the value of Back_log. The default value is 50, I change it to 500.
Key parameter two: Interactive_timeout
The number of seconds the server waits for an action on an interactive connection before shutting it down. An interactive customer is defined as a customer who uses the client_interactive option for Mysql_real_connect (). The default value is 28800, I change it to 7200.
Key parameter three: Key_buffer_size
The index block is buffered and shared by all threads. Key_buffer_size is the buffer size used for the index block, increasing the index (for all reads and multiple writes) that can be better processed, to the extent that you can afford it. If you make it too big, the system will start to change pages and really become slow. The default value is 8388600 (8M), my MySQL host has 2GB memory, so I changed it to 402649088 (400MB).
Key parameter four: Max_connections
The number of simultaneous customers allowed. Increase this value to increase the number of file descriptors required by the mysqld. This number should be increased, otherwise you will often see Too many connections error. The default value is 100, I change it to 1024.
Key parameter five: Record_buffer
Each thread that makes a sequential scan allocates a buffer of that size for each table it scans. If you do a lot of sequential scans, you may want to increase the value. The default value is 131072 (128K), I change it to 16773120 (16M)
Key parameter VI: Sort_buffer
Each thread that needs to be sorted allocates a buffer of that size. Increase this value to accelerate the order by or group by operation. The default value is 2097144 (2M), and I change it to 16777208 (16M).
Key parameter VII: Table_cache
The number of tables opened for all threads. Increasing this value can increase the number of file descriptors required by the mysqld. MySQL requires 2 file descriptors for each unique open table. The default value is 64, I change it to 512.
Key parameter eight: Thread_cache_size
The number of threads that can be reused for saving in. If there is, a new thread is obtained from the cache, and if there is space when disconnected, the customer's line is placed in the cache. If there are many new threads, the value of this variable can be increased in order to improve performance. By comparing the variables of the Connections and threads_created states, you can see the effect of this variable. I set it to 80.
Key parameter IX: Wait_timeout
The number of seconds the server waits for an action on a connection before shutting it down. The default value is 28800, I change it to 7200.
Note: Parameters can be adjusted by modifying the/etc/my.cnf file and restarting the MySQL implementation. This is a relatively cautious work, the above results are just some of my views, you can be based on the hardware of your own host (especially memory size) to further modify.
Original address: http://database.51cto.com/art/200906/132814.htm
Key parameters for MySQL database performance optimization (RPM)