Prophet
a path out of the cloud http://syncwith.us
jesse@bestpractical.com
1
Prophet a path out of the cloud http://syncwith.us - - PowerPoint PPT Presentation
Prophet a path out of the cloud http://syncwith.us jesse@bestpractical.com 1 You may know me from... RT (Request Tracker) Jifty SVK Hiveminder Perl 6 Shirts 2 Ive been hacking on an open source database called Prophet 3 It
a path out of the cloud http://syncwith.us
jesse@bestpractical.com
1RT (Request Tracker) Jifty SVK Hiveminder Perl 6 Shirts
2If we want people to have the same degree
from the world, we may have to sit down and code alternatives to Google Docs, Twitter, and EC3 that can live with us
http://www.oblomovka.com/entries/2008/07/16
64Step 1: Go to Hawaii for “work” Step 2: ??? Step 3: Prophet!
We were there for 8 days We wrote 8000 lines of Perl We figured out step 2
73Prophet http://syncwith.us/prophet SD http://syncwith.us/sd
A grounded, semirelational, peer to peer replicated, disconnected, versioned, property database with self-healing conflict resolution
Runs at the edge Doesn’t need to run in the cloud Syncs with services you already use (We call the adaptors “Foreign Replicas”)
81Joins are expensive (They’re still possible)
Update any replica Pull from any replica Push to any replica Publish a replica Changes will propagate
Real-time replication is hard to scale It only “works” with constant connectivity I don’t have constant connectivity Neither do you Prophet sync can happen whenever
Every update is recorded as a change set Change sets don’t lose any data (so you can use them to go backwards) All history is introspectable Replication just replays changesets
Atomic operations
CREATE, READ, UPDATE, DELETE, SEARCH
Record types can have optional validation and canonicalization Records of the same type do not need to have the same properties Add and remove properties at will
Remembers all conflict resolutions Syncs all resolutions with your peers Detects identical conflicts Uses your peers’ resolutions to “vote” for the winner of a conflict
GET /records.json GET /records/Cars.json GET /records/Cars/716499-5F9-4AC4-827.json GET /records/Cars/716499-5F9-4AC4-827/wheels.json POST /records/Cars.json POST /records/Cars/716499-5F9-4AC4-827.json POST /records/Cars/716499-5F9-4AC4-827/wheels.json
89Yes, we should be using PUT and DELETE Yes, you can have a commit bit and help us fix it :)
90(Yes, the core is Perl.) my $cli = Prophet::CLI->new(); my $cxn = $cli->app_handle->handle; my $record = Prophet::Record->new( handle => $cxn, type => 'Person' ); my $uuid = $record->create( props => { name => 'Jesse', age => 31 } ); $record->set_prop( name => 'age', value => 32 ); my $people = Prophet::Collection->new( handle => $cxn, type => 'Person' ); $people->matching( sub { shift->prop('species') ne 'cat' } );
91A bug tracker: “simple defects”
./bin/sd ticket create -- summary="Can't sync sd with Google Code" status=new Created ticket 5 (93BF979E-08C1-11DD-94C3-D4B1FCEE7EC4)
./bin/sd ticket search --regex publish 29 } new the online help doesn't describe publish 34 } new publish a static html view of records 35 } new publish should create a static rss file
./bin/sd ticket update
Jesse sd publish --to fsck.com:public_html/sd/ CL sd pull --from http://my.com/~jesse/sd
Actually, mine use two:
Prophet makes Foreign Replicas easy SD gets them "for free"
100(Using only the public REST API) It took an afternoon Mirror an RT instance into SD Share it with your peers using prophet Sync changes back from your peers to RT Supports Comments and Attachments
(Using only the public REST API)
Database
How about a P2P BBS? Prophet doesn’t need a server. You can sync over sneakernet.
Database UUID Replica UUID Record Store Changeset Store Resolution Database Configuration metadata
114Stores individual records by type Not guaranteed to have all old versions
115Stores every change to a set of records Guaranteed to have all old changesets Replaying all changesets will create an exact clone of the replica
116Readable Flat files Compact Fast (Not yet fully atomic)
118Designed to let you “publish” databases Flat-files, Currently read-only. Same format as the filesystem replica type.
119Subversion (DEPRECATED)
Slow Steady Robust Supports remote sync Requires Subversion Perl Bindings
120The filesystem is cheap and easy The filesystem is portable Help us write new backends: CouchDB, SQLite, MySQL, Postgres, S3, AppEngine, $YOUR_FAVORITE_DB
121Prophet is designed to sync with “other” databases and systems They don’t need to support all of Prophet’s features - Prophet knows how to interpret mumbo-jumbo from the Cloud Foreign Replicas will usually be app specific All current examples are for SD
Serialize and export all of a replica's resolutions and changesets
124Integrate unseen resolutions and then unseen changesets from a replica
125Integrate new resolutions and changesets into a replica
126Figures out the best resolution “Nullifies” the conflict so the changeset can be cleanly integrated Integrates the conflicting changeset Records the resolution as a new changeset Records the resolution decision in the resolution database
Prophet has clever ways to figure out the best resolution. If there are previous resolutions for the same conflict and a majority agree, use that If the merger has specified a “prefer this side” choice, use that Prompt the user to make a decision, giving them info about previous decisions for this conflict
Scaling to giant clusters is boring (Can I play the “They’re not Green” card here?) Scales to many weakly coonnected peers You are not Google. Does anyone here work for Google? Current target is databases of O(50k) records
We have a political agenda. Cloud computing is not Open Source. APIs for “export” are not good enough. You should always have full control. You probably don’t need to store 10 billion records in one database.
Simple, well-defined Perl API RESTy web API (with microserver) Fast, lightweight backend Small, active dev community Great test coverage ...less than great documentation coverage
136Better ergonomics Improved search and indexing (Including full-text indexing) Client libraries for other languages Proper security model More apps
Prophet 6937 lines of code and doc 1952 lines of tests sd 2121 lines of code and doc 973 lines of tests
Prophet designed in April Prophet core implemented in April SD designed in April SD built in June and July
139Kick-ass functional and text indexing Backend data store improvements Slick GUIs for syncing More Foreign Replicas for SD Documentation improvements A clever logo New applications
140Prophet http://syncwith.us/prophet/download SD http://syncwith.us/sd/download
http://syncwith.us prophet-subscribe@lists.bestpractical.com #prophet on freenode IRC