Building a P2P Multi-Purpose Database
Tutorial: Getting Local First with Barrel

Benoit Chesneau
Creator of Barrel and Gunicorn

Barrel ( is a modern multi-purpose database in Erlang focusing on data locality (put/match the data next to you) and P2P. Building a database in Erlang is indeed challenging. I/Os are handled differently from the other VM for example. Performance is always a trade-off versus the concurrency and the fault tolerance. On the other hand, Erlang, its vm, the OTP framework offer many competitive advantages that can help you to build a very effective database. To achieve this we created a binding of Facebook rocksdb based on dirty-nif, cowdb to have a pure erlang key/value storage ithout the limit of DETS and our own way to manage presence and claim spaces to store our data over the web.

Talk objectives:

This talk will show how we built Barrel in Erlang, using C when we needed it, which pattern we choose to achieve the read/write concurrency and how we distribute the data. It will show you also how we built a P2P protocol allowing us to distribute our data without any bottleneck.


In this tutorial we will explore:

  • What is Barrel.

  • How to handle your data in Barrel

  • The synchronisation of your data between your applications in Elixir or Erlang without any locking and bottleneck.

  • The addition of new feature to barrels inside your application

  • Going further and replicate to any mobile devices


In physics, the concept of locality is that, for an action at one point to have an influence at another point, something in the space between the points, such as a field, must mediate the action. This exactly what is trying Barrel, a modern multi-purpose database in Erlang focusing on data locality. With Barrel you're able to put and match the data next to you in a P2P manner without any single point of failure.


Erlanger who wants to synchronize its data between multiple locations without conflicts in Erlang or Elixir.


Benoît Chesneau is a internet craftsman, living near Paris. He has years of experience in building small and big-scale database backend websites. He is the founder of a company building innovative web services and open-source applications. Benoît Chesneau is also the founder of the Barrel projects, the author of Gunicorn and multiple other opensource projects in Python and Erlang.

GitHub: benoitc

Twitter: @benoitc

Back to conference page