Solve the problem that mysql occupies 100% of cpu resources

Source: Internet
Author: User
Tags what sql


Solve the problem that mysql occupies 100% of cpu resources. A Win2003 server ran a tomcat instance and didn't use nginx as a front-end proxy. This tomcat contains many websites, however, the traffic volume is not very large, and it is basically a concentrated business type. The solution process is actually quite easy. Let's record the ideas here. Www.2cto.com first upgrades the mysql server to the latest version, and tries to avoid mysql problems. In my. ini, configure "slow-query-log = 1slow-query-log-file = slow. log" in "mysqld" to restart mysql. All "slow" logs will be recorded in the log. Www.2cto.com and then when it is slow, you can see what SQL statements have caused the slow problem (slow. log in datadir). Finally, we found that the username in the slow Table query is not indexed and the concurrency is not small, and there is no problem with not much data at the beginning, later, when the data volume reached tens of thousands of times, the number of tables with no indexes found at the same time became a problem. It was terrible to compare strings with tens of thousands of times each time. Adding an index to this field immediately reduces the cpu usage.

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.