MySQL server process CPU usage 100% solution

Source: Internet
Author: User
Tags mysql connect
There are many friends who use the mysql database server, and we often encounter mysql process CPU usage of 100%. Below I will summarize some solutions.

There are many friends who use the mysql database server, and we often encounter mysql process CPU usage of 100%. Below I will summarize some solutions.

Solution 1, Modify the my. cnf File

Find

Query_cache_size = 0

This is probably the cause of this problem. No query cache is enabled.

(Usually 64 MB cache for 1 GB)

Memory of my server is 4 GB,

Adjusted

The Code is as follows:
Query_cache_size = 256 M

If your system needs a large temporary cache, we can find it again.

The Code is as follows:

Tmp_table_size

Modify My. ini and assign the tmp_table_size value to 200 MB.

System cpu usage 100% troubleshooting

Cause Analysis

The deployed application reports to the master every 30 seconds. Each report creates a connection to mysql. After processing, the mysql connection is closed,
However, after the mysql connection is closed, the tcp resources are not released and remain in the TIME_WAIT status within 2-3 minutes.
During High IO operations, a large number of mysql connections will be created and closed after mysq requests are created. Therefore, there will be more tcp connections than TIME_WAIT.
Eventually lead to new mysql connections, no tcp resources available, and finally mysql connect fail

Possible solutions:

1. Change the application connection mode to a mysql persistent connection for each thread. (Change short connection to persistent connection)
2. Change the disk used by mysql so that it is not deployed on the same physical machine as the application, or use an independent disk.
3. Change item: innodb_flush_log_at_trx_commit = 2

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.