当前位置:网站首页>Consistency under distributed

Consistency under distributed

2022-06-13 07:30:00 Muzijin

Distributed consistency

 Insert picture description here

The core is expandability

Through the service , Storage expansion , To improve the processing capacity of the system

By working with multiple servers , To complete tasks that cannot be completed by a single server

A single point of failure

In traditional architecture , Once a component in the system fails , This will make the whole system inoperable , In a distributed system , A single point does not affect the overall operation

No state

Only stateless services can meet the requirements that part of the machine downtime does not affect all , Demand that can be expanded at any time

CAP theory

A distributed system can only satisfy consistency

c consistency Uniformity

All nodes can see the same data at the same time

That is, after the update operation is completed and returned , The data of all nodes at the same time is completely consistent , It is equivalent to that all nodes have the latest version of data at the same time

Consistency is called atomic objects , Any reading and writing should look atomic Or serial , You can read the front content by writing the back reading , All read and write requests seem to be sorted globally

A Availability Usability

anytime , Reading and writing are successful

That is, the service is always available and normally responding

This can correspond to SLA agreement (N individual 9)

Any non failed node should be returned in a limited time

P Partition Tolerance Zone tolerance

In case of message loss or partition failure of some nodes, the distributed system can still continue to run

In case of network inaccessibility between certain nodes or network partitions , Still able to provide external services to meet the consistency and availability

Allow any number of messages to be lost between nodes , When the network is partitioned , Messages between nodes may be lost completely

CP

Discard availability , Pursue consistency and partition fault tolerance

zooKeeper That is to say CP Uniformity The core algorithm Zab Algorithm

I understand it :zk Adopt master-slave architecture , When the master node hangs up , An election will be held , The system is not available at this time ( Discard availability ), Characteristics of master-slave architecture , The master node data is copied from the node to provide read , Master node Provide write and read , And sending data to the slave node after each write , It is a typical read-write separation ( It meets the requirements of consistency and partition fault tolerance )

AP

Give up strong consistency , The pursuit of partition fault tolerance and availability

The vast majority of distributed architecture choices

Base Theory is also an extension of this foundation

summary

cap The three cannot be satisfied at the same time , Don't waste your energy on how to design a distributed system that meets all three , But to make a choice

It's usually choice AP and CP Strong consistency and final consistency are mentioned here (Base theory )

We often focus on how to maintain relative consistency , Improve system availability

Base theory

Base The theory is Basically Available ( Basic available ) Soft-state( Soft state ) Eventually Consistent ( Final consistency ) Abbreviation

Basic available : No pursuit CAP At any time in , Reading and writing are successful , But the system can basically run , Always provide services , Partial loss of performance is allowed ( The request may be Current limiting , Downgrade )

Soft state : Allow data in the system to have intermediate states , It is considered that this state does not affect the overall availability of the system

Final consistency : Data cannot always be soft , The consistency of a node must be achieved within a time period , Achieve final consistency

( Mention here ) Strong consistency

When the user updates , Any subsequent process access will return the latest updated value , This is the most user-friendly , But according to CAP theory , Need to sacrifice availability

summary

Base Theory abandons strong consistency , The implementation is basically available

Consistency algorithm

paxos:https://juejin.cn/post/6844903621499289613

raft : https://juejin.cn/post/6907151199141625870 Typical middleware : etcd

zab : https://juejin.cn/post/6978751402206052360 Typical middleware : zookeeper

原网站

版权声明
本文为[Muzijin]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270548255557.html