Chapter 17

Versioned Value

Store every update to a value with a new version, to allow reading historical values.

Problem

In a distributed system, nodes need to be able to tell which value for a key is the most recent. Sometimes they need to know past values so they can react properly to changes in a value.

Solution

Store a version number with each value. The version number is incremented for every update. This allows every update to be converted to a new write without blocking a read. Clients can read historical values at a specific version number.

Consider a simple example of a replicated key-value store. The leader of the cluster handles all the writes to the key-value store. It saves the write requests in a Write-Ahead Log. The write-ahead ...

Get Patterns of Distributed Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.