Distributed and cluster-php Tutorial

Source: Internet
Author: User
Distributed and cluster problems
1: Write a distributed database by yourself. when there are multiple slave databases, how should I select which slave database to query? (The best choice is based on the user's current network)
2: What is the difference between distributed and cluster? I have never understood it. it is best to give a more practical example.
3: insert data from two tables. if mysql tables do not support transactions, how can I ensure consistency?


Reply to discussion (solution)

To put it simply, distributed databases are distributed across different locations, and resources are shared on a unified platform.
As the name suggests, a cluster is a cluster with a large number of database servers for resource sharing. This also has advantages, such as ease of maintenance and so on.

3: insert data from two tables. if mysql tables do not support transactions, how can I ensure consistency?
Self-programmed
1. Insert the first table and save last_insert_id.
2. if Step 1 is successful, insert the second table.
3. if Step 2 fails, delete the record pointed to by last_insert_id from the first table.

To put it simply, distributed databases are distributed across different locations, and resources are shared on a unified platform.
As the name suggests, a cluster is a cluster with a large number of database servers for resource sharing. This also has advantages, such as ease of maintenance and so on.

3: insert data from two tables. if mysql tables do not support transactions, how can I ensure consistency?
Self-programmed
1. Insert the first table and save last_insert_id.
2. if Step 1 is successful, insert the second table.
3. Step 2 failed ,......
Does the distributed architecture have any relationship with the business logic?
For example, can a distributed architecture refer to multiple business logic?
Does a cluster refer to a single business logic?
Thank you very much for thinking about the third method. we can only do that!
What is the answer to the first question?

Does the distributed architecture have any relationship with the business logic?
Of course it is related. it is because of the huge business volume that many database servers need to work together.

One cognition needs to be clarified: the database is a data warehouse, which provides services for multiple users at the same time. The data stored in the database is not necessarily required by your specific business. Just like a parking lot, although the parking lot is full of cars, you only have that car.

Does the distributed architecture have any relationship with the business logic?
Of course it is related. it is because of the huge business volume that many database servers need to work together.

One cognition needs to be clarified: the database is a data warehouse, which provides services for multiple users at the same time. The data stored in the database is not necessarily required by your specific business. Just like a parking lot, although the parking lot is full of cars, you only have that car.
If it is a cluster, after the master-slave database inserts data, they have interfaces for synchronous replication between them. it means. in fact, the data in the database is the same as that in the primary database and will be synchronized in a timely manner?
Isn't that true? Can I query any slave database data? However, it is perfect to choose which database to check and determine the optimal solution based on the user's network.

Does the distributed architecture have any relationship with the business logic?
Of course it is related. it is because of the huge business volume that many database servers need to work together.

One cognition needs to be clarified: the database is a data warehouse, which provides services for multiple users at the same time. The data stored in the database is not necessarily required by your specific business. Just like a parking lot, although the parking lot is full of cars, you only have that car.
There is also the business logic ..
I am not referring to the VP volume or the access volume is huge.
I mean, for example, if the same parameter is included, a will be output this time and B will be output next time. I mean the business logic is different.

Clusters can be understood as a group of people pulling the river together. in many cases, clusters are used in scenarios with high loads or require a large amount of synchronous computing.

Distributed architecture can be understood as a large group of people playing the relay game. There are many people, but the number of people is not necessarily fixed.


Clusters can be understood as a group of people pulling the river together. in many cases, clusters are used in scenarios with high loads or require a large amount of synchronous computing.

Distributed architecture can be understood as a large group of people playing the relay game. There are many people, but the number of people is not necessarily fixed.
Okay. thank you very much.

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.