Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

NoSlides example application

Example application for the talk at NoSlidesConf. This application is a sample application with some functionalities available on riak_core.

You need to use Elixir 1.3 and Erlang 18.X. There are some works on riak_core and riak_core_ng to move on Erlang 19.X, but when I wrote this docs it's not ready.

Clone the repository as usually, download the dependencies and compile the app in this way:

mix deps.get
mix compile

How to start a single node

If you want run a single node you can execute in this way:

$ iex --name gpad@ -S mix run

You can substitute gpad with the name that you prefer. You have to always run riak_core with full name using --name parameter.

How to start multinode on same machine

In this repo it's possibile execute 3 nodes on the same machine. You can execute it in this way:

# this is node 1
MIX_ENV=gpad_1 iex --name gpad_1@ -S mix run

# this is node 2
MIX_ENV=gpad_2 iex --name gpad_2@ -S mix run

# this is node 3
MIX_ENV=gpad_3 iex --name gpad_3@ -S mix run

If you want add more nodes you can check the file in config directory.

Join/Leave node

When you run all the nodes they are running alone. If you want join two node together and create cluster you could go, for example, on console on node 2 and execute this command:

iex(gpad_2@>  :riak_core.join('gpad_1@')

In this way node 2, called gpad_2 is joined on node 1, called gpad_1. Now this two node are a cluster.

The same command could be executed on console of node 3:

iex(gpad_3@>  :riak_core.join('gpad_1@')

When the cluster is stable you can try to put some data in it using the put command (see below) and then you can remove a node from the cluster with the leave command. Try it in this way:

# removing node 2 from cluster
iex(gpad_2@>  :riak_core.leave

How the cluster is composed is saved in disk so, if you stop and restart one or all nodes, they try to connect together, if you want destroy the cluster you can remove evry single node with leave command or deleted the various ring_data_dir*.

Print ring status

After or before the join you can check the status of the ring. You can do this executing this command on elixir shell:

iex(gpad_1@> {:ok, ring} = :riak_core_ring_manager.get_my_ring
iex(gpad_1@> :riak_core_ring.pretty_print(ring, [:legend])


In this example it's now possible execute a ping command with default value of 1 but it's possible pass also a different value to have more chance to change the destination node.

#execute a lot of different ping
(1..20) |> Enum.each(fn v -> end)

It's also possible use this application as a simple KV memory store, in this way:

# on node 1
iex(gpad_1@> NoSlides.Service.put(:key, 42)

On node execute the command to store the value 42 associated with key :key and, it's possible get this value from another node, in this way:

# on node 2
iex(gpad_2@> NoSlides.Service.get(:key)

Depending on your configuration and how many nodes you are running, you can see some different node that respond to this requests. Try to get value before and after a join and a subsequent leave of a node.

More infos...

I'm writing some post about the use of riak_core from Elixir, and you can find it here.


Thanks to:


This code is released under Apache 2 License. Check LICENSE file for more information.