Partitioning

Introduction

For a system to scale incrementally without disruption the availability, a mechanism is required to partition the data over a set of nodes. Dynamo's partitioning scheme relies on Consistent Hashing to distribute the load across multiple storage blocks

Benefits of Partitioning

Partitioning offers several benefits for distributed systems:

  1. Scalability: By dividing the data into partitions, the system can easily scale horizontally by adding more nodes. Each node is responsible for a subset of the data, allowing for increased processing power and storage capacity as the system grows.

  2. Load Distribution: Partitioning ensures that the workload is evenly distributed across multiple nodes. This prevents any single node from becoming a bottleneck and improves overall system performance.

  3. Fault Tolerance: By replicating partitions across multiple nodes, partitioning provides fault tolerance in case of node failures. If a node goes down, its partitions can be quickly reassigned to other available nodes without affecting the availability of the system.

  4. Data Locality: Partitioning allows data to be stored closer to where it is needed, reducing network latency and improving query performance. Nodes can be located geographically close to their respective data partitions, minimizing data transfer time.

Details

Quote

The output range of a hash function is treated as a fixed circular space or 'ring' (ie. the largest hash value wraps around the smallest hash value)

ABCDEFGKey KNodes B,C,Dstore keys inrange (A,B)Including K

Problems

Consistent hashing assign a random position in the ring to the node which will lead to

Solution

Each node gets assigned to multiple points in the ring. Introducing the concept of virtual node
A virtual node behaves like a node in the ring system, is just that one physical node in the system is in charge of the task assigned to multiple virtual nodes

Question

How is the position of the virtual node assigned to make sure that the load is distributed evenly

Adding and removing a node

When a new (say X) node is added into the system, it gets assigned a number of tokens(virtual nodes) that are randomly scattered on the ring
For every key range that is assigned to node X, there may be a number of nodes (less than or equal to N) that are currently in charge of handling keys that fall within its token range
Since there are some key ranges assigned to X, some existing nodes do not have to handle this key ranges, hence transferring these keys to X, while the rest of the nodes still can carry out read and write, ensuring high availability
A1B1A2C1B2C2X1X1X1This key rangeis transferred from B1 to X1Inserting Node X
Adding a confirmation round between the source and the destination, this made sure that the destination node does not receive any duplicate transfers for a given key range

Propagation

After assigning the virtual node hash spaces, the mappings stored in different dynamo nodes are reconciled during communication exchanges. The partitioning and placement information

propagates through gossip-base protocol and each node is aware of token ranges handled by its peers.

This allows each node to forward the client request to the right set of nodes

External discovery

The mechanism for partitioning may result in a temporary logical partitioning in the dynamo ring

Example

When node A join A to the ring and node B join B in the ring
Both node consider themselves are part of the ring
But they are not aware of each other's presence

Prevention

Some dynamo nodes plays the role of seeds. Seeds are nodes that are discovered via external mechanism and are known to all hosts