Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What does the traditional ACID in redis refer to?

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about what the traditional ACID in redis refers to. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

What are traditional ACID?

A (Atomicity) atomicity

C (consistency)

I (Isolation) Independence

D (Durability)

Relational databases follow ACID rules, transactions in English is transaction, and real-world transactions are very similar, it has the following four characteristics:

A (Atomicity) atomicity

  Atomicity is easy to understand, that is, all operations in the transaction are either completed or not done. The condition for the success of the transaction is that all operations in the transaction are successful. As long as one operation fails, the whole transaction fails and needs to be rolled back. For example, bank transfer, from account A to 100 yuan to account B, is divided into two steps: 1) take 100 yuan from account A;2) deposit 100 yuan to account B. These two steps are either completed together or not completed together. If only the first step is completed and the second step fails, the money will be inexplicably less than 100 yuan.

C (Consistency)

  Consistency is also easy to understand, that is, the database should always be in a consistent state, and the operation of transactions will not change the original consistency constraints of the database.

I (Isolation) Independence

  Independence means that concurrent transactions do not affect each other. If one transaction accesses data that is being modified by another transaction, the data it accesses is not affected by the uncommitted transaction as long as the other transaction is not committed. For example, there is an existing transaction that transfers 100 yuan from account A to account B. If this transaction has not been completed, if B queries his own account at this time, he cannot see the newly added 100 yuan.

D (Durability)

Persistence means that once a transaction is committed, its changes will be permanently stored in the database and will not be lost even if there is an outage.

CAP

C:Consistency (strong consistency)

A:Availability

P:Partition tolerance or distributed tolerance

CAP theory means that in distributed storage systems, only the above two points can be realized at most.

Strong consistency: for example, what is on the data is what is. Are all copies of data in a distributed system the same value at the same time? (Equivalent to all nodes accessing the same up-to-date copy of data)

Availability: For example, Taobao Double Eleven cannot be used. Whether the cluster as a whole can still respond to client read and write requests after a part of the nodes in the cluster fails. (High availability for data updates)

Zoning fault tolerance: In practical terms, zoning is equivalent to the time limit requirement for communication. If the system fails to achieve data consistency within the time frame, it means that a partitioning situation has occurred and must choose between C and A for the current operation.

For example: Taobao bags

For strong consistency, we require that the number of likes for this bag is 141, which is absolutely correct. Precise guidance is necessary, but it is difficult to ensure data uniformity at times of high concurrency.

For high availability: There can be weak consistency, such as allowing errors in the number of likes and views, but it cannot cause the website to crash.

Most websites use AP. Weak consistency + high availability

For Nosql, partition tolerance must be achieved, distributed systems may not be in the same city, such as Taobao, content distribution is closest to you. Taobao servers may have servers in Hangzhou, Shanghai and Suzhou.

Because the current network hardware will certainly have problems such as delay and packet loss, partition tolerance is what we must achieve. So we have to balance consistency and availability, and no NoSQL system can guarantee all three.

CA Traditional Oracle Database

AP Choice of most website architectures

CP Redis、Mongodb

Note: trade-offs must be made when it comes to distributed architecture.

Balance consistency and availability. Most web applications don't really need strong consistency. So sacrifice C for P, which is the direction of current distributed database products.

Choice between consistency and availability

  For web 2.0 sites, many of the key features of relational databases are often useless

Database transaction consistency requirements

  Many web real-time systems do not require strict database transactions, and the requirements for read consistency are low, and in some cases, the requirements for write consistency are not high. Allow for final consistency.

Requirements of Write Real-time and Read Real-time of Database

  For relational databases, immediately after inserting a piece of data query, is sure to read out this piece of data, but for many web applications, does not require such a high real-time, for example, after a message posted on Weibo, after a few seconds or even ten seconds, my subscribers see this dynamic is completely acceptable.

Demand for complex SQL queries, especially multi-table associative queries

  Any web system with a large amount of data is very taboo against the association query of multiple large tables, as well as the report query of complex data analysis types, especially SNS type websites. From the perspective of requirements and product design, this situation is avoided. More often than not, it is only a single table primary key query, and a single table simple conditional paging query, and the function of SQL is greatly weakened.

classical CAP graph

The core of CAP theory is that a distributed system can not satisfy consistency, availability and partition fault tolerance at the same time, and can only satisfy two at the same time.

Therefore, according to CAP principle, NoSQL database is divided into three categories: CA principle, CP principle and AP principle:

CA -Single point cluster, a system that satisfies consistency, availability, and is generally less robust in scalability.

CP -A system that satisfies consistency, partition tolerance, and generally performance is not particularly high.

AP -Systems that meet availability, partition tolerance, and generally may have lower consistency requirements.

BASE

BASE is a solution to the problem of availability degradation caused by strong consistency of relational database.

  BASE is actually an abbreviation for the following three terms:

  Basically Available

  soft state (Soft state)

  Finally consistent (Eventually consistent)

The idea is that by relaxing the system's requirement for data consistency at one point in time, the overall scalability and performance of the system will improve. The reason for this is that large systems are often geographically distributed and require extremely high performance. It is impossible to use distributed transactions to achieve these metrics. To obtain these metrics, we must adopt another way to achieve them. BASE is the solution to this problem.

Introduction to Distributed + Cluster

distributed system (distributed system)

It consists of multiple computers and software components that communicate through a computer network (local network or wide area network). Distributed systems are software systems built on networks. Because of the nature of software, distributed systems are highly cohesive and transparent. Thus, the difference between a network and a distributed system lies more in high-level software (especially the operating system) than in hardware. Distributed systems can be applied on different platforms such as PC, workstation, local area network and wide area network.

Briefly:

Distributed: Different service modules (engineering) are deployed on different servers, and they communicate and invoke through RPC/RMI to provide services and collaborate within the group.

Cluster: The same service module is deployed on different servers, and unified scheduling is performed through distributed scheduling software to provide services and access to the outside world.

Thank you for reading! About "what does the traditional ACID in redis refer to respectively" this article is shared here, I hope the above content can be of some help to everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report