The cap theorem and the acid of RDBMS

Source: Internet
Author: User

First, the distributed domain cap theory

The cap theorem refers to the three attributes of consistency (consistent), availability (availability), reliability (partition tolerance partition tolerance) when designing a distributed system, which is also known as the Brewer's theorem. The cap theorem clarifies the limitations of the system that can be implemented by a distributed system, and many distributed systems in the Internet are designed based on the primary satisfaction of usability and partition tolerance.

In a series of research results found that in larger distributed systems, because of network separation, consistency and availability can not be met, which means that these three elements can only be implemented at the same time two, it is impossible to take into account; The requirement to relax consistency increases the availability of the system, and increasing consistency means that the system needs to sacrifice some availability.

Second, the acid of the RDBMS

    • Atomicity (atomicity)

A transaction is a non-divisible unit of work. All operations in the entire transaction, either complete or incomplete, are not likely to stall in one part of the middle. When a transaction has an error during execution, it is rolled back (Rollback) to the state before the transaction started.

    • Consistency (consistency)

The integrity constraints of the database are not compromised until the transaction begins and after the transaction has ended. That is, database transactions cannot break the integrity of relational data and the consistency of business logic.

    • Isolation (Isolation)

An isolated state performs a transaction, and one transaction cannot affect another transaction, making them appear to be the only operations that the system performs within a given time. If there are two transactions that run at the same time and perform the same function, the isolation of the transaction will ensure that every transaction in the system considers only that the transaction is in use by the system. This attribute is sometimes called serialization, and in order to prevent confusion between transactional operations, the request must be serialized or sequenced so that only one request is used for the same data at a time.

    • Persistence (Durability)

After the transaction is completed, the changes made to the database by the firm persist in the database and are not rolled back.

There are two main ways to achieve acid: the first is write ahead logging, which is the way of logging. The second type is shadow paging.

Most Web sites have read-write separations using master-slave replication technology to improve read and write performance and the scalability of reading libraries. Therefore, the database master-slave mode is used when a large number of data operations are performed.

Data writing is responsible for the main database, the data read in by the database is responsible for, can be relatively simple by increasing the scale from the database, but there is no easy way to write data to solve the scale problem.

First, if you want to scale the data write, you can consider the main database from one to two, as a mutual associated replication of the two-yuan primary database use, it is possible to reduce the load per primary database, but the update processing will conflict, may result in inconsistent data, in order to avoid such a problem, Each table request needs to be assigned to the appropriate primary database for processing.

Second, the database can be divided into separate, placed on different database servers, such as the different tables placed on different database servers, database segmentation can reduce the amount of data on each database server, in order to reduce the input of hard disk IO, output processing, to achieve high-speed memory processing. However, because the separate storage words on different server tables can not be join processing, the database segmentation needs to consider these issues in advance, after the database segmentation, if it is necessary to join processing, it must be in the program to associate, this is very difficult.

READ MORE: Data consistency-partition availability-performance--my opinion on the implementation of multi-replica strong synchronous database system

The cap theorem and the acid of RDBMS

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.