Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Practical Eventually-Consistent Web Apps on Riak

Practical Eventually-Consistent Web Apps on Riak

"Eventual consistency! Scalability! Schema-free!" is the rallying call of the NoSQL world. But what does it mean to be eventually-consistent, to be scalable, to be schema-free? Why should you, as a web developer, care? Let's demystify these terms and then explore some ways that Riak, an "eventually-consistent, scalable, schema-free" datastore, can be put to practical use in web applications. You might just find that you've been using eventual consistency all along!

Sean Cribbs

October 18, 2013
Tweet

More Decks by Sean Cribbs

Other Decks in Programming

Transcript

  1. About me 3.5yrs @ Basho Technologies Software Engineer Erlang /

    Ruby Python / JavaScript Riak + Clients + Tools
  2. Already non-ACID Photo by Julie Jacobson data everywhere availability =

    $ blind writes DB not “ACID” application invariants
  3. Eventual consistency is not safe “...it’s easy to satisfy liveness

    without being useful... If all replicas return the value 42 in response to every request, the system is eventually consistent.” http://www.bailis.org/blog/safety-and-liveness-eventual-consistency-is-not-safe/ Peter Bailis
  4. Schema-Free • Data is denormalized • Single-access reads • Great

    for write-heavy loads • More duplication • Harder to query • Harder to evolve cold data
  5. 1 2 3 Riak Eventual Consistency • Peer-to-peer replication •

    F+1 failure tolerance • Hinted handoff • Anti-entropy • Logical time (vector clocks)
  6. Riak Scalability • More nodes → more throughput • More

    replicas → greater reliability • More RAM → lower latency • Faster disk → more throughput, lower latency
  7. Riak Schema-Free • It’s just a “blob” • Key-Value access

    • “Bucket” namespaces • Indexing/search optional
  8. Don’t Use Riak if... • Data fits in RAM on

    one machine • Data is tightly-coupled or highly structured • Application can’t handle eventual consistency* *Riak 2.0 will have more conflict-free datatypes
  9. Social Timelines • Write new updates to various collection points

    • Aggregate and de- dupe on read • Send notifications • Yammer, Formspring, Voxer http://basho.com/riak-and-scala-at-yammer/
  10. Content Management • Documents, design assets, large files • Riak

    CS - run your own S3 • AT&T, IDC Frontier
  11. Persistent Cache • Store rendered pages and snippets or coalesced

    records • Posterous, fast.ly • “A Riak machine was off and no one noticed.”
  12. Game Data • Backup mobile game data, play from another

    device • Record matchup history and stats • Rovio, Riot Games
  13. RICON & Riak 2.0 • RICON|WEST Jeff Dean Pat Helland

    • Riak 2.0 - Strong consistency, New search system, More datatypes, Security features