Skip to Content
构建可扩展分布式系统:方法与实践
book

构建可扩展分布式系统:方法与实践

by Ian Gorton
May 2024
Intermediate
278 pages
5h 24m
Chinese
China Machine Press
Content preview from 构建可扩展分布式系统:方法与实践
最终一致性
|
189
ly/1ZKIt
)和
Cassandra
根节点
11-4Merkle 树示例
11.5
冲突处理
到目前为止,本章内容一直假设数据库具有某种机制,以用于辨别副本中数据库对象的
最新值。例如,从三个副本读取数据对象时,数据库将能够以某种方式确定哪个副本的
值是最近更新的,并将该值作为查询结果返回。
在无领导系统中,写入操作可以由任何副本处理。两个客户端可以同时更新不同副本上
相同的数据库键。发生这种情况时,应按什么顺序更新对象的值?所有副本中该对象的
最终值应该是多少?你需要某种机制来做出此决定。
11.5.1
最后写入者胜出
决定最终值的一种方法是使用时间戳。为更新请求生成一个时间戳,数据库确保并发写
入发生时,具有最新时间戳的更新成为最终版本。对于数据库来说,这种办法既简单又
快速。
不幸的是,这种方法存在问题。正如我在第
3
章所描述的,机器上的时钟会漂移。一个
节点的时钟可能领先于其他节点,让时间戳变得毫无意义。实际上的更新请求是按什么
顺序发生的?我们无法确定事件的顺序。更新请求由两个或多个独立进程在不同副本上
的同一数据对象执行。这些更新必须被视为同时的或并发的。附加到更新请求的时间戳
只是施加了任意顺序来解决冲突罢了。
 
190
|
11
这样做的结果是,当并发更新发生时最后一个写入者获胜,其他更新将被静默丢弃 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9787111750697