Riak_Core with Elixir : Part One

This is going to be a multi-part blog series in which I’ll show how can you build an riak_core application using elixir.

I won’t go into details of what riak_core is or what can be achieved using riak_core. You can read about it here.

In this part we will try to configure riak core in our application.


You would need to install erlang version 18 (please note that erlang version above 18 are not supported in riak_core as of now). Elixir version should be 1.3 or above.


We will create a mix project using command

once we have our project structure ready, we need to declare riak_core as a build time dependency in our mix.exs file.

Now we have to make sure that riak_core is started before our app by giving it as a runtime dependency. We will do it in application method in our mix file.

In the first line, we specify the application module of our application (start/0 function will be called from Vyuha.App). In second line, we are telling mix to start riak_core and logger before it starts our application.


Before we start our application, we need to configure riak_core by setting some default values. We will do this in our config.exs file

Here we are configuring riak_core for its different properties, like number of vnodes to create (which is 12 in this case), where to save ring configuration data etc.

Apart from configuring riak_core, we also need to configure two more runtime dependencies (these are part of elixir package). Again we will do this in config.exs

One more thing that we need to do before we can start our application is to create a “priv” folder under the root project folder and copy riak_core.schema from deps/riak_core. Run below command on root folder of your project.

Building Project

Get dependencies by running following command.

Now run the application by running following command

Here we have used a long name by providing a — name flag. This name identifies a Beam Instance on a machine. Name takes a form of arbitrary_prefix@host, where arbitrary_prefix is any name that you give to the Beam instance and host is the full ip address of the host machine. This will become important as soon as we try to run multiple Nodes on same machine.

Hint: if you get some weird riak_core errors, try to delete the ring_data_dir in your root folder, riak_core seems to store the node configuration from previous run and expects they are their in the next run.

This should start our riak_core application. In next post we will try to add functionality in our app. You can find code up to this point here.

Read part 2 here.

Composability = Programming | Category-Theory

Composability = Programming | Category-Theory