AboutBlogContact
DevOps & InfrastructureJune 28, 2010 2 min read 182Updated: June 22, 2026

Riak: Dynamo in Practice with Riak Core (2010)

AunimedaAunimeda
📋 Table of Contents

Riak: Dynamo in Practice with Riak Core

Riak isn't just a database; it's a masterpiece of Erlang engineering. It implements the Dynamo architecture, which focuses on high availability and partition tolerance (AP in the CAP theorem).

The Hash Ring

Riak uses a consistent hashing ring divided into 64 (or more) partitions. These partitions are managed by "vnodes" (virtual nodes).

%% Riak Core vnode initialization
init([Partition]) ->
    {ok, #state{partition=Partition}}.

handle_command({put, Key, Value}, _Sender, State) ->
    %% Store data locally for this partition
    Storage = do_store(Key, Value),
    {reply, ok, State#state{storage=Storage}}.

Quorum and N, R, W

The secret to Riak's flexibility is the N, R, W parameters:

  • N: Number of replicas (default 3).
  • R: Number of nodes that must respond to a read.
  • W: Number of nodes that must respond to a write.

If you set W=1, your writes are lightning fast but potentially less durable. If you set W=3, you have high durability but a single node failure can block writes.

Vector Clocks

Because Riak is eventually consistent, two clients might update the same key on different nodes during a network partition. Riak uses Vector Clocks to track the causal history of an object.

Object A, vclock: {node1, 1}, {node2, 2}

If the vclocks are siblings (neither is a descendant of the other), Riak creates a "conflict" (sibling) and lets the application resolve it. This is why Riak is perfect for shopping carts-you never want to lose a customer's item just because of a network glitch.


Aunimeda provides DevOps engineering and infrastructure services - CI/CD pipelines, containerization, cloud deployments, and monitoring setups.

Contact us to discuss your infrastructure needs. See also: DevOps Services, Custom Software Development

Read Also

RabbitMQ: Choosing the Right Exchange Type (2011)aunimeda
DevOps & Infrastructure

RabbitMQ: Choosing the Right Exchange Type (2011)

Direct, Topic, Fanout, or Headers? If you're just dumping everything into a queue, you're missing the point of AMQP.

The GAE Datastore: Living with Eventual Consistency (2008)aunimeda
DevOps & Infrastructure

The GAE Datastore: Living with Eventual Consistency (2008)

Google App Engine is here! But Bigtable isn't your daddy's SQL. Learn how to navigate Entity Groups and eventual consistency in the early days of GAE.

Fault-Tolerant Systems with Erlang/OTP Supervision Trees (2007)aunimeda
DevOps & Infrastructure

Fault-Tolerant Systems with Erlang/OTP Supervision Trees (2007)

Designing 'Nine Nines' availability. How Erlang 5.5 (R11B) uses the Let It Crash philosophy and OTP supervision hierarchies to build distributed systems that never die.

Need IT development for your business?

We build websites, mobile apps and AI solutions. Free consultation.

DevOps Services

Get Consultation All articles