1. Foreword

  2. Preface

  3. Acknowledgments

  4. About the Author

  5. Part I: Narratives

    1. Chapter 1: The Promise and Perils of Distributed Systems

      1. The Limits of a Single Server

      2. Separate Business Logic and Data Layer

      3. Partitioning Data

      4. A Look at Failures

      5. Replication: Masking Failures

        1. Process Crash

        2. Network Delay

        3. Process Pause

        4. Unsynchronized Clocks

      6. Defining the Term “Distributed Systems”

      7. The Patterns Approach

    2. Chapter 2: Overview of the Patterns

      1. Keeping Data Resilient on a Single Server

      2. Competing Updates

      3. Dealing with the Leader Failing

      4. Multiple Failures Need a Generation Clock

      5. Log Entries Cannot Be Committed until They Are Accepted by a Majority Quorum

      6. Followers Commit Based on a High-Water Mark

      7. Leaders Use a Series of Queues to Remain Responsive to Many Clients

      8. Followers Can Handle Read Requests to Reduce Load on the Leader

      9. A Large Amount of Data Can Be Partitioned over Multiple Nodes

      10. Partitions Can Be Replicated for Resilience

      11. A Minimum of Two Phases Are Needed to Maintain Consistency across Partitions

      12. In Distributed Systems, Ordering Cannot Depend on System Timestamps

      13. A Consistent Core Can Manage the Membership of a Data Cluster

      14. Gossip Dissemination for Decentralized Cluster Management

  6. Part II: Patterns of Data Replication

    1. Chapter 3: Write-Ahead Log

      1. Problem

      2. Solution

        1. Implementation Considerations

        2. Usage in Transactional Storage

        3. Compared to Event Sourcing

      3. Examples

    2. Chapter 4: Segmented Log

      1. Problem

      2. Solution

      3. Examples

    3. Chapter 5: Low-Water Mark

      1. Problem

      2. Solution

        1. Snapshot-Based Low-Water Mark

        2. Time-Based Low-Water Mark

      3. Examples

    4. Chapter 6: Leader and Followers

      1. Problem

      2. Solution

        1. Leader Election

        2. Why Quorum Read/Writes Are Not Enough for Strong Consistency Guarantees

      3. Examples

    5. Chapter 7: HeartBeat

      1. Problem

      2. Solution

        1. Small Clusters: Consensus-Based Systems

        2. Technical Considerations

        3. Large Clusters: Gossip-Based Protocols

      3. Examples

    6. Chapter 8: Majority Quorum

      1. Problem

      2. Solution

        1. Deciding on Number of Servers in a Cluster

        2. Flexible Quorums

      3. Examples

    7. Chapter 9: Generation Clock

      1. Problem

      2. Solution

      3. Examples

    8. Chapter 10: High-Water Mark

      1. Problem

      2. Solution

        1. Log Truncation
      3. Examples

    9. Chapter 11: Paxos

      1. Problem

      2. Solution

        1. Flow of the Protocol

        2. An Example Key-Value Store

        3. Flexible Paxos

      3. Examples

    10. Chapter 12: Replicated Log

      1. Problem

      2. Solution

        1. Multi-Paxos and Raft

        2. Replicating Client Requests

        3. Leader Election

        4. Technical Considerations

        5. Push vs. Pull

        6. What Goes in the Log?

      3. Examples

    11. Chapter 13: Singular Update Queue

      1. Problem

      2. Solution

        1. Choice of the Queue

        2. Using Channels and Lightweight Threads

        3. Backpressure

        4. Other Considerations

      3. Examples

    12. Chapter 14: Request Waiting List

      1. Problem

      2. Solution

        1. Expiring Long Pending Requests
      3. Examples

    13. Chapter 15: Idempotent Receiver

      1. Problem

      2. Solution

        1. Expiring the Saved Client Requests

        2. Removing the Registered Clients

        3. At-Most-Once, At-Least-Once, and Exactly-Once Actions

      3. Examples

    14. Chapter 16: Follower Reads

      1. Problem

      2. Solution

        1. Finding the Nearest Replica

        2. Disconnected or Slow Followers

        3. Read Your Own Writes

        4. Linearizable Reads

      3. Examples

    15. Chapter 17: Versioned Value

      1. Problem

      2. Solution

        1. Ordering of Versioned Keys

        2. Reading Multiple Versions

        3. MVCC and Transaction Isolation

        4. Using RocksDB-Like Storage Engines

      3. Examples

    16. Chapter 18: Version Vector

      1. Problem

      2. Solution

        1. Comparing Version Vectors

        2. Using Version Vector in a Key-Value Store

      3. Examples

  7. Part III: Patterns of Data Partitioning

    1. Chapter 19: Fixed Partitions

      1. Problem

      2. Solution

        1. Choosing the Hash Function

        2. Mapping Partitions to Cluster Nodes

        3. Alternative Solution: Partitions Proportional to Number of Nodes

      3. Examples

    2. Chapter 20: Key-Range Partitions

      1. Problem

      2. Solution

        1. Predefining Key Ranges

        2. An Example Scenario

        3. Auto-Splitting Ranges

      3. Examples

    3. Chapter 21: Two-Phase Commit

      1. Problem

      2. Solution

        1. Locks and Transaction Isolation

        2. Commit and Rollback

        3. An Example Scenario

        4. Using Versioned Value

        5. Using Replicated Log

        6. Failure Handling

        7. Transactions across Heterogeneous Systems

      3. Examples

  8. Part IV: Patterns of Distributed Time

    1. Chapter 22: Lamport Clock

      1. Problem

      2. Solution

        1. Causality, Time, and Happens-Before

        2. An Example Key-Value Store

        3. Partial Order

        4. A Single Leader Server Updating Values

      3. Examples

    2. Chapter 23: Hybrid Clock

      1. Problem

      2. Solution

        1. Multiversion Storage with Hybrid Clock

        2. Using Timestamp to Read Values

        3. Assigning Timestamp to Distributed Transactions

      3. Examples

    3. Chapter 24: Clock-Bound Wait

      1. Problem

      2. Solution

        1. Read Restart

        2. Using Clock-Bound APIs

      3. Examples

  9. Part V: Patterns of Cluster Management

    1. Chapter 25: Consistent Core

      1. Problem

      2. Solution

        1. Metadata Storage

        2. Handling Client Interactions

      3. Examples

    2. Chapter 26: Lease

      1. Problem

      2. Solution

        1. Attaching the Lease to Keys in the Key-Value Storage

        2. Handling Leader Failure

      3. Examples

    3. Chapter 27: State Watch

      1. Problem

      2. Solution

        1. Client-Side Implementation

        2. Server-Side Implementation

        3. Handling Connection Failures

      3. Examples

    4. Chapter 28: Gossip Dissemination

      1. Problem

      2. Solution

        1. Avoiding Unnecessary State Exchange

        2. Criteria for Node Selection to Gossip

        3. Group Membership and Failure Detection

        4. Handling Node Restarts

      3. Examples

    5. Chapter 29: Emergent Leader

      1. Problem

      2. Solution

        1. Sending Membership Updates to All the Existing Members

        2. An Example Scenario

        3. Handling Missing Membership Updates

        4. Failure Detection

        5. Comparison with Leader and Followers

      3. Examples

  10. Part VI: Patterns of Communication between Nodes

    1. Chapter 30: Single-Socket Channel

      1. Problem

      2. Solution

      3. Examples

    2. Chapter 31: Request Batch

      1. Problem

      2. Solution

        1. Technical Considerations
      3. Examples

    3. Chapter 32: Request Pipeline

      1. Problem

      2. Solution

      3. Examples

  11. References

  12. Index