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

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

by Ian Gorton
May 2024
Intermediate
278 pages
5h 24m
Chinese
China Machine Press
Content preview from 构建可扩展分布式系统:方法与实践
最终一致性
|
183
论,当我重新加载页面时,会看到自己的评论。而同一时间加载该页面的其他用户不一
定立即看到我的评论。但是,他们最终会看到。
采用领导者
-
追随者副本时,实现读写一致性很简单。对于要求读写一致性的用例,你
只需确保后续读取由领导者副本处理。这样可以保证读取的是最新的数据对象值。
读写一致性的实现因数据库平台而异。
MongoDB
的默认行为是(我将在第
13
章详细
介绍的数据库)通过访问主副本实现
3
。在
Neo4j
集群中(
https://oreil.ly/f7yXy
,所
有写入操作都由领导者处理,领导者异步更新只读的副本。然而,读取操作可能由副
本处理。为了实现读写一致性,任何写入事务都可以请求返回一个唯一标识该更新的
书签
。随后的读取请求将书签传递给
Neo4j
,集群确保只有收到书签事务的副本才能处
理该读取。
1
11.2
可调节一致性
许多最终一致的数据库允许你通过配置选项和
API
参数来定制数据库的最终一致行为,
可以根据用例能容忍的副本最终一致性级别来权衡读写操作的性能。这种方法称为可调
节一致性。
可调节一致性基于要完成数据库请求必须访问的特定副本数。为了解释其工作原理,让
我们定义以下内容:
N
副本总数。
W
向客户端确认更新之前要更新的副本数。
R
返回一个值之前需要读取的副本数。
例如,假设
N
= 3
,并且这是一个无领导者数据库,任何一个副本都可以处理独立的请
求。我们称处理请求的副本为协调器。你可以指定
W
值来调整写入操作性能和不一致窗
口的范围,如以下示例所示:
W
= 3
请求协调器将等待三个副本都更新完成后再向客户端返回成功的结果。 ...
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