Solutions to MYSQL stress caused by php concurrency

Source: Internet
Author: User
Tags database sharding

On a PHP page, there is a browser count of 200 concurrent queries per second, which causes a lot of pressure on mysql due to insert.

In the lnmp environment, other page content is cached, and there is not much load. This is the browser statistics function, which puts a lot of pressure on mysql. Do you have any solutions?

I don't want to use MySQL to do this. It's not difficult for MySQL to have 200 concurrent queries per second. In addition, Redis and Memcached are used for persistence. The Business Code and O & M deployment volume are not small.

I will give you some suggestions to minimize your O & M deployment and Business Code changes.

You can separate data and do not insert data concurrently in a database. After the split, the query is performed in the slave database (or even in a dedicated distributed system such as Hive). The index can be removed from the master database to improve the insert performance. In this way, the Business Code is almost unchanged (just change the database configuration file ). For MySQL O & M and deployment, you can select a low business point online.

If you can accept a small amount of changes to the Business Code (PHP), there are two suggestions:
1. Database sharding and table sharding. The total amount of data in each table is small, which improves the operation performance, especially for the MyISAM table in the slave database. There may be some queries before you insert them. For example, if the IP address is not in the library, the previous statistics have not been made.
2. Use the HandlerSocket plug-in to bypass SQL Parser and directly operate the stored files. If possible, you can also use bulk insert (batch insert ). MySQL InnoDB also launched InnoDB NoSQL Plugin similar to HandlerSocket, using the memcached protocol to share the InnoDB Buffer, no longer have to worry about how to maintain data consistency before MySQL and Memcached.

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.