目录
正在加载目录…
正在阅读专栏 分布式共识系统专栏 第 38 篇 · 共 59 篇 · 64%

论文:Dynamo:Amazon’s Highly Available Key-value Store

发布于 2026-09-21 10:07 · 最后编辑于 2026-09-21 18:15 · 版本 v2 · 字数 43,506 · 预计阅读 88 分钟 👁 44 次阅读

本篇按 MIT 6.824 Spring 2013 课程资料列出的 Dynamo 论文整理。每一页保留原始 PDF 页面图;页面图是原文排版、Figure、公式、脚注、benchmark 图表和参考文献的原始副本,下面按原页顺序给出中文译文与必要术语说明。

论文:Dynamo:Amazon’s Highly Available Key-value Store

相关文章:6.5840:Lecture 12 Spanner · 论文:The Google File System(GFS) · 论文:Secure Untrusted Data Repository(SUNDR)

TL;DR

  • 目标:为 Amazon 的 core service 提供 always-on 的 highly available key-value store,重点优化 availability、predictable latency、incremental scalability 和 operational simplicity。
  • 核心取舍:Dynamo 在部分 failure scenario 下牺牲 strong consistency,提供 eventual consistency;写入尽量不被拒绝,冲突在 read path 暴露并由 application 或 data store 解决。
  • 数据布局:使用 consistent hashing 和 virtual node 做 partitioning;每个 key 在 N 个 physical node 上复制,并由 preference list 决定 replica 集合。
  • 一致性接口:get 可能返回多个 divergent version;put(key, context, object) 通过 vector clock context 表达因果关系;application 可 merge conflicting version。
  • 故障处理:sloppy quorum、hinted handoff、Merkle-tree anti-entropy、gossip membership、local failure detection 和 cross-datacenter replication 共同维持 availability 与 durability。
  • 可调参数:N 控制 replica 数量,R 是 read quorum,W 是 write quorum;service 可以按 SLA 在 availability、durability、consistency、cost 和 latency 之间调参。

名词解释

名词含义本文对应物
Always writeablefailure 或 concurrent write 下仍尽量接受 writeDynamo 的核心目标
Consistent hashing把 hash space 视为 ring,key 顺时针映射到 nodepartitioning 基础
Virtual node / token一个 physical node 在 ring 上的多个位置均衡 load、支持 heterogeneity
Preference list负责保存某个 key 的 replica 的 ordered listN 个首选 physical node 及其扩展
Vector clock(node, counter) pair 的集合,用于表达 causalityversion conflict 检测
Sloppy quorum选择前 N 个 healthy node,而非严格 ring 上的前 N 个temporary failure 期间继续读写
Hinted handoff暂代 node 保存 replica,目标 node 恢复后归还temporary failure recovery
Anti-entropy后台比较并同步 divergent replicaMerkle tree
Read repairread 返回后顺手修复 stale replicaopportunistic synchronization
Zero-hop DHT每个 node 保持完整 routing view,直接转发 request避免 multi-hop latency tail

目录

章节内容
版本与来源课程版本、PDF、图片与翻译边界
原文页面与逐段翻译16 个 PDF 页面按顺序保留并翻译
机制索引partitioning、versioning、quorum、failure handling 与 lessons
本篇验收页数、图片、图表和覆盖范围检查

版本与来源

  • 论文标题:Dynamo: Amazon’s Highly Available Key-value Store。
  • 作者与机构:Giuseppe DeCandia、Deniz Hastorun、Madan Jampani、Gunavardhan Kakulapati、Avinash Lakshman、Alex Pilchin、Swaminathan Sivasubramanian、Peter Vosshall、Werner Vogels,Amazon.com。
  • 发表信息:SOSP ’07,October 14–17, 2007,Stevenson, Washington, USA。
  • 课程来源:MIT 6.824 Spring 2013 schedule 将本文列为 Lecture 14《Peer-to-peer Systems: Dynamo》的 preparation reading,官方归档路径为 papers/dynamo.pdf。
  • 本地固定文件:source/dynamo.pdf;由于官方归档 PDF 当前返回 403,实际文件来自公开课程镜像 https://www.cl.cam.ac.uk/~ey204/teaching/ACS/R244_2018_2019/aid/amazon-dynamo-sosp2007.pdf,与课程所列 16 页 SOSP’07 版本一致。
  • PDF 固定信息:16 页,每页 612×792 points;SHA-256:5cacd624cd7bfd37e3d22e04d8c2e347a49579d2927dbb06f40a89c0bcd40bd4。
  • 附件处理:每页渲染为 1224×1584 PNG,存放于 assets/37 Dynamo/,正文以 600 宽度嵌入。Figure 1–8、Table 1–2、公式、脚注和 References 由原页图保留。
  • 翻译边界:双栏 PDF 的物理换行不作为语义断句;以标题、段落、列表、协议步骤、公式、图注和表格为最小翻译单元。Dynamo、key-value、consistent hashing、vector clock、quorum、hinted handoff、anti-entropy、read repair 等术语保留 English 或中英并列。

原文页面与逐段翻译

第 1 页:Abstract 与 Introduction(上)

dynamo p01

Dynamo: Amazon’s Highly Available Key-value Store

《Dynamo:Amazon 的高可用 key-value store》;作者为 Giuseppe DeCandia、Deniz Hastorun、Madan Jampani、Gunavardhan Kakulapati、Avinash Lakshman、Alex Pilchin、Swaminathan Sivasubramanian、Peter Vosshall 和 Werner Vogels,Amazon.com。

Abstract

在 Amazon.com 这样的超大规模 e-commerce operation 中,reliability 是最具挑战的问题之一;即使非常短暂的 outage 也会造成显著 financial consequence,并损害 customer trust。Amazon.com platform 为全球许多 website 提供 service,建立在分布于许多 datacenter 的数万台 server 和 network component 之上。在这种规模下,小型和大型 component 持续 failure;面对这些 failure 如何管理 persistent state,决定了 software system 的 reliability 和 scalability。

本文介绍 Dynamo 的 design 与 implementation。Dynamo 是 highly available key-value storage system,Amazon 的一些 core service 使用它获得 always-on experience。为了达到这种 availability,Dynamo 在某些 failure scenario 下牺牲 consistency。它广泛使用 object versioning 和 application-assisted conflict resolution,并以一种新颖的 interface 暴露给 developer。

1 Introduction

Amazon 运行一个 worldwide e-commerce platform,在 peak time 为数千万 customer 提供服务,使用分布于全球多个 datacenter 的数万台 server。Amazon platform 对 performance、reliability 和 efficiency 有严格 operational requirement;为了持续增长,platform 还必须具备很高的 scalability。

Amazon 在运行 platform 的过程中学到的一条经验是:system 的 reliability 和 scalability 取决于 application state 如何管理。Amazon 使用高度 decentralized、loosely coupled、service-oriented architecture,由数百个 service 组成。在这种环境中,特别需要始终可用的 storage technology。例如,即使 disk failure、network route flapping,甚至 tornado 摧毁 datacenter,customer 仍应能够查看和添加 shopping-cart item。因此,负责 shopping cart 的 service 要求 data store 始终可读写,并且 data 能跨多个 datacenter available。

在包含数百万 component 的 infrastructure 中处理 failure,是 Amazon 的常态:任意时刻总会有少量但数量可观的 server 和 network component failure。因此 Amazon software system 必须把 failure handling 当作 normal case,而不能因此降低 availability 或 performance。

为了满足 reliability 和 scaling 需求,Amazon 开发了多种 storage technology;其中最知名的可能是 Amazon Simple Storage Service(Amazon S3)。本文介绍另一种为 Amazon platform 构建的 highly available、scalable distributed data store:Dynamo。

Dynamo 用来管理对 reliability 有极高要求、并且需要精确控制 availability、consistency、cost-effectiveness 和 performance 之间取舍的 service state。Amazon platform 上 application 的 storage requirement 差异很大;其中一部分 application 需要一种足够 flexible 的 storage technology,让 application designer 根据这些 tradeoff 配置 data store,在最具 cost-effectiveness 的前提下取得 high availability 和 guaranteed performance。

Amazon platform 上许多 service 只需要对 data store 做 primary-key access。例如 best-seller list、shopping cart、customer preference、session management、sales rank 和 product catalog 等 service,如果使用 relational database 的常见模式,会带来 inefficiency,并限制 scale 与 availability。Dynamo 提供简单的 primary-key-only interface,满足这类 application。

Dynamo 综合多种已知技术获得 scalability 和 availability:使用 consistent hashing [10] 做 data partitioning 与 replication;使用 object versioning 帮助维护 consistency [12];更新期间通过 quorum-like technique 和 decentralized replica synchronization protocol 维护 replica consistency;并使用 gossip-based distributed failure detection 和 membership protocol。Dynamo 完全 decentralized,几乎不需要人工 administration;storage node 可以加入或离开而无需手工 partitioning 或 redistribution。

第 2 页:Introduction(下)、Background 与 Requirements(上)

dynamo p02

过去一年,Dynamo 成为 Amazon e-commerce platform 多个 core service 的 underlying storage technology。它能高效应对 holiday shopping season 的极端 peak load,期间没有 downtime。例如,维护 shopping cart 的 Shopping Cart Service 在单日处理数千万 request,并完成超过 300 万次 checkout;管理 session state 的 service 同时处理数十万 active session。

本文对 research community 的主要贡献,是评估如何把不同 technique 组合成一个 single highly-available system。它证明 eventually-consistent storage system 可以在 demanding production application 中使用,并展示如何调节这些 technique,以满足 production system 严格的 performance demand。

论文结构如下:第 2 节介绍 background;第 3 节介绍 related work;第 4 节介绍 system design;第 5 节描述 implementation;第 6 节总结 Dynamo 在 production 中运行得到的 experience 与 insight;第 7 节总结全文。由于保护 Amazon business interest 的需要,论文有些地方减少了细节:第 6 节的 intra-/inter-datacenter latency、6.2 节的 absolute request rate、6.3 节的 outage length 与 workload,都以 aggregate measure 而不是 absolute detail 给出。

2 Background

Amazon e-commerce platform 由数百个协同工作的 service 组成,功能从 recommendation、order fulfillment 到 fraud detection 不等。每个 service 都通过 well-defined interface 暴露,并通过 network 访问。它们运行在全球多个 datacenter 的数万台 server 上。一些 service 是 stateless,即聚合其他 service 的 response;另一些是 stateful,即在 persistent store 中保存 state,并通过执行 business logic 产生 response。

传统 production system 通常把 state 存在 relational database 中。但对许多常见的 state persistence pattern 来说,relational database 远非理想 solution。很多 service 只按 primary key 存取 data,并不需要 RDBMS 提供的复杂 query 与 management function。多余的功能需要昂贵 hardware 和高技能 personnel 维护,导致 solution inefficiency。

此外,现有 replication technology 有限,通常选择 consistency 而不是 availability。虽然近年来有许多进展,但 database scale-out 和 smart partitioning for load balancing 仍然不容易。

本文介绍 Dynamo:面向这类重要 service 的 highly available data storage technology。Dynamo 提供简单 key/value interface、high availability、定义清晰的 consistency window、resource efficiency,以及支持 dataset size 和 request rate 增长的简单 scale-out scheme。每个使用 Dynamo 的 service 都运行自己的 Dynamo instance。

2.1 System Assumptions and Requirements

这类 service 的 storage system 具有以下 requirement。

Query Model:只需要对由 key 唯一标识的 data item 做简单 read/write。State 以 binary object,即 blob 的形式保存,每个 blob 有 unique key。Operation 不跨多个 data item,也不需要 relational schema。这是因为相当一部分 Amazon service 可以采用这种简单 query model;Dynamo 面向通常小于 1 MB 的 object。

ACID Properties:ACID(Atomicity、Consistency、Isolation、Durability)保证 database transaction 可靠处理。Amazon experience 表明,提供 ACID guarantee 的 data store 往往 availability 较差,这一点已被 industry 和 academia 广泛承认 [5]。Dynamo 面向可以接受 weaker consistency(ACID 中的 C)以换取 high availability 的 application。Dynamo 不提供 isolation guarantee,只允许 single-key update。

Efficiency:system 必须运行在 commodity hardware infrastructure 上。Amazon platform 的 service 有严格 latency requirement,通常以 latency distribution 的 99.9th percentile 衡量。由于 state access 是 service operation 的关键部分,storage system 必须达到这样的 SLA;service 还必须能配置 Dynamo,使 performance 和 throughput requirement 稳定满足。可调 tradeoff 包括 performance、cost efficiency、availability 和 durability guarantee。

Other Assumptions:Dynamo 只供 Amazon internal service 使用;operation environment 假设 non-hostile,不考虑 authentication 和 authorization 等 security requirement。由于每个 service 使用独立 Dynamo instance,最初设计目标是每个 instance 最多数百个 storage host;后文讨论 scalability limitation 与可能 extension。

第 3 页:SLA、Design Considerations 与 Figure 1

dynamo p03

2.2 Service Level Agreements(SLA)

为了让 application 在 bounded time 内完成功能,platform 的每个 dependency 都必须提供更严格的 bound。Client 和 service 之间签署 SLA,即形式化协商的 contract,约定若干 system characteristic,最重要的是某个 API 的 expected request-rate distribution,以及在该负载下的 expected service latency。例如,简单 SLA 可以要求:peak client load 为每秒 500 request 时,99.9% request 在 300 ms 内得到 response。

在 Amazon 的 decentralized service-oriented infrastructure 中,SLA 非常重要。一个 e-commerce page request 通常需要 rendering engine 向超过 150 个 service 发 request;这些 service 往往还有其他 dependency,因此 application call graph 出现多层并不罕见。为了让 page rendering engine 保持清晰的 page-delivery bound,call chain 中每个 service 都必须遵守自己的 performance contract。

业界形成 performance-oriented SLA 的常见方法,是用 average、median 和 expected variance 描述 performance。但 Amazon 发现,如果目标是让所有 customer 都有良好 experience,而不只是让多数 customer 满意,这些 metric 不够好。例如大量使用 personalization 时,history 较长的 customer 需要更多 processing,影响 distribution 的 high end。基于 mean 或 median 的 SLA 无法约束这一重要 customer segment。

因此 Amazon 用 distribution 的 99.9th percentile 表达和测量 SLA。选择 99.9% 而非更高 percentile,是基于 cost-benefit analysis:再继续提高 percentile 会显著增加成本。Amazon production experience 表明,与基于 mean 或 median 的 SLA 相比,这种方法能带来更好的整体 customer experience。

本文多次引用 99.9th percentile,体现 Amazon 从 customer perspective 对 performance 的持续关注。许多论文报告 average,因此本文在便于比较的地方也给出 average;但 Amazon engineering 和 optimization 并不以 average 为目标。例如 load-balanced selection of write coordinator 就是专门控制 99.9th percentile performance 的 technique。

Storage system 往往是 service SLA 的重要组成部分,尤其当 business logic 较轻时。此时 state management 就是 service SLA 的主要部分。Dynamo 的一项核心 design consideration,是让 service 控制 durability、consistency 等 system property,并自行在 functionality、performance 与 cost-effectiveness 之间做 tradeoff。

2.3 Design Considerations

商业 system 中的 data replication algorithm 通常同步协调 replica,以提供 strongly consistent data-access interface。为得到这种 consistency,它们在 failure scenario 下被迫牺牲 data availability:与其返回不确定是否正确的 answer,不如等到确定正确后再让 data available。早期 replicated database work 已经说明,在可能发生 network failure 时,strong consistency 和 high availability 不能同时实现 [2, 11]。因此,system 与 application 必须理解不同条件下可以获得哪些 property。

对容易发生 server/network failure 的 system,可以采用 optimistic replication 提高 availability:允许 change 在 background 传播,并容忍 concurrent、disconnected work。挑战在于 concurrent change 可能冲突,需要 detection 和 resolution;这又带来两个问题:何时 resolve,以及由谁 resolve。

Dynamo 是 eventually consistent data store,即所有 update 最终都会到达所有 replica。一个重要 design choice 是在 read 还是 write 时处理 update conflict。许多传统 data store 在 write 时 resolve conflict,把 read 保持简单 [7];如果无法联系所有 replica(或 majority),write 可能被拒绝。Dynamo 选择 “always writeable” data store:对于 Amazon 的某些 service,拒绝 customer update 会造成糟糕 experience。例如 shopping-cart service 必须允许 customer 在 network/server failure 中 add/remove item。因此 Dynamo 把 conflict-resolution complexity 推到 read path,确保 write 永不被拒绝。

另一个 design choice 是由谁执行 conflict resolution。Data store 只能使用有限的简单 policy,如 last-write-wins [22];application 了解 data schema,可以选择最符合 client experience 的方法。例如 shopping-cart application 可 merge conflicting version,返回 single unified cart。虽然这种 flexibility 很有价值,但某些 developer 不希望自己写 reconciliation mechanism,于是可把工作下推给 data store,由 data store 使用 last-write-wins 这类简单 policy。

其他重要 design principle 包括:

  • Incremental scalability:一次只扩展一个 storage host(下文称 node),对 operator 和 system 本身的影响都尽量小。
  • Symmetry:每个 node 与 peer 承担相同 responsibility,不设置 distinguished node 或额外 special role。Symmetry 简化 provisioning 和 maintenance。
  • Decentralization:作为 symmetry 的延伸,优先使用 decentralized peer-to-peer technique,而不是 centralized control;后者曾造成 outage。
  • Heterogeneity:利用 infrastructure 的 heterogeneity,让 work distribution 与各 server capability 成比例,以便加入 higher-capacity node 而不必同时升级所有 host。

Figure 1:Service-oriented architecture of Amazon’s platform

原图展示 dynamic web content 由 page rendering component 生成;rendering component 查询多个 service。每个 service 有自己的 state data store,只在 service boundary 内可访问;某些 aggregator service 使用多个 service 产生 composite response,通常 stateless 但大量使用 caching。Figure 1 的完整 architecture 图由页面图保留。

第 4 页:Related Work 与 System Architecture 引入

dynamo p04

3.1 Peer-to-Peer Systems

许多 P2P system 研究过 data storage 与 distribution。第一代 P2P system(如 Freenet、Gnutella)主要用于 file sharing,是 unstructured P2P network:peer 之间 overlay link 任意建立,search query 通常 flooding network,以寻找尽可能多的共享 data 的 peer。

第二代 P2P system 演化为 structured P2P network,使用 globally consistent protocol,让任何 node 都能高效把 search query 路由到拥有目标 data 的 peer。Pastry [16] 和 Chord [20] 使用 routing mechanism,使 query 能在 bounded number of hop 内得到回答。为降低 multi-hop latency,一些 P2P system(如 [14])采用 O(1) routing:每个 peer 本地维护足够 routing information,在 constant hop 内把 data-access request 发到目标 peer。

Oceanstore [9] 和 PAST [17] 等 storage system 建立在这些 routing overlay 上。Oceanstore 提供 global、transactional、persistent storage service,支持 widely replicated data 的 serialized update;为支持 concurrent update 并避免 wide-area lock 的问题,它使用 conflict-resolution-based update model。Oceanstore 通过处理一系列 update、选择它们的 total order,并按该 order atomic apply 来 resolve conflict;它面向 data 被复制在 untrusted infrastructure 上的 environment。相比之下,PAST 在 Pastry 之上提供 persistent immutable object 的简单 abstraction,假设 application 自己在其上构建 mutable file 等 storage semantics。

3.2 Distributed File Systems and Databases

为了 performance、availability 和 durability 分布 data,file-system 和 database community 已进行了大量研究。P2P storage system 通常只提供 flat namespace,而 distributed file system 通常提供 hierarchical namespace。Ficus [15] 和 Coda [19] 复制 file 以获得 high availability,但牺牲 consistency,并用 specialized conflict-resolution procedure 处理 update conflict。Farsite [1] 是不使用 NFS 那样 centralized server 的 distributed file system,通过 replication 获得 high availability 与 scalability。GFS [6] 面向 Google internal application state,使用单一 master 保存 metadata,data 则拆成 chunk 存在 chunkserver。Bayou 是支持 disconnected operation 与 eventual consistency 的 distributed relational database [21]。

Bayou、Coda 和 Ficus 都允许 disconnected operation,能抵御 network partition 与 outage,但 conflict-resolution procedure 不同:Coda/Ficus 在 system level resolve,Bayou 允许 application-level resolution;三者都保证 eventual consistency。Dynamo 类似这些 system,允许 network partition 期间继续 read/write,并使用不同 conflict-resolution mechanism。

FAB [18] 等 distributed block storage system 把 large object 拆成 small block,并以 highly available 方式保存。相比之下,key-value store 更适合 Dynamo 的场景:它面向 small object(小于 1 MB),而且比 block system 更容易按 application 配置。Antiquity [23] 是面向 wide-area、可处理多 server failure 的 distributed storage system,使用 secure log 保护 integrity、在多个 server 复制 log 保证 durability,并使用 Byzantine fault-tolerance protocol 维护 consistency。Dynamo 不关注 data integrity/security,而是为 trusted environment 构建。Bigtable [2] 管理 structured data,维护 sparse multi-dimensional sorted map,并允许 application 按多个 attribute 访问;Dynamo 则面向只需 key/value access、首要目标是 high availability、即使 network/server failure 也不拒绝 update 的 application。

传统 replicated relational database 关注 strong consistency。Strong consistency 给 application writer 带来方便的 programming model,但限制 scalability 和 availability [7];由于通常提供 strong consistency,它们无法处理 network partition。

3.3 Discussion

Dynamo 与上述 decentralized storage system 的差异在于 target requirement:第一,它主要面向 always-writeable storage,failure 或 concurrent write 不应导致 update reject;第二,它运行在 single administrative domain,所有 node 假设 trusted;第三,application 不需要 hierarchical namespace 或 complex relational schema;第四,它服务于 latency-sensitive application,要求至少 99.9% read/write 在几百毫秒内完成。

为满足 strict latency,Dynamo 必须避免把 request 通过多个 node 路由,因为 Chord、Pastry 等 DHT 的 multi-hop routing 会增加 response-time variability,抬高 high percentile latency。Dynamo 可以称为 zero-hop DHT:每个 node 本地维护足够 routing information,直接把 request 路由到目标 node。

4 System Architecture

Production storage system 的 architecture 很复杂。除 data persistence component 外,还需要 scalable/robust 的 load balancing、membership、failure detection、failure recovery、replica synchronization、overload handling、state transfer、concurrency、job scheduling、request marshalling、request routing、monitoring/alarming 和 configuration management。本文不可能详细说明每个 solution,重点放在 Dynamo 的 core distributed-systems technique:partitioning、replication、versioning、membership、failure handling 和 scaling。

第 5 页:Interface、Partitioning 与 Table 1

dynamo p05

Table 1:Dynamo 使用的 technique 与 advantage

ProblemTechniqueAdvantage
PartitioningConsistent hashingIncremental scalability
Write high availabilityVector clock,read 时 reconciliationVersion size 与 update rate 解耦
Temporary failureSloppy quorum、hinted handoffreplica 不可用时仍保持 availability/durability
Permanent failureMerkle-tree anti-entropy后台同步 divergent replica
Membership/failure detectionGossip-based membership 与 failure detection保持 symmetry,不需 centralized registry

4.1 System Interface

Dynamo 通过简单 interface 保存与 key 关联的 object,只暴露 get() 和 put() 两个 operation。get(key) 找到保存该 key 的 object replica,返回 single object,或者返回带 context 的 conflicting object list。put(key, context, object) 根据 key 决定 replica 放置位置,并把 replica 写入 disk。Context 编码 object 的 system metadata,对 caller opaque,包括 object version 等信息;context 与 object 一起保存,system 可据此检查 put request 提供的 context 是否 valid。

Dynamo 把 caller 提供的 key 和 object 都当作 opaque byte array。它对 key 做 MD5 hash,生成 128-bit identifier,用于决定负责该 key 的 storage node。

4.2 Partitioning Algorithm

Dynamo 的关键 design requirement 是 incremental scale-out,因此需要动态地把 data partition 到 storage-host 集合上。Dynamo 使用 consistent hashing:把 hash function 的 output range 看成 fixed circular space,即 ring;最大 hash value 会 wrap 到最小 hash value。每个 node 被分配 ring 中的一个 random value,代表它在 ring 上的位置。

每个 key 对应的 data item 先 hash 到 ring 上一个 position,然后沿 ring 顺时针走,找到 position 大于 item position 的第一个 node;该 node 负责 item。于是每个 node 负责自己与 predecessor node 之间的 ring region。Consistent hashing 的主要优点是 node departure/arrival 只影响 immediate neighbor,其他 node 不受影响。

Figure 2:Partitioning and replication of keys in Dynamo ring

原图展示 ring 上的 node A–G 和 key K;K 位于 range (A, B),节点 B、C、D 保存该 range 的 replica。完整 ring、箭头和区间由页面图保留。

基本 consistent hashing 有两个问题:random position 会导致 data/load non-uniform;它忽略 physical node performance 的 heterogeneity。Dynamo 使用变体:不把 node 映射到 circle 的单一点,而是给每个 node 多个 ring position,即 virtual node。Virtual node 在系统中看起来像单个 node,但一个 physical node 可以负责多个 virtual node;新 node 加入时得到多个 position,称为 token。第 6.2 节讨论如何 fine-tune partitioning scheme。

Virtual node 的优点:node 因 failure 或 maintenance 不可用时,其 load 均匀分散到剩余 node;node 恢复或加入新 node 时,新 node 从其他 available node 各接收大致相等的 load;每个 node 负责的 virtual-node 数量可以按 physical capacity 决定,从而利用 infrastructure heterogeneity。

第 6 页:Replication 与 Data Versioning(上)

dynamo p06

4.3 Replication

为获得 high availability 与 durability,Dynamo 把 data 复制到多个 host。每个 data item 在 N 个 host 上复制,N 是按 instance 配置的参数。每个 key k 被分配给一个 coordinator node;coordinator 负责复制落在自己 range 内的 data item。除在本地保存 key 外,coordinator 还把 key 复制到 ring 上顺时针方向的 N - 1 个 successor node。

因此,一个 node 负责从 ring 上自身开始向前、到第 N 个 predecessor 为止的 region。Figure 2 中,B 除本地保存 key k 外,还把它复制到 C、D;D 保存 (A,B]、(B,C]、(C,D] 三个 range 中的 key。负责保存某个 key 的 node list 称为 preference list。系统设计为让每个 node 都能决定任意 key 的 preference list。为应对 node failure,preference list 包含多于 N 个 node。

使用 virtual node 时,某个 key 的前 N 个 successor position 可能属于少于 N 个 distinct physical node,因为一个 physical node 可能持有多个 position。因此构造 preference list 时要跳过 ring position,确保 list 只包含 distinct physical node。

4.4 Data Versioning

Dynamo 提供 eventual consistency,允许 update asynchronous 地传播到所有 replica。put() 可能在 update 尚未应用到所有 replica 前就返回,因此后续 get() 可能返回没有最新 update 的 object。无 failure 时,update propagation time 有一个 bound;但 server outage 或 network partition 可能使 update 长时间无法到达所有 replica。

Amazon 有一类 application 能容忍这种 inconsistency,并据此构造 operation。例如 shopping cart 要求 “Add to Cart” 永远不能被遗忘或 reject。如果最新 cart state 不 available,user 在旧 version 上做的 change 仍然有意义,应被保留;但它也不能覆盖当前不可用的 state,因为不可用 state 可能包含其他应保留的 change。add to cart 与 delete item from cart 都会转译成 Dynamo put request;当最新 version 不可用时,operation 作用于旧 version,divergent version 以后再 reconcile。

Dynamo 将每次 modification 的结果视为新的 immutable version,并允许同一 object 同时存在多个 version。多数情况下,新 version subsume 旧 version,system 可自动确定 authoritative version,这叫 syntactic reconciliation。但 failure 与 concurrent update 结合时,version 可能 branching,产生 conflicting version;此时 system 无法自动 reconcile,client 必须把多个 evolution branch collapse 成一个,这叫 semantic reconciliation。典型操作是 merge 不同 shopping-cart version。这样可以保证 add operation 不丢失,但 deleted item 可能重新出现。

某些 failure mode 可能导致同一 data 不止两个 version。Network partition 和 node failure 可能产生多个 distinct version sub-history,application 必须明确承认同一 data 可以有多个 version,以免丢失 update。

Dynamo 使用 vector clock [12] 捕获同一 object 不同 version 之间的 causality。Vector clock 是 (node, counter) pair 的 list;每个 object version 对应一个 vector clock。通过比较两个 vector clock,可以判断 version 是 parallel branch 还是存在 causal order:如果第一个 clock 的 counter 对所有 node 都小于等于第二个 clock,则第一个是第二个的 ancestor,可以忘记;否则两个 change 冲突,需要 reconciliation。

当 client 更新 object 时,必须说明它要更新的是哪个 version;方法是把此前 read 得到的 context 传给 put,context 包含 vector-clock information。如果 read 发现多个无法 syntactically reconcile 的 branch,Dynamo 返回所有 leaf object 和对应 version information;使用这个 context 的 update 就被视为已 reconcile divergent version,并把 branch collapse 成新的单一 version。

第 7 页:Vector Clock 示例与 Get/Put

dynamo p07

Figure 3:Version evolution of an object over time

为了说明 vector clock,考虑 Figure 3 的例子。Client 首次写入一个新 object。处理该 key write 的 node Sx 增加自己的 sequence number,生成 data 的 vector clock;此时 system 有 object D1,clock 为 [(Sx, 1)]。

Client 更新 object,假设仍由 Sx 处理;system 得到 D2,clock 为 [(Sx, 2)]。D2 descend from D1,所以会覆盖 D1,但尚未看到 D2 的 replica 可能还保留 D1。Client 再更新一次,改由 Sy 处理,于是得到 D3,clock 为 [(Sx, 2), (Sy, 1)]。

接着,另一个 client 读到 D2 后尝试更新,由 Sz 执行 write。于是产生 D4,它是 D2 的 descendant,clock 为 [(Sx, 2), (Sz, 1)]。知道 D1 或 D2 的 node 收到 D4 后,可以判断 D1、D2 已被覆盖并 garbage collect;但知道 D3 的 node 收到 D4 后发现二者没有 causal relation:D3 和 D4 各自包含对方没有反映的 change。因此两个 version 都必须保留,并在 read 时一起返回给 client 做 semantic reconciliation。

假设某个 client 同时读到 D3、D4,read context 总结两个 clock,为 [(Sx, 2), (Sy, 1), (Sz, 1)]。Client 完成 reconciliation 后,由 Sx coordinate write;Sx 增加自身 sequence number,新的 D5 clock 为 [(Sx, 3), (Sy, 1), (Sz, 1)]。

Vector clock 的一个问题是:如果很多 server coordinate 同一 object 的 write,clock size 可能增长。实践中这通常不严重,因为 write 通常由 preference list 中 top N node 之一处理;但 network partition 或 multiple server failure 可能让不在 top N 的 node 处理 write,导致 vector clock 增长。

因此 Dynamo 限制 vector-clock size:每个 (node, counter) pair 还保存 node 最后更新 data item 的 timestamp;当 pair 数量达到阈值(例如 10)时,删除最老的 pair。这个 truncation 可能降低 reconciliation 效率,因为无法准确推导 descendant relationship;但 production 中尚未出现问题,作者没有进一步研究。

4.5 Execution of get() and put() Operations

任何 Dynamo storage node 都可以接收任意 key 的 client get/put。先假设没有 failure,后文再说明 failure 下的 read/write。

get/put 通过 Amazon infrastructure-specific request-processing framework over HTTP 调用。Client 可选择两种 node-selection strategy:一是经过 generic load balancer,由它根据 load information 选 node;二是使用 partition-aware client library,直接把 request 路由到 coordinator。第一种不要求 application link Dynamo-specific code;第二种跳过 potential forwarding step,latency 更低。

处理 read/write 的 node 称为 coordinator,通常是 preference list top N node 中的第一个。如果 request 经过 load balancer 发送,任意 random node 都可能接收;若它不在 key preference list 的 top N 中,就把 request forward 给 list 中的第一个 node。

Read/write operation 使用 preference list 中前 N 个 healthy node,跳过 down 或 inaccessible node。所有 node healthy 时访问 top N;发生 node failure 或 network partition 时,访问 preference list 中排名较低的 node。

Dynamo 使用类似 quorum system 的 consistency protocol 维护 replica consistency,包含两个 configurable value:R 是成功 read 至少需要参与的 node 数,W 是成功 write 至少需要参与的 node 数。令 R + W > N,得到 quorum-like system。get/put latency 由 R/W 个 replica 中最慢者决定,因此通常把 R、W 配置为小于 N,换取更低 latency。

收到 put() 后,coordinator 为新 version 生成 vector clock,并先本地写入;随后把新 version 和 vector clock 发给 preference list 中最高排名且 reachable 的 N 个 node。至少 W - 1 个 node response 后,write 成功。

收到 get() 后,coordinator 从该 key preference list 中最高排名且 reachable 的 N 个 node 请求所有现存 version,等待 R 个 response。若收集到多个 version,就返回它认为 causally unrelated 的全部 version;这些 divergent version 随后 reconcile,并把覆盖当前 version 的新 version 写回。

第 8 页:Sloppy Quorum、Hinted Handoff 与 Anti-Entropy

dynamo p08

4.6 Handling Failures:Hinted Handoff

如果 Dynamo 使用 traditional quorum,在 server failure 或 network partition 时就会 unavailable;即使在简单 failure 下,durability 也会降低。为此 Dynamo 不强制 strict quorum membership,而使用 sloppy quorum:所有 read/write 都在 preference list 中前 N 个 healthy node 上执行,它们不一定是沿 consistent-hashing ring 遇到的最初 N 个 node。

以 Figure 2 的 N = 3 配置为例:若 node A 在 write 期间 temporarily down/unreachable,本应存于 A 的 replica 改发给 D,以维持 availability 和 durability。发给 D 的 replica metadata 中带有 hint,指出它的 intended recipient 是 A。接收 hinted replica 的 node 把它保存在独立 local database 中,周期性扫描;A 恢复后,D 尝试把 replica 交还 A,传输成功后 D 可以删除本地临时副本,此时 system 中的 replica 总数不减少。

Hinted handoff 确保 temporary node/network failure 不会导致 read/write fail。需要最高 availability 的 application 可以把 W 设为 1:只要 system 中有一个 node 成功把 key durable write 到 local store,write 就接受;只有所有 node 都 unavailable 时才 reject。但多数 Amazon production service 使用更高 W,以满足 durability requirement。

高度 available storage system 必须能处理整个 datacenter failure。Datacenter 可能因 power outage、cooling failure、network failure 或 natural disaster 失效。Dynamo 把同一 object 复制到多个 datacenter;key 的 preference list 会跨 datacenter 分布 storage node。Datacenter 之间由 high-speed network 连接。这样,整个 datacenter failure 也不会造成 data outage。

4.7 Handling Permanent Failures:Replica Synchronization

Hinted handoff 适合 membership churn 较低、node failure 为 transient 的情况。但 hinted replica 可能在交还原 replica 前再次 unavailable。为处理这种情况及其他 durability threat,Dynamo 实现 anti-entropy,即 replica synchronization protocol,使 replica 保持同步。

为快速发现 replica inconsistency、减少传输 data,Dynamo 使用 Merkle tree [13]。Merkle tree 是 hash tree:leaf 是各 key value 的 hash,higher-level parent 是 child hash 的 hash。其主要优点是每条 branch 可以独立检查,不要求 node 下载整个 tree 或 dataset。

若两个 tree 的 root hash 相等,则 leaf value 相等,不需要同步;若 root 不同,说明 replica value 存在差异。Node 可以交换 child hash,递归比较,直到 leaf,最终定位 out-of-sync key。Merkle tree 同时减少 synchronization 需要传输的 data 和 anti-entropy 所需的 disk read。

Dynamo 为每个 node 所保存的每个 key range(即每个 virtual node 覆盖的 key set)维护独立 Merkle tree。两个 node 交换彼此共同持有的 key range 对应的 root;然后使用 tree traversal 找差异并执行 synchronization。缺点是 node join/leave 会改变许多 key range,需要重新计算 tree;第 6.2 节的 refined partitioning scheme 改善了这个问题。

4.8 Membership and Failure Detection

4.8.1 Ring Membership

在 Amazon environment 中,node outage(failure 或 maintenance)常常是 transient 的,可能持续较长时间;outage 很少表示 permanent departure,因此不应立即 rebalance partition assignment 或 repair unreachable replica。相反,manual error 也可能导致新 Dynamo node 被意外启动。因此 Dynamo 使用 explicit mechanism 加入/移除 ring:administrator 通过 command-line tool 或 browser 连接某个 node,发出 join/remove membership change。

处理该 request 的 node 把 membership change 和 issue time 写入 persistent store。Membership change 形成 history,因为 node 可能多次 remove、再 add。Gossip protocol 传播 membership change,并维护 eventually consistent membership view。每个 node 每秒随机联系一个 peer,双方高效 reconcile 持久化的 membership-change history。

Node 第一次启动时,选择 virtual-node token,并把 node 映射到 token set;mapping 持久化在 disk。不同 node 上的 mapping 与 membership history 在同一次 communication exchange 中 reconcile,所以 partitioning/placement information 也通过 gossip 传播;每个 storage node 都知道 peer 所处理的 token range,可以直接把某个 key 的 read/write 转发到正确 node 集合。

第 9 页:External Discovery、Failure Detection、Node Churn 与 Implementation

dynamo p09

4.8.2 External Discovery

前述机制可能暂时形成 logically partitioned ring。例如 administrator 先联系 A,把 A 加入 ring;再联系 B,把 B 加入 ring。A、B 都认为自己是 ring member,却暂时互不知道对方。为避免 logical partition,部分 Dynamo node 充当 seed。Seed 通过 external mechanism 发现,并为所有 node 所知。由于所有 node 最终都会与 seed reconcile membership,logical partition 的可能性很低。Seed 可以来自 static configuration 或 configuration service;通常 seed 本身也是 fully functional ring node。

4.8.3 Failure Detection

Failure detection 用来避免在 get/put、partition transfer 和 hinted-replica transfer 中尝试联系 unreachable peer。对避免 failed communication attempt 来说,purely local 的 failure notion 已足够:A 可以在 B 不回复 A 的 message 时认为 B failed,即使 B 能回复 C。只要 ring 中有稳定的 client request 产生 inter-node communication,B 不回复时 A 会很快发现;A 用 alternate node 服务映射到 B partition 的 request,并周期性重试 B 检查 recovery。

如果两个 node 之间没有 client request 驱动 traffic,它们没有必要知道对方是否 reachable。Decentralized failure detector 用简单 gossip-style protocol 让每个 node 学到其他 node 的 arrival/departure;更详细的 failure-detector accuracy 参数见 [8]。Dynamo 早期设计使用 decentralized failure detector 维护 global failure-state view;后来发现 explicit join/leave 已经足够:permanent addition/removal 由 join/leave 通知,temporary failure 则由各 node 在 forwarding request 时检测。

4.9 Adding/Removing Storage Nodes

加入新 node X 时,给它分配散落在 ring 上的多个 token。对于 X 新负责的每个 key range,原先可能有不超过 N 个 node 负责保存。新 allocation 使部分 old node 不再需要保存这些 key,于是它们把 key transfer 给 X。

例如 Figure 2 中 X 加入 A、B 之间,X 负责 (F,G]、(G,A]、(A,X];B、C、D 不再需要保存这些 range,于是它们向 X offer key,得到确认后转移。移除 node 时,key reallocation 反向执行。Operational experience 表明,这种方法能在 storage node 间均匀分配 key-distribution load,满足 latency requirement 并快速 bootstrap。Source 与 destination 之间增加 confirmation round,可避免同一 key range 重复 transfer。

5 Implementation

每个 Dynamo storage node 有三个主要 software component:request coordination、membership/failure detection 和 local persistence engine,均用 Java 实现。

Local persistence component 支持插拔 storage engine:BDB Transactional Data Store、BDB Java Edition、MySQL,以及带 persistent backing store 的 in-memory buffer。设计 pluggable persistence 的主要原因,是按 application access pattern 选择合适 engine。例如 BDB 适合通常几十 KB 的 object,MySQL 可处理更大 object;application 按 object-size distribution 选择 engine。多数 production instance 使用 BDB Transactional Data Store。

Request coordination 构建在 event-driven messaging substrate 上,message-processing pipeline 分成类似 SEDA [24] 的多个 stage;communication 使用 Java NIO channel。Coordinator 代表 client 执行 read/write:read 从一个或多个 node 收集 data,write 把 data 存到一个或多个 node。

每个 client request 都在接收它的 node 上创建一个 state machine。State machine 负责识别 key 对应 node、发送 request、等待 response、必要时 retry、处理 reply 并包装 client response;每个 instance 只处理一个 client request。

Read state machine 的步骤是:(i) 向 node 发送 read request;(ii) 等待所需 minimum response;(iii) 如果在 time bound 内 reply 太少则 fail;(iv) 收集 data version,决定要返回的 version;(v) 如果启用 versioning,执行 syntactic reconciliation,并生成 opaque write context,该 context 包含 subsume 其余 version 的 vector clock。Failure handling 与 retry state 在原文中省略。

第 10 页:Read Repair、Production Usage 与参数 N/R/W

dynamo p10

Read response 返回 caller 后,state machine 还等待一小段时间接收 outstanding response。如果任何 response 带有 stale version,coordinator 就把最新 version 更新到那些 node;这个过程叫 read repair:它在 opportunistic time 修复漏掉 recent update 的 replica,减轻 anti-entropy protocol 的负担。

Write request 由 preference list top N node 之一 coordinate。理想情况下总由 top N 中第一个 node coordinate,以便在一个位置 serializing all writes;但 object access load 并不均匀,会导致 load imbalance 和 SLA violation。因此允许 top N 中任意 node coordinate write。由于 write 通常紧跟 read,Dynamo 让此前 read response 最快的 node coordinate write;该 node 记录在 request context 中。

这个 optimization 选择刚刚返回被读 data 的 node,提高 read-your-writes consistency 的机会,也降低 request-processing variability,改善 99.9th percentile performance。

6 Experiences & Lessons Learned

Dynamo 被多个 service 以不同 configuration 使用;这些 instance 的 version-reconciliation logic、read/write quorum characteristic 各不相同。主要使用模式如下。

  • Business-logic-specific reconciliation:每个 data object 复制到多个 node;出现 divergent version 时,由 client application 执行 reconciliation。Shopping Cart Service 是代表:business logic merge customer shopping cart 的不同 version。
  • Timestamp-based reconciliation:Dynamo 在出现 divergent version 时使用 timestamp-based last-write-wins,选择 physical timestamp 最大的 object。维护 customer session information 的 service 使用这种模式。
  • High-performance read engine:部分 service read request rate 高、update 很少,把 Dynamo 调成 high-performance read engine,通常设 R = 1、W = N。这样既能 partition/replicate data,获得 incremental scalability,也可把 Dynamo 作为更 heavy backing store 的 authoritative persistence cache;product catalog、promotional item service 属于此类。

Dynamo 的主要优点,是 client application 可以调节 N、R、W,取得所需 performance、availability 和 durability。N 决定 object durability;Dynamo user 常用 N = 3。W、R 影响 availability、durability 和 consistency:若 W = 1,只要至少一个 node 能成功处理 write,system 就不会 reject;但较低的 W/R 会提高 inconsistency risk,因为 write 即使未在多数 replica 上处理也可能成功返回,并产生 durability vulnerability window。

Figure 4 与 Figure 5

Figure 4 展示 2006 年 12 月 peak request season 中 read/write 的 average 与 99.9th-percentile latency;latency 随 request rate 呈 diurnal pattern,99.9th percentile 约比 average 高一个数量级。Figure 5 比较 24 小时内 buffered 与 non-buffered write 的 99.9th-percentile latency;完整图表、坐标和曲线由原页图保留。

第 11 页:Performance、Durability 与 Load Distribution

dynamo p11

传统观点认为 durability 与 availability 总是同向;但 Dynamo 中未必如此。例如,提高 W 可以缩小 durability vulnerability window,却可能因为需要更多 storage host alive 而提高 reject probability,降低 availability。

若干 Dynamo instance 使用的 common (N,R,W) configuration 是 (3,2,2),以满足 performance、durability、consistency 和 availability SLA。本节 measurement 来自 live system:配置 (3,2,2),数百个 homogeneous hardware node,分布在多个 datacenter。Successful get(或 put)分别需要 R(或 W)个 node 向 coordinator response,因此 inter-datacenter network latency 会影响 response time;node 与 datacenter location 会据 application target SLA 选择。

6.1 Balancing Performance and Durability

虽然 Dynamo 的首要目标是 highly available data store,performance 同样重要。Amazon service 通常在 99.9th 或 99.99th percentile 设 performance target;Dynamo service 的典型 SLA 是 99.9% read/write 在 300 ms 内完成。

因为 Dynamo 运行在 I/O throughput 低于 high-end enterprise server 的 commodity hardware 上,要稳定获得 high performance 并不容易。Read/write 要涉及多个 storage node,operation performance 还受 R 或 W 个 replica 中最慢者限制。Figure 4 展示 30 天内 read/write average 与 99.9th-percentile latency:存在明显 diurnal pattern,来自 day/night request-rate difference;write latency 高于 read,因为 write 必然 access disk;99.9th-percentile latency 约 200 ms,比 average 高一个数量级,原因包括 request-load、object-size 和 locality 的 variability。

部分 service 需要更高 performance,因此 Dynamo 允许以 durability guarantee 换 performance。每个 storage node 在 main memory 中维护 object buffer;write 先存到 buffer,由 writer thread 周期性写入 storage;read 先查 buffer,命中时不访问 storage engine。

即使 buffer 只有 1000 个 object,这个 optimization 也能在 peak traffic 将 99.9th-percentile latency 降低约 5 倍,并平滑 high-percentile write latency。代价是 durability:server crash 可能丢失仍在 buffer 中的 write。为降低风险,coordinator 从 N 个 replica 中选择一个做 durable write;coordinator 只等待 W 个 response,因此单个 durable-write replica 的性能不会影响 write operation。

6.2 Ensuring Uniform Load Distribution

Dynamo 使用 consistent hashing partition key space,并试图保证 uniform load。若 key access distribution 没有严重 skew,uniform key distribution 可带来 uniform load;即使 access distribution skew,只要 popular end 有足够多 key,也可通过 partitioning 把 popular-key load 均匀分散。

作者在 24 小时内按 30 分钟 interval 统计每个 node 收到的 request。若某时间窗中 node 的 request load 与 average 偏差超过 15%,则称其 out-of-balance;Figure 6 展示 out-of-balance node fraction,即 imbalance ratio,同时画出整个 system 的 request load。低 load 时 imbalance ratio 最高约 20%;高 load 时约 10%。直觉上,高 load 会访问大量 popular key,均匀 key distribution 使 load 均匀;低 load(约 peak 的八分之一)只访问较少 popular key,imbalance 更高。

第 12 页:三种 Partitioning Strategy

dynamo p12

本节回顾 Dynamo partitioning scheme 的演化,以及它们对 load distribution 的影响。

Strategy 1:每 node T 个 random token,按 token value partition

这是最初 production strategy,也是第 4.2 节描述的 scheme。每个 node 得到 T 个从 hash space uniform random 选择的 token;所有 node 的 token 按 hash value 排序,每两个相邻 token 定义一个 range,最后 token 与第一个 token 形成 wrap-around range。

由于 token random,range size 不同;node join/leave 会改变 token set 和 range。每个 node 必须维护所有 node 的 token position,因此 membership state space 随 node 数量线性增加。

该 strategy 遇到几个问题。新 node 加入时,必须从其他 node “steal” key range;让出 range 的 node 要扫描 local persistence store 找出对应 data item。Production node 上的 scan 很耗 resource,必须以 background、low priority 执行;在 busy shopping season,node 每天处理数百万 request,bootstrap 可能接近一天。

其次,node join/leave 会改变很多 node 的 key range,新 range 的 Merkle tree 必须重算;再者,random range 使整个 key space 难以 snapshot,archive 必须分别从每个 node 取 key,效率低。

根本问题是 data partitioning 与 data placement 绑定。例如增加 node 只是为了提高 request capacity 时,也无法不影响 data partition。理想情况是两种 scheme 独立。

Strategy 2:每 node T 个 random token,equal-sized partition

Hash space 被划分为 Q 个 equal-sized partition/range,通常 Q >> N 且 Q >> S*T,其中 S 是 node 数。Token 只用于构造“hash value 到 ordered node list”的映射,不再决定 partition。Partition 放在从 partition end 沿 ring 顺时针遇到的前 N 个 unique node 上。

Figure 7 展示 N = 3:从包含 k1 的 partition end 沿 ring 走,依次遇到 A、B、C。该 strategy 的优点是 partition 与 placement 解耦,并可以运行时改变 placement scheme。

Strategy 3:每 node Q/S 个 token,equal-sized partition

该 strategy 也把 hash space 分成 Q 个 equal-sized partition,并使 placement 与 partitioning 解耦;每个 node 分配 Q/S 个 token。Node 离开时,其 token 随机分给剩余 node,同时保持这些 property;node 加入时从现有 node “steal” token,以同样方式保持 property。

作者在 S = 30、N = 3 的 system 上评估三种 strategy。但公平比较困难,因为 tuning parameter 不同:Strategy 1 依赖 token 数 T,Strategy 3 依赖 partition 数 Q。一种公平方法,是让三种 strategy 使用相同 membership-information space,再比较 load-distribution skew。

Figure 7

Figure 7 展示三种 strategy 下 key partitioning 与 placement:A、B、C 是 consistent-hashing ring 上构成 key k1 preference list 的三个 unique node;阴影是 A、B、C 组成 preference list 的 key range,深色箭头表示不同 node 的 token location。原图保留完整 ring 与标注。

第 13 页:Partitioning 结果、Divergent Version 与 Coordination

dynamo p13

三种 strategy 需要维护的 membership information 不同:Strategy 1 每 node 保存 ring 中所有 node 的 token position;Strategy 3 保存分配给每个 node 的 partition information。实验改变 T 与 Q,在不同 membership-information size 下测量 load-balancing efficiency,定义为每 node 平均处理 request 数除以 hottest node 处理 request 数。

Figure 8 结果显示,Strategy 3 的 load-balancing efficiency 最好,Strategy 2 最差。Dynamo instance 从 Strategy 1 迁移到 Strategy 3 的短暂过渡期使用过 Strategy 2。相比 Strategy 1,Strategy 3 效率更好,并把每 node membership information 降低三个数量级。Storage 本身不是主要问题,但 node 会周期 gossip membership information,因此 compact information 很有价值。

Strategy 3 还有两个 operational advantage:

  1. Faster bootstrap/recovery:partition range fixed,可存放在独立 file 中;迁移 partition 只需传输整个 file,不必 random access 查找 item。
  2. Ease of archival:Dynamo dataset 可按 partition file 分别 archive;Strategy 1 的 random token 则要求从每个 node 单独取 key,低效且缓慢。

Strategy 3 的缺点是 node membership change 必须协调,以保持 token assignment 的 property。

Figure 8

Figure 8 比较 30-node、N = 3 system 中三种 strategy 的 load-distribution efficiency;横轴是每 node 维护的 metadata size,纵轴是 mean load / max load。Figure 中的 system size 和 replica number 来自多数 service 的典型 configuration。

6.3 Divergent Versions:When and How Many?

Dynamo 以 consistency 换 availability。要精确理解不同 failure 对 consistency 的影响,需要 outage length、failure type、component reliability、workload 等详细 data;这些不在本文 scope 内。本节选择一个 production summary metric:live production environment 中 application 看到的 divergent version 数量。

Data item 的 divergent version 有两类来源:一是 node failure、datacenter failure、network partition 等 failure scenario;二是同一 data item 有大量 concurrent writer,多个 node 同时 coordinate update。从 usability 和 efficiency 角度,都希望任意时刻的 divergent version 尽量少;如果 vector clock 无法 syntactically reconcile,就必须交给 business logic 做 semantic reconciliation,增加 service load。

作者在 24 小时内 profile shopping-cart service 收到的 version:99.94% request 看到恰好一个 version;0.00057% 看到 2 个;0.00047% 看到 3 个;0.00009% 看到 4 个。这说明 divergent version 很少产生。Experience 表明,version 数量增加并非主要由 failure 引起,而是由 concurrent writer 数量增加引起;concurrent write 常由 busy robot 触发,很少由 human 触发。

6.4 Client-driven or Server-driven Coordination

Dynamo 的 request-coordination component 用 state machine 处理 incoming request。Client request 由 load balancer uniform assign 到 ring node;任何 Dynamo node 都可 coordinate read,但 write 必须由 key 当前 preference list 中的 node coordinate,因为它要创建 causally subsume 被 update version 的新 version stamp。若 versioning 使用 physical timestamp,任意 node 都可 coordinate write。

另一种方法是把 state machine 放到 client node,由 client library 本地 coordinate。Client 周期性随机选择一个 Dynamo node,下载当前 membership view,由此计算任意 key 的 preference list。Read 可在 client node coordinate,避免 load balancer 将 request 分给 random node 后产生的额外 network hop;write 则 forward 到 preference-list node,或在 physical-timestamp versioning 时本地 coordinate。

Client-driven coordination 的重要优点,是不再需要 load balancer 来均匀分发 client load;近似均匀的 key assignment 会隐式保证 load distribution。缺点是依赖 client membership information 的 freshness。当前 client 每 10 秒从 random Dynamo node pull membership update;pull 比 push 更能 scale 到大量 client,且 server 无需维护 client state。最坏情况下,client 可能使用 stale membership 10 秒;若发现 membership stale(例如某 member unreachable),立即 refresh。

第 14 页:Coordination、Background Task 与 Discussion

dynamo p14

Table 2:Client-driven 与 Server-driven Coordination

Coordination99.9th read latency99.9th write latencyAverage read latencyAverage write latency
Server-driven68.9 ms68.5 ms3.9 ms4.02 ms
Client-driven30.4 ms30.4 ms1.55 ms1.9 ms

Client-driven coordination 将 99.9th-percentile latency 至少降低 30 ms,average 降低 3–4 ms。原因是去掉 load balancer overhead 和 request 被分到 random node 时可能产生的 extra network hop。Average latency 往往明显低于 99.9th percentile,因为 storage engine cache 和 write buffer hit ratio 较好;load balancer 与 network 引入的 variability,使 client-driven approach 对 high percentile 的改善更明显。

6.5 Balancing Background vs. Foreground Tasks

每个 node 除正常 foreground put/get 外,还执行 replica synchronization、hinted handoff、node add/remove 引起的 data handoff 等 background task。早期 production setting 中,background task 与 foreground task resource contention,影响 regular put/get performance。因此需要确保 background task 只在不显著影响 critical operation 时运行。

Dynamo 将 background task 接入 admission-control mechanism。每个 background task 使用 controller 预留 resource 的 runtime slice(例如 database),所有 background task 共享这些 slice。Controller 根据 foreground performance feedback 调整可用 slice 数量。

Admission controller 持续监控 foreground put/get 的 resource access,包括 disk-operation latency、lock contention 导致的 database access failure、transaction timeout 和 request queue wait time。它检查 trailing time window 中 latency/failure percentile 是否接近 threshold。例如,controller 检查过去 60 秒 database read latency 的 99th percentile 是否接近 50 ms preset threshold,然后评估 foreground resource availability,并决定 background task 可用的 time slice 数,以 feedback loop 限制 background activity 的 intrusion。类似的 background-task management 在 [4] 中研究过。

6.6 Discussion

许多 Amazon internal service 在过去两年使用 Dynamo,并获得显著 availability。特别是,application 收到 successful response(未 timeout)的 request 比例为 99.9995%,截至论文发表没有发生 data-loss event。

Dynamo 的主要优势,是用 N、R、W 三个 parameter 提供 knobs,让 service 按需求 tuning instance。与 popular commercial data store 不同,Dynamo 把 data consistency 和 reconciliation logic 暴露给 developer。开始时可能认为 application logic 会变复杂,但 Amazon platform 本来就面向 high availability,许多 application 已经设计为处理不同 failure mode 与 inconsistency,因此迁移到 Dynamo 相对简单。新 application 需要在开发早期分析业务场景,选择合适 conflict-resolution mechanism。

Dynamo 采用 full-membership model,每个 node 知道 peer host 的 data,并主动 gossip full routing table。该 model 适合数百 node;但扩展到数万 node 并不容易,因为 routing-table maintenance overhead 随 system size 增加。可通过 hierarchical extension 缓解;O(1) DHT system(如 [14])也在解决这一问题。

第 15 页:Conclusions、Acknowledgments 与 References(上)

dynamo p15

7 Conclusions

本文介绍 Dynamo:Amazon.com e-commerce platform 多个 core service 使用的 highly available、scalable data store。Dynamo 达到所需 availability 与 performance,能够处理 server failure、datacenter failure 和 network partition。它支持 incremental scalability,service owner 可以按当前 request load scale up/down。

Dynamo 允许 service owner 通过调节 N、R、W,定制 storage system 的 performance、durability 和 consistency SLA。Dynamo 一年多的 production use 证明,可以把 decentralized technique 组合成单一 highly-available system;它在最具挑战的 application environment 中的成功表明,eventual-consistent storage system 可以作为 highly-available application 的 building block。

Acknowledgments

作者感谢 Pat Helland 对 Dynamo 初始 design 的贡献;感谢 Marvin Theimer 与 Robert van Renesse 的 comments;感谢 shepherd Jeff Mogul 在准备 camera-ready version 时提出的详细 comments 与 input,这些意见显著提高了论文质量。

References(1–20)

  1. Adya et al.,《Farsite: Federated, Available, and Reliable Storage for an Incompletely Trusted Environment》;不完全可信环境中的 federated、available、reliable storage。
  2. Bernstein、Goodman,《An Algorithm for Concurrency Control and Recovery in Replicated Distributed Databases》;replicated distributed database 的 concurrency control 与 recovery。
  3. Chang et al.,《Bigtable: A Distributed Storage System for Structured Data》;structured data 的 distributed storage system。
  4. Douceur、Bolosky,《Process-based Regulation of Low-importance Processes》;low-importance process regulation。
  5. Fox et al.,《Cluster-based Scalable Network Services》;cluster-based scalable network service。
  6. Ghemawat、Gobioff、Leung,《The Google File System》;GFS。
  7. Gray et al.,《The Dangers of Replication and a Solution》;replication danger 与 solution。
  8. Gupta、Chandra、Goldszmidt,《On Scalable and Efficient Distributed Failure Detectors》;scalable distributed failure detector。
  9. Kubiatowicz et al.,《OceanStore: An Architecture for Global-scale Persistent Storage》;global-scale persistent storage architecture。
  10. Karger et al.,《Consistent Hashing and Random Trees: Distributed Caching Protocols for Relieving Hot Spots on the World Wide Web》;consistent hashing 与 random trees。
  11. Lindsay et al.,《Notes on Distributed Databases》;distributed database notes。
  12. Lamport,《Time, Clocks, and the Ordering of Events in a Distributed System》;distributed event ordering。
  13. Merkle,《A Digital Signature Based on a Conventional Encryption Function》;Merkle/hash-based signature。
  14. Ramasubramanian、Sirer,《Beehive: O(1) Lookup Performance for Power-law Query Distributions in Peer-to-peer Overlays》;P2P overlay 的 O(1) lookup。
  15. Reiher et al.,《Resolving File Conflicts in the Ficus File System》;Ficus file conflict resolution。
  16. Rowstron、Druschel,《Pastry: Scalable, Decentralized Object Location and Routing for Large-scale Peer-to-peer Systems》;Pastry object location/routing。
  17. Rowstron、Druschel,《Storage Management and Caching in PAST, a Large-scale, Persistent Peer-to-peer Storage Utility》;PAST storage/caching。
  18. Saito et al.,《FAB: Building Distributed Enterprise Disk Arrays from Commodity Components》;commodity component 构建 distributed disk array。
  19. Satyanarayanan et al.,《Coda: A Resilient Distributed File System》;Coda distributed file system。
  20. Stoica et al.,《Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications》;Chord lookup service。

第 16 页:References(下)

dynamo p16

References(21–24)

  1. Terry et al.,《Managing Update Conflicts in Bayou, a Weakly Connected Replicated Storage System》;Bayou 中的 update-conflict management。
  2. Thomas,《A Majority Consensus Approach to Concurrency Control for Multiple Copy Databases》;multiple-copy database 的 majority consensus。
  3. Weatherspoon、Eaton、Chun、Kubiato­wicz,《Antiquity: Exploiting a Secure Log for Wide-area Distributed Storage》;利用 secure log 的 wide-area storage。
  4. Welsh、Culler、Brewer,《SEDA: An Architecture for Well-conditioned, Scalable Internet Services》;SEDA architecture。

机制索引

机制论文位置与本专栏其他笔记的连接
Zero-hop DHTSections 3.3、4.2用全 membership view 换取低 high-percentile latency
Consistent hashingSections 4.2、6.2key partition、incremental scale-out 与 virtual node
Virtual node/tokenSections 4.2、6.2均衡 load、支持 heterogeneous hardware
Preference listSection 4.3key 的 replica placement 与 distinct physical node
Vector clockSection 4.4、Figure 3causal ordering、syntactic/semantic reconciliation
N/R/WSections 4.5、6.6在 availability、durability、consistency、latency 间调参
Sloppy quorumSection 4.6temporary failure 下保持 read/write availability
Hinted handoffSection 4.6暂代 node 保存 replica,恢复后归还
Merkle-tree anti-entropySection 4.7后台发现并同步 permanent divergence
Gossip membershipSection 4.8decentralized membership 与 routing-table propagation
Read repairSection 5read path opportunistically 修复 stale replica
Buffered writeSection 6.1以 durability 换 99.9th-percentile performance
Client-driven coordinationSections 6.4、Table 2消除 load balancer hop,改善 tail latency
Background admission controlSection 6.5限制 repair/handoff 对 foreground operation 的干扰

本篇验收

  • [x] 课程版本已固定:MIT 6.824 Spring 2013 schedule 的 Lecture 14 Dynamo reading,使用 16 页 SOSP’07 PDF。
  • [x] SHA-256 已记录:5cacd624cd7bfd37e3d22e04d8c2e347a49579d2927dbb06f40a89c0bcd40bd4。
  • [x] 16 个原始页面均渲染为 1224×1584 PNG,并按 600 宽度嵌入。
  • [x] Abstract、Sections 1–7、Figure 1–8、Table 1–2、get/put、consistent hashing、virtual node、preference list、vector clock、sloppy quorum、hinted handoff、Merkle anti-entropy、gossip membership、read repair、N/R/W、production experience、conclusion 和 24 条 References 均按原页顺序完成译注或由原页图保留。
  • [x] 术语如 key-value、eventual consistency、zero-hop DHT、vector clock、syntactic/semantic reconciliation、sloppy quorum、hinted handoff、anti-entropy、read repair 和 admission control 保留 English 或中英并列。
  • [x] Figure、Table、公式、脚注和 References 的原始排版由原页图片保留;翻译层按 16 页原始顺序对应。
← 返回列表
← 上一篇 论文:Practical Byzantine Fault Tolerance(PBFT) 下一篇 → 论文:The Chubby Lock Service for Loosely-Coupled Distributed Systems

评论 (0)

暂无评论,来留下第一条吧。
登录 或 注册 后才能发表评论