Build a data platform over and on the web

Erlang User Conference 2013 Benoît Chesneau

About me Apache CouchDB committer and PMC member ● PSF Member ● Web craftsman ● Do opensource for a living ●

Erlang User Conference 2013 - Benoît Chesneau

The big picture

Erlang User Conference 2013 - Benoît Chesneau

What is Refuge? A way to store, sync, and share your data ● Decentralized ● Over and on the web ● Opensource ● Built in Erlang ●

Erlang User Conference 2013 - Benoît Chesneau

Part of

Erlang User Conference 2013 - Benoît Chesneau

Why? Played too much with Apache CouchDB

Document oriented ● Blobs can be attached to documents ● Master-master replication (P2P) ● Couchapps ●

Erlang User Conference 2013 - Benoît Chesneau

But What we really need at the end is...

A simple way to store any blobs ● Index or render them ● And share them among people and machines ● Can work with off-line devices ● Or near you ●

Erlang User Conference 2013 - Benoît Chesneau

Coffer Versatile storage service

Multi-backend (FS, Distributed FS, S3...) ● Simple REST API: GET,PUT, POST, DELETE ● Synchronization ● All blobs are uniquely identified (content-hash) ●

Erlang User Conference 2013 - Benoît Chesneau

Coffer Versatile storage service

Works with mobile & embedded devices ● Partials upload & downloads supported ● RESTFUL, resources visible on HTTP ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

Erlang Side A gen_server to keep all the storage backend configuration ● gen_storage , a behaviour to keep a storage states ● Handle conflicts in the backend. Same file can't be uploaded by 2 clients at the same time ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

Synchronization algorithm Create a change queue on the source ● Enumerate (list) all blobs on the source and copy the blobs not on the target ● Enumerate is cheap (we only compare blobs ids) ● Blobs already on the target aren't sent ● Start to watch on the change queue ● Blobs delivery guarantee ●

Erlang User Conference 2013 - Benoît Chesneau

How changes queues work in Erlang Queues are kept in memory and persited to the disk from time to time ● A process / queue ● A process / watcher is maintained ● Pub/sub over websockets, event source or longpolling ●

Erlang User Conference 2013 - Benoît Chesneau

Today support Memory storage (ETS) ● FS Storage ● Distributed using riak-coree ● More to come (S3, Redis, Memcache) ●

Erlang User Conference 2013 - Benoît Chesneau

Some tools we use Modified cowboy version – http server ● Hackney – http client ● Gproc for a cheap pub/sub internal system (changing) ●

Erlang User Conference 2013 - Benoît Chesneau

Hackney in action ping(#coffer_conn{url=URL, options=Opts}) -> case hackney:head(URL, [], <<>>, Opts) of {ok, 200, _, Client} -> hackney:close(Client), pong; _ -> pang end.

Erlang User Conference 2013 - Benoît Chesneau

How to use the blobs?

No metadata on the disk ● No history ● Just blobs ●

Erlang User Conference 2013 - Benoît Chesneau

Create a backup of a folder

3 kinds of blobs ● 1 blob for the file ● 1 blob keeping file metadata (name, type...) ● 1 blob keeping the directory structure ●

Erlang User Conference 2013 - Benoît Chesneau

file { "blobid": "blobobid", "prev": "prevref or null" }

Erlang User Conference 2013 - Benoît Chesneau

tree { "filename": { “blobid: "blobbid", “type”: “blob” }, "foldername": { “blobid: "blobbid", “type”: “tree” } }

Erlang User Conference 2013 - Benoît Chesneau

Create a backup of a folder Create a reference (or link) to the last version of the tree ● Another blob with a level of indirection ● Can be signed ● Just another blob ●

Erlang User Conference 2013 - Benoît Chesneau

Index your content “just” replicate your index ● An indexer receive {blobref, Blob, timestamp} from the replication queue ● Can be any kind of indexer: sql, apache couchdb, an FTS (like elasticsearch) ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

Behind the scene Mostly works like a blob server ● Except it only pass mapped data to the index ● Possibility to transform the data before indexing (mapping) ● Multi-language ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

The refuge node Frontend to blobs servers and indexers ● Manage blobs claims and access ● Gateway to others nodes ● Forward requests ● WebRTC signaling ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

The hub True decentralized web system ● Once found nodes are directly connected ● A node can be authenticated using a signature ● Webfinger & host-meta ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

The hub Each node can open a connection to an hub using a websocket ● A node can connect to multiple hub ● Once connected a node authenticated itself with a signature ●

Erlang User Conference 2013 - Benoît Chesneau

Erlang User Conference 2013 - Benoît Chesneau

The hub Each refuge node open a connection to an hub (websocket) ● A node can connect to multiple hub ● Once connected a node authentified itself with a signature ●

Erlang User Conference 2013 - Benoît Chesneau

?

@benoitc http://refuge.io

Thanks to Laurent (@lolograph) for the website and logo design Nicolas (@nrdufour) for the code and the ideas Others for their feedback

Erlang User Conference 2013 - Benoît Chesneau

Build a data platform over and on the web Erlang ... - Erlang Factory

Build a data platform over and on the web. Erlang User Conference 2013 ... Works with mobile & embedded devices. ○ Partials upload & downloads supported.

2MB Sizes 3 Downloads 262 Views

Recommend Documents

Erlang/OTP and how the PRNGs work - Erlang Factory
Mar 30, 2012 - Kenji Rikitake / Erlang Factory SF Bay 2012. 1 ... R15B can handle IPv6 services. • Address format is ... Network part: 64, Host part: 64. Address ...

How WhatsApp is scaling up - Erlang Factory
Mar 7, 2014 - 1. That's Billion with a B: Scaling to the next level at WhatsApp. Rick Reed .... Downstream services (esp. non-essential) .... Network failures.

mnesia mnesia - Erlang
Storage of transaction data ... Optionally append to transaction log - disk_log .... recover locker subscr loader monitor mnemosyne sup checkpoint checkpoint ...

Erlang/OTP and how the PRNGs work - Kenji Rikitake Professional ...
Sep 23, 2011 - Contents. RNGs implemented in Erlang/OTP. •crypto and random modules and their issues. SIMD-oriented Fast Mersenne Twister. (SFMT) on pure Erlang and with NIFs. •implementation issues. •performance evaluation. Conclusions and fut

SSH Distribution Transport on Erlang Concurrent System
Oct 26, 2009 - and the arbitrary port-mapping mechanism, and is prone to security attacks on a wide-area Internet. In this paper, we propose a distributed ...

Erlang/OTP and how the PRNGs work - Kenji Rikitake Professional ...
Sep 23, 2011 - Extensive use of head-and-tail list. •Making lists for each recursive argument. •list head addition + lists:reverse/1 is 50% faster than using the ++ ...

Mnesia Database Management System (MNESIA) - Erlang
The management of data in telecommunications system has many aspects whereof some, but .... initialize a database schema, start Mnesia, and create tables.

Generic Load Regulation Framework for Erlang - GitHub
Erlang'10, September 30, 2010, Baltimore, Maryland, USA. Copyright c 2010 ACM ...... rate on a budget dual-core laptop was 500 requests/s. Using parallel.

Mnesia Database Management System (MNESIA) - Erlang
QLC, can be used as a database programming language for Mnesia. ... Mnesia Session enables access to the Mnesia DBMS from foreign programming languages ( ...... -mnesia no table loaders NUMBER specifies the number of parallel table ...

Extracting the processes structure of Erlang applications - CiteSeerX
design patterns which commonly occur in concurrent distributed software. Ex- amples of ... ture of an Erlang application by analysis of the source code. By “the ...

Extracting the processes structure of Erlang applications
Department of Information Technology ... an Erlang program is structured according to modules and functions, ... An example of the type of information we.

Extracting the processes structure of Erlang applications - CiteSeerX
tool extracts the process structure from the applications source code, and presents it ..... a nop-behaviour, e.g. cancel timer, disconnect node, get, load module,.

TinyMT Pseudo Random Number Generator for Erlang
Sep 14, 2012 - vided as a general library for multiple operating systems, since .... 3 On Kyoto University ACCMS Supercomputer System B cluster; the test.

SFMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
Erlang/OTP [5] has a built-in PRNG library called random mod- ule. ..... RedHat Enterprise Linux AS V4 of x86_64 architecture5. We chose the five SFMT ... WN time [ms] leciel reseaux thin. Figure 5. Total own time of SFMT gen_rand_list32/2 for 10 cal

TinyMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
Sep 14, 2012 - Statistics]: Random Number Generation. General Terms Algorithms, Performance. Keywords .... Table 1 shows a list of tinymt-erlang major exported functions referred in this paper. Figure 1 shows the ..... hiroshima-u.ac.jp/~m-mat/MT/ART

SFMT Pseudo Random Number Generator for Erlang - Kenji Rikitake ...
List of sfmt-erlang exported functions referred in this paper. 128-bit shift registers. ..... and does not effectively utilize the concurrent and parallel nature of. Erlang.

Application Security of Erlang Concurrent System - Kenji Rikitake ...
Contact email: [email protected] ... We then evaluate and propose the possible further enhancements to add the protection ..... 1/books/handbook/jails.html.

TinyMT Pseudo Random Number Generator for Erlang
Sep 2, 2012 - Now default PRNG for Python and R. Kenji Rikitake / Erlang ... A) Generate a 32-bit integer random number R. B) Compute Q which is the ...

Shared Nothing Secure Programming in Erlang/OTP
(*1): The word CAP stands for Consistency, Availability, and Partition tolerance. (*2): Disclaimer: the author Kenji Rikitake was a Senior Software Engineer at Basho. Japan KK, a subsidiary of Basho Technologies, Inc., from February to Septem