Help you to quickly optimize your MySQL database performance

Source: Internet
Author: User
Tags connect mysql mysql host thread mysql database

By looking up data on the web and trying it myself, I think the following system parameters are more critical:

(1), Back_log:

Require MySQL to have the number of connections. This works when the main MySQL thread gets a lot of connection requests in a very short time, 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 on the stack within a short time before MySQL temporarily stops answering the new request. Only if you expect to have a lot of connections in a short time, you need to increase it, in other words, this value is the size of the listening queue for incoming TCP/IP connections. Your operating system has its own limits on the size of this queue. Attempting to set Back_log above your operating system will be ineffective.

When you look at your host process list, find a lot of 264084 | Unauthenticated user | xxx.xxx.xxx.xxx | NULL | Connect | NULL | Login | NULL to connect process, it is necessary to increase the value of Back_log. The default value is 50, and I'll change it to 500.

(2), Interactive_timeout:

The number of seconds the server waits for action on an interactive connection before closing it. An interactive customer is defined as a customer who uses the client_interactive option for Mysql_real_connect (). The default value is 28800, and I'll change it to 7200.

(3), Key_buffer_size:

The index block is buffered and is shared by all threads. Key_buffer_size is the size of the buffer used for the index block, adding that it can be better processed by indexing (for all read and multiple writes), to the extent that you can afford that much. If you make it too big, the system will start to change pages and it really slows down. The default value is 8388600 (8M), my MySQL host has 2GB memory, so I changed it to 402649088 (400MB).

(4), Max_connections:

The number of simultaneous customers allowed. Increase this value to increase the number of file descriptors required by mysqld. This number should be increased, otherwise you will often see Too many connections errors. The default value is 100, and I'll change it to 1024.

(5), Record_buffer:

Each thread that carries out a sequential scan assigns a buffer of this size to each table it scans. If you do a lot of sequential scans, you might want to add that value. The default value is 131072 (128K) and I change it to 16773120 (16M)

(6), 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 action. The default value is 2097144 (2M) and I change it to 16777208 (16M).

(7), Table_cache:

The number of tables opened for all threads. Increasing this value can increase the number of file descriptors required by mysqld. MySQL requires 2 file descriptors for each unique open table. The default value is 64, and I'll change it to 512.

(8), Thread_cache_size:

The number of threads stored in that can be reused. If there is, a new thread is obtained from the cache, and if there is space when disconnected, the client's line is placed in the cache. If there are a lot of new threads, in order to improve performance you can have this variable value. By comparing the variables of connections and threads_created states, we can see the effect of this variable. I set it to 80.

(10), Wait_timeout:

The number of seconds the server waits for action on a connection before closing it. The default value is 28800, and I'll change it to 7200.

Note: Parameters can be adjusted by modifying the/etc/my.cnf file and restarting the MySQL implementation. This is a more cautious work, the results above is only a few of my views, you can be based on your own host hardware conditions (especially memory size) to further modify.



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.