About how to operate MYSQL in PHP

Source: Internet
Author: User
Tags php database php mysql database sharding
Regarding the PHP operation of MYSQL, in a website with a large access volume, how can PHP applications operate MYSQL more efficiently, such as query, update, and delete operations. ------ Solution ------------------ read/write splitting. Add cache ------ solution ------------------ plan the key data of the database to a certain scale and database/table sharding... ------ solution ------- about the php mysql operation
On a website with a large traffic volume, how can PHP applications operate MYSQL more efficiently, such as query, update, and delete operations.

------ Solution --------------------
Read/write splitting. Add cache
------ Solution --------------------
It is very important to plan the key data of the database to a certain scale for Database Sharding and table sharding...
------ Solution --------------------
Php database operations are some operations...
More optimization should be performed on database processing.

Put some query results into memcached
Put some results into a temporary table
Put some results into the temporary memory table

Merge repeated queries into one query

....

Too many.
------ Solution --------------------
It is easy to store different tables on different servers, but it is required that they are not checked.

If it is a small number of writes, but the read pressure is huge, the disk speed can not keep up with the network traffic, the master from the separation of read and write.

If the server/master/slave cluster of a table cannot support it, split the table into different machines by hash or segment according to a field.

How to manage these ing relationships, you can create a mysql proxy and so on, it works in the memory, the general pressure is not enough to press it, even if it can die one, it's a big deal to open a few more proxies and then perform load balancing. all database operations are submitted to the proxy, and the SQL command is parsed in the proxy, and the correct forwarding can be done according to the configuration file, under this proxy, you can have a master-slave cluster proxy, depending on the requirements.

If you do not want the proxy to directly write the policy to the program, it is a decision function. it should pass in the SQL command and return the ip address: port of the mysql server that should be requested, put this function in a separate php file, and use the include function for others. This allows you to pull the entire body and it is quite calm.
------ Solution --------------------
Discussion

It is easy to store different tables on different servers, but it is required that they are not checked.

If it is a small number of writes, but the read pressure is huge, the disk speed can not keep up with the network traffic, the master from the separation of read and write.

If the server/master/slave cluster of a table cannot support it, split the table into different machines by hash or segment according to a field.

How to manage these ing relationships, you can create a mysql proxy and so on, it works in the memory, the general pressure is not enough to press it, even if it can die one, big deal, open a few more proxies, and make the negative ......

------ Solution --------------------
Sphindexing + php can be used for queries (sphindexing features: high-speed indexing and high-speed searching)

Baidu or google

Specific reference: http://wenku.baidu.com/view/ff2efb2d647d27284b7351ad.html


------ Solution --------------------
Create a cluster!
------ Solution --------------------
Set mysql as a cluster for master-slave read/write splitting.
If you plan to use a project with a large data volume and require transaction processing or foreign key support,
Then you should use InnoDB directly.
But remember that InnoDB tables require more memory and storage.
------ Solution --------------------
Don't worry about this problem for beginners

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.