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

Learning to Build Distributed Systems the Hard ...

Theo Hultberg
September 20, 2012

Learning to Build Distributed Systems the Hard Way 

I’ve learned how to build distributed systems the hard way; I’ve failed, and failed again. I’ve made many of the common mistakes and tried a few other things that turned out to be a disappointment. You shouldn't have to make those mistakes too. In this talk I'll tell the story of how I built a real time advertising analytics platform that tracks and reports on millions of impressions every day, and all the things I did wrong before I got it to work. I’ll also tell you what I did right, and the choices I don’t regret.

Theo Hultberg

September 20, 2012
Tweet

More Decks by Theo Hultberg

Other Decks in Technology

Transcript

  1. TRACKING AD IMPRESSIONS track page views and all their ads

    track visibility and send updates on changes track events, track activity, sync cookies, and track visits
  2. track page views and all their ads track visibility and

    send updates on changes track events, track activity, sync cookies, and track visits LOADED VISIBLE HIDDEN VISIBLE LOADED
  3. ASSEMBLING SESSIONS assemble ad impressions, page views and visits, to

    be able to calculate things like total visible duration mix in demographics, revenue, and third-party data
  4. assemble ad impressions, page views and visits, to be able

    to calculate things like total visible duration mix in demographics, revenue, and third-party data WAS LOADED BECAME ACTIVE BECAME VISIBLE WAS HIDDEN BECAME VISIBLE AGAIN A CLICK! { "user_id": "M9L6R5TD0YXK", "session_id": "MAI3QAGNAIYT", "timestamp": 1347896675038, "placement_name": "example", "category": "frontpage", "embed_url": "http://example.com/", "visible_duration": 1340 "browser": "Chrome", "device_type": "computer", "click": true, "ad_dimensions":"980x300" } 3rd PARTY DATA & OTHER GOODIES
  5. ONE VISIT CAN CHANGE UP TO 100K COUNTERS hundreds of

    millions of individual counters per day, plus counting uniques and visitor histories
  6. GIVE A LOT OF THOUGHT TO YOUR KEYS AND IDS

    it will save you lots of pain
  7. PUT BUFFERS BETWEEN LAYERS queues can even out peaks, let

    you scale layers independently, and let you restart services without loosing data
  8. PLAN HOW TO GET RID OF YOUR DATA deleting stuff

    is harder than you might think × × × × × × ×
  9. RANDOMLY when you have no interdependencies between things it’s easy

    to scale out (or round robin, it’s basically the same)
  10. CONSISTENTLY when there are interdependencies you need to route using

    some property of the objects, but make sure you get a uniform distribution
  11. 12

  12. A SHORT DIVERSION ABOUT COUNTING TO 60 the reason why

    there’s 60 seconds to a minute, and 360 degrees to a circle
  13. log2(366) ≈ 31 six characters 0-9, A-Z can represent 31

    bits, which is kind of almost very close to four bytes
  14. DO YOU REALLY NEED A BACKUP? if you got 3x

    replication over multiple availability zones, is that backup really worth it?
  15. PRODUCTION IS THE ONLY REAL TEST ENVIRONMENT when thousands of

    things happen every second, new, weird and unforeseen things happen all the time, your tests can only cover the foreseeable =
  16. COME TO SWEDEN IN MARCH AND TALK ABOUT BIG DATA

    scandevconf.se/2013/call-for-proposals
  17. IDEMPOTENCE if you don’t have to worry about things accidentally

    happening twice, everything becomes much simpler
  18. COUNTING UNIQUES when adding to a set it doesn’t matter

    how many times you do it, the end result is the same
  19. INC X VS SET X increments are not idempotent, and

    very scary, if you can avoid non-idempotent operations, try