Slide 1

Slide 1 text

BARREL DISTRIBUTED DATABASE FOR THE MODERN WORLD https://barrel-db.org Erlang Factory Lite Brussel 2016

Slide 2

Slide 2 text

VISION AND CONCEPT

Slide 3

Slide 3 text

local database mobile sensor "cloud" database local database mobile DATA IS MOBILE

Slide 4

Slide 4 text

share discover replicate PEER TO PEER (P2P)

Slide 5

Slide 5 text

▸ Local first ▸ Put/Match the data next to you ▸ Query Locally ▸ Replicate a view of the data you need

Slide 6

Slide 6 text

WHAT IS BARREL

Slide 7

Slide 7 text

WHAT IS BARREL ▸ a document database ▸ revision tree & atomic document updates ▸ changes feed ▸ replication between any nodes in both way ▸ views (~ map)

Slide 8

Slide 8 text

AN EFFORT TO MAINTAIN THE COUCHDB API

Slide 9

Slide 9 text

▸ view changes ▸ replication based on a view ▸ bulk get ▸ pluggable WITH MODERN FEATURES

Slide 10

Slide 10 text

▸ DATA are not only blobs ▸ Replicated APPs ▸ Couchapps but extended and revisited REPLICATED APPS

Slide 11

Slide 11 text

BUILT IN ERLANG /> <

Slide 12

Slide 12 text

▸ append only file ▸ MVCC ▸ 2 indexes (btree): by sequence, by id ▸ 1 index for local documents without conflict handling ▸ A revision tree is stored in indexes pointed to the revision offset ▸ The revision is stored in the file separately HOW ARE STORED DOCUMENTS

Slide 13

Slide 13 text

REVISION TREE

Slide 14

Slide 14 text

▸ Write is slow ▸ Read should not being blocked by writes ▸ No shared memory ▸ No atomic integer trick ▸ Only actors and message passing ▸ Operations on a doc are atomic CHALLENGES

Slide 15

Slide 15 text

READ/WRITE OPERATIONS DB STATE READER READER writer writer write process update share state

Slide 16

Slide 16 text

▸ LRU to cache blocks
 https://github.com/barrel-db/erlang-lru ▸ 1 File process, Operations are limited ▸ DB users are linked to the database process ▸ Write buffer to reduce the latency ▸ Optional wal (barrel 014) ▸ NIF for the collation READ/WRITE OPERATIONS

Slide 17

Slide 17 text

INDEX OPERATIONS View Group READER READER change reader indexer update share state send /collect changes DB get changes

Slide 18

Slide 18 text

▸ Credit Flow Based ▸ The View group keep the state ▸ View group is created on demande ▸ kept open until it has readers ▸ Indexer ask for updates ▸ Read functions (Map functions) are processed in // INDEX OPERATIONS

Slide 19

Slide 19 text

▸ Create a new file to remove the fragmentation ▸ A race between copy and the addition of new data ▸ Require at least twice of the storage THE COMPACTION ISSUE

Slide 20

Slide 20 text

▸ Added 2 features: ▸ MOVE: move doc(s) to another node or database ▸ User hooks functions (run in background) using hooks:
 https://github.com/barrel-db/hooks ▸ Partition on demand ▸ Decision depends on the application needs NEW FUNCTIONS

Slide 21

Slide 21 text

CHANGES HANDLER subscriber change dispatcher broadcast changes DB

Slide 22

Slide 22 text

▸ changes load balancing ▸ consumer subscribe on patterns (delete, update, …) ▸ Create changes Load Balancer on demand ▸ Allows remote nodes to subscribe to a queue ▸ Based on primer (released on February 2016) CHANGES EVENTS

Slide 23

Slide 23 text

▸ fetch the revisions and their attachments
 not present on the node ▸ continuous or not ▸ try to collect multiple docs at once ▸ use hackney:
 http://github.com/benoitc/hackney ▸ Use a Flow-based pattern instead of a classic pool REPLICATION

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

HTTPS://BARREL-DB.ORG Barrel HTTP://ENKIM.EU Enki Multimedia