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

Russell Brown - Oh, you wanted to increment a counter? Good luck with that!

Russell Brown - Oh, you wanted to increment a counter? Good luck with that!

Presented at Hey! #22 on 29th March, 2016.

Hey! Presents

March 29, 2016
Tweet

More Decks by Hey! Presents

Other Decks in Programming

Transcript

  1. basho "Oh, you wanted to *increment a counter*?! Good luck

    with that!” [1] Russell Brown [email protected] [1] https://twitter.com/lindsey/status/575006945213485056
  2. basho Leslie Lamport ``A distributed system is one in which

    the failure of a computer you didn't even know existed can render your own computer unusable''
  3. basho https://en.wikipedia.org/wiki/Distributed_computing A distributed system is a software system in

    which components located on networked computers communicate and coordinate their actions by passing messages. The components interact with each other in order to achieve a common goal.
  4. basho Distributed Counters - WHY? • Many many updates -

    scale/perf • Fault tolerance - machines crash • Latency - local data centres • Containers/“microservices”
  5. basho CAP CAP CAP CAP CAP CAP CAP CAP CAP

    CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP CAP
  6. basho Why Are You Counting? • Money / Votes •

    Real world resources (seats on a place, rental cars) • Unique IDs • Events (likes, hits, plays)
  7. basho Not Really Counting - IDs • Ticket Servers -

    flickr ticket server • Flake - boundary • SnowFlake - Twitter
  8. basho Eventually Consistent • Riak/Cassandra etc • CRDTs Counters •

    Drift/Partial failure • Idempotence • Bounded-Counters - reservations
  9. basho Probabilistic • HyperLogLog etc • Bounded error estimates •

    Trade off space/speed for accuracy • Redis (soon to-be riak) and others
  10. basho Take Home • Understand your requirements • Know What

    you are counting and WHY • Understand the trade offs • Make them consciously • Chose the least consistency/accuracy your use case allows