SlideShare une entreprise Scribd logo
1  sur  106
Jeremy Edberg
                          QconSF 2012




Tweet @jedberg with feedback!
Watch the video with slide
                         synchronization on InfoQ.com!
                      http://www.infoq.com/presentations
                              /Reliable-Data-Store

       InfoQ.com: News & Community Site
• 750,000 unique visitors/month
• Published in 4 languages (English, Chinese, Japanese and Brazilian
  Portuguese)
• Post content from our QCon conferences
• News 15-20 / week
• Articles 3-4 / week
• Presentations (videos) 12-15 / week
• Interviews 2-3 / week
• Books 1 / month
Presented at QCon San Francisco
                          www.qconsf.com
Purpose of QCon
- to empower software development by facilitating the spread of
knowledge and innovation
Strategy
 - practitioner-driven conference designed for YOU: influencers of
change and innovation in your teams
- speakers and topics driving the evolution and innovation
- connecting and catalyzing the influencers and innovators
Highlights
- attended by more than 12,000 delegates since 2007
- held in 9 cities worldwide
Tweet @jedberg with feedback!
Building a Reliable Data
          Store




Tweet @jedberg with feedback!
Agenda

  • CAP theory and how it applies to reliability
  • How reddit and Netflix maintain reliable
      data stores
  • Best Practices
  • War stories -- surviving real outages

Tweet @jedberg with feedback!
CAP Theorem

  • Consistent
  • Available
  • Partition-resistant

Tweet @jedberg with feedback!
ATM


                                      ?




Tweet @jedberg with feedback!
ATM

                                           AP

                                  Limits liability through
                                    allowing only small
                                        transactions




Tweet @jedberg with feedback!
Flight Reservations


                                ?




Tweet @jedberg with feedback!
Flight Reservations

                                    AP

                                 This is why
                                overbooking
                                   occurs




Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
The problem with CAP

  • Daniel Abadi had a problem with CAP
  • The weightings were uneven
  • A is essential in all scenarios
  • C is more important than P
  • Latency wasn’t accounted for at all
Tweet @jedberg with feedback!
PACELC

    If there is a partition (P) how does the system
    tradeoff between availability and consistency (A
    and C); else (E) when the system is running as
    normal in the absence of partitions, how does
    the system tradeoff between latency (L) and
    consistency (C)?



Tweet @jedberg with feedback!
Partitioning




Tweet @jedberg with feedback!
Thinking like a coder
           Partitions are like code branches




Tweet @jedberg with feedback!
Some examples


  • ACID systems (Postgres, Oracle, MySql,
      etc) are PC/EC
  • Cassandra is PA/EL


Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Reliability and $$




Tweet @jedberg with feedback!
Building for redundancy




Tweet @jedberg with feedback!
We want to make sure
  we are building for
       survival



Tweet @jedberg with feedback!
1>2>3
           Going from two to three is hard




Tweet @jedberg with feedback!
1>2>3
           Going from one to two is harder




Tweet @jedberg with feedback!
Build for Three
   If possible, plan for 3 or more from the beginning.




Tweet @jedberg with feedback!
“Build for three” is the
   secret to success




Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
reddit




Tweet @jedberg with feedback!
Architecture




Tweet @jedberg with feedback!
Postgres




Tweet @jedberg with feedback!
Database Resiliancy
        with Sharding




Tweet @jedberg with feedback!
Sharding
  •   reddit split writes across four master databases

  •   Links/Accounts/Subreddits, Comments,Votes
      and Misc

  •   Each has at least one slave in another zone

  •   Avoid reading from the master if possible

  •   Wrote their own database access layer, called
      the “thing” layer



Tweet @jedberg with feedback!
Sample Schema
                   link_thing
                       int id
                       timestamp date
                       int ups
                       int downs
                       bool deleted
                       bool spam

                   link_data
                       int thing_id
                       string name
                       string value
                       char kind
Tweet @jedberg with feedback!
The thing layer
  • Postgres is used like a key/value store
  • Thing table has denormalized data
  • Data table has arbitrary keys
  • Lots of indexes tuned for our specific
      queries
  • Thing and data tables are on the same box,
      but don’t have to be

Tweet @jedberg with feedback!
I love memcache
            I make heavy use of memcached




Tweet @jedberg with feedback!
1     A


               2
                                        3



                   C                B



Tweet @jedberg with feedback!
1
                   D            A
               2
                                    3



                   C            B



Tweet @jedberg with feedback!
Cassandra




Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Netflix




Tweet @jedberg with feedback!
Data
           What does Netflix do with it all?




Tweet @jedberg with feedback!
We store it!

  • Cache (memcached)
  • Cassandra
  • RDS (MySql)

Tweet @jedberg with feedback!
I love memcache
            I make heavy use of memcached




Tweet @jedberg with feedback!
RDS (Relational
         Database Service)




Tweet @jedberg with feedback!
Cassandra




Tweet @jedberg with feedback!
A/B Testing




Tweet @jedberg with feedback!
A/B Testing

            Online Data         Offline Data




         Test Cell allocation    Test tracking
           Test Metadata           Retention
           Start/End date       Fraction Viewed
            UI Directives        Pages Viewed


Tweet @jedberg with feedback!
Atlas




Tweet @jedberg with feedback!
AWS Usage
                 Dollar amounts have been carefully removed




Tweet @jedberg with feedback!
Chronos




Tweet @jedberg with feedback!
More Things Netflix
      Stores in Cassandra

  •   Video Quality

  •   Network issues

  •   Usage History

  •   Playback Errors




Tweet @jedberg with feedback!
Service based
                architecture




Tweet @jedberg with feedback!
Netflix on AWS
                                2012   2012   2012
                                IPv6   IPv6   IPv6




Tweet @jedberg with feedback!
Abstraction

  • Data sources are abstracted away behind
      restful interfaces
  • Each application owns its own consistency
  • Each application can scale independently
      based on load



Tweet @jedberg with feedback!
Netflix autoscaling
2




                                    Text
1




                               Traffic Peak


    Tweet @jedberg with feedback!
The Big Oracle
               Database




Tweet @jedberg with feedback!
Circuit Breakers
Be liberal in what you accept, strict in what you send




  Tweet @jedberg with feedback!
Cassandra




Tweet @jedberg with feedback!
Priam




Tweet @jedberg with feedback!
Cassandra Architecture




Tweet @jedberg with feedback!
Cassandra Architecture




Tweet @jedberg with feedback!
How it works
  •   Replication factor

  •   Quorum reads / writes

  •   Bloom Filter for fast negative lookups

  •   Immutable files for fast writes

  •   Seed nodes

  •   Multi-region

  •   Gossip protocol

Tweet @jedberg with feedback!
Cassandra Benefits

  • Fast writes
  • Fast negative lookups
  • Easy incremental scalability
  • Distributed -- No SPoF

Tweet @jedberg with feedback!
Why Cassandra?

  • Availability over consistency
  • Writes over reads
  • We know Java
  • Open source + support

Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
We live in an unreliable
          world




Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Tips, and Tricks
Queues are your friend
  • Votes
  • Comments
  • Thumbnail scraper
  • Precomputed queries
  • Spam
   • processing
   • corrections
Tweet @jedberg with feedback!
Caching is a good way
   to hide your failures



Tweet @jedberg with feedback!
Sometimes users notice
 your data inconstancy




Tweet @jedberg with feedback!
EVCache
          1
    D                           A
2
                                        3   +
    C                           B



        Tweet @jedberg with feedback!
Do you even need a
           cache?


Tweet @jedberg with feedback!
Think of SSDs as cheap
 RAM, not expensive disk


Tweet @jedberg with feedback!
Going multi-zone or
      multi-datacenter




Tweet @jedberg with feedback!
Benefits of Amazon’s
           Zones

  • Loosely connected
  • Low latency between zones
  • 99.95% uptime guarantee per zone

Tweet @jedberg with feedback!
Going Multi-region




Tweet @jedberg with feedback!
Leveraging Mutli-region

  • 100% uptime is theoretically possible.
  • You have to replicate your data
  • This will cost money

Tweet @jedberg with feedback!
Other options


  • Backup datacenter
  • Backup provider


Tweet @jedberg with feedback!
Cause chaos




Tweet @jedberg with feedback!
The Monkey Theory


  • Simulate things that go wrong
  • Find things that are different


Tweet @jedberg with feedback!
The simian army
  • Chaos -- Kills random instances
  • Latency -- Slows the network down
  • Conformity -- Looks for outliers
  • Doctor -- Looks for passing health checks
  • Janitor -- Cleans up unused resources
  • Howler -- Yells about bad things
Tweet @jedberg with feedback!
The Chaos Gorilla




Tweet @jedberg with feedback!
Automate all the things!




Tweet @jedberg with feedback!
Automate all the things!

  • Application startup
  • Configuration
  • Code deployment
  • System deployment

Tweet @jedberg with feedback!
Incident Reviews
            Ask the key questions:
  •   What went wrong?
  • How could we have detected it sooner?
  • How could we have prevented it?
  • How can we prevent this class of problem
      in the future?
  • How can we improve our behavior for next
      time?

Tweet @jedberg with feedback!
The Netflix way
  • Everything is “built for three”
  • Fully automated build tools to test and
      make packages
  • Fully automated machine image bakery
  • Fully automated image deployment

Tweet @jedberg with feedback!
All systems choices
  assume some part will
    fail at some point.



Tweet @jedberg with feedback!
Best Practices


• Keep data in multiple Availability Zones / DCs
• Avoid keeping state on a single instance


Tweet @jedberg with feedback!
Best Practices

  • Isolated Services
  • Three Balanced AZs
  • Triple replicated persistence
  • Isolated Regions

Tweet @jedberg with feedback!
Best Practices

  • Don’t trust your dependencies
   • Have good fallbacks
   • Use circuit breakers/dependency
         commands



Tweet @jedberg with feedback!
Best Practices


  • Be generous in what you accept and stingy
      in what you give




Tweet @jedberg with feedback!
Best Practices


  • Hope for the best, assume the worst



Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
War Stories



Tweet @jedberg with feedback!
April 2011 EBS outage




Tweet @jedberg with feedback!
June 29th Outage

  • Due to a severe storm, power went out in
      one AZ
  • Netflix did not do well because of a bug in
      our internal mid-tier load balancer
  • However, Cassandra held up just fine!

Tweet @jedberg with feedback!
October 29th Outage

  • EBS degradation in one Zone
  • We did much better this time
  • Cassandra just kept running
  • MySql not as well, but fallbacks kicked in

Tweet @jedberg with feedback!
Hurricane Sandy
             The outage that never was




Tweet @jedberg with feedback!
Just a quick reminder...
           (Some of) Netflix is open source:
                 https://netflix.github.com/




Tweet @jedberg with feedback!
Another reminder...

                reddit is also open source
                 https://github.com/reddit
           patches are now being accepted!




Tweet @jedberg with feedback!
Netflix is hiring
           http://jobs.netflix.com/jobs.html

                          - or -
              email talent@netflix.com and
               tell them jedberg sent you




Tweet @jedberg with feedback!
Questions?




Tweet @jedberg with feedback!
Tweet @jedberg with feedback!
Getting in touch
  Email: jedberg@gmail.com

  Twitter: @jedberg

  Web: www.jedberg.net

  Facebook: facebook.com/jedberg

  Linkedin: www.linkedin.com/in/jedberg

  reddit: www.reddit.com/user/jedberg

Tweet @jedberg with feedback!

Contenu connexe

Plus de C4Media

Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaC4Media
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideC4Media
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDC4Media
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine LearningC4Media
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at SpeedC4Media
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsC4Media
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsC4Media
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerC4Media
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleC4Media
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeC4Media
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereC4Media
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing ForC4Media
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data EngineeringC4Media
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreC4Media
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsC4Media
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechC4Media
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/awaitC4Media
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaC4Media
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayC4Media
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?C4Media
 

Plus de C4Media (20)

Does Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to JavaDoes Java Need Inline Types? What Project Valhalla Can Bring to Java
Does Java Need Inline Types? What Project Valhalla Can Bring to Java
 
Service Meshes- The Ultimate Guide
Service Meshes- The Ultimate GuideService Meshes- The Ultimate Guide
Service Meshes- The Ultimate Guide
 
Shifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CDShifting Left with Cloud Native CI/CD
Shifting Left with Cloud Native CI/CD
 
CI/CD for Machine Learning
CI/CD for Machine LearningCI/CD for Machine Learning
CI/CD for Machine Learning
 
Fault Tolerance at Speed
Fault Tolerance at SpeedFault Tolerance at Speed
Fault Tolerance at Speed
 
Architectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep SystemsArchitectures That Scale Deep - Regaining Control in Deep Systems
Architectures That Scale Deep - Regaining Control in Deep Systems
 
ML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.jsML in the Browser: Interactive Experiences with Tensorflow.js
ML in the Browser: Interactive Experiences with Tensorflow.js
 
Build Your Own WebAssembly Compiler
Build Your Own WebAssembly CompilerBuild Your Own WebAssembly Compiler
Build Your Own WebAssembly Compiler
 
User & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix ScaleUser & Device Identity for Microservices @ Netflix Scale
User & Device Identity for Microservices @ Netflix Scale
 
Scaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's EdgeScaling Patterns for Netflix's Edge
Scaling Patterns for Netflix's Edge
 
Make Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home EverywhereMake Your Electron App Feel at Home Everywhere
Make Your Electron App Feel at Home Everywhere
 
The Talk You've Been Await-ing For
The Talk You've Been Await-ing ForThe Talk You've Been Await-ing For
The Talk You've Been Await-ing For
 
Future of Data Engineering
Future of Data EngineeringFuture of Data Engineering
Future of Data Engineering
 
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and MoreAutomated Testing for Terraform, Docker, Packer, Kubernetes, and More
Automated Testing for Terraform, Docker, Packer, Kubernetes, and More
 
Navigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery TeamsNavigating Complexity: High-performance Delivery and Discovery Teams
Navigating Complexity: High-performance Delivery and Discovery Teams
 
High Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in AdtechHigh Performance Cooperative Distributed Systems in Adtech
High Performance Cooperative Distributed Systems in Adtech
 
Rust's Journey to Async/await
Rust's Journey to Async/awaitRust's Journey to Async/await
Rust's Journey to Async/await
 
Opportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven UtopiaOpportunities and Pitfalls of Event-Driven Utopia
Opportunities and Pitfalls of Event-Driven Utopia
 
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/DayDatadog: a Real-Time Metrics Database for One Quadrillion Points/Day
Datadog: a Real-Time Metrics Database for One Quadrillion Points/Day
 
Are We Really Cloud-Native?
Are We Really Cloud-Native?Are We Really Cloud-Native?
Are We Really Cloud-Native?
 

Dernier

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 

Dernier (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 

Building a Reliable Data Store

  • 1. Jeremy Edberg QconSF 2012 Tweet @jedberg with feedback!
  • 2. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /Reliable-Data-Store InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month
  • 3. Presented at QCon San Francisco www.qconsf.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  • 5. Building a Reliable Data Store Tweet @jedberg with feedback!
  • 6. Agenda • CAP theory and how it applies to reliability • How reddit and Netflix maintain reliable data stores • Best Practices • War stories -- surviving real outages Tweet @jedberg with feedback!
  • 7. CAP Theorem • Consistent • Available • Partition-resistant Tweet @jedberg with feedback!
  • 8. ATM ? Tweet @jedberg with feedback!
  • 9. ATM AP Limits liability through allowing only small transactions Tweet @jedberg with feedback!
  • 10. Flight Reservations ? Tweet @jedberg with feedback!
  • 11. Flight Reservations AP This is why overbooking occurs Tweet @jedberg with feedback!
  • 12. Tweet @jedberg with feedback!
  • 13. The problem with CAP • Daniel Abadi had a problem with CAP • The weightings were uneven • A is essential in all scenarios • C is more important than P • Latency wasn’t accounted for at all Tweet @jedberg with feedback!
  • 14. PACELC If there is a partition (P) how does the system tradeoff between availability and consistency (A and C); else (E) when the system is running as normal in the absence of partitions, how does the system tradeoff between latency (L) and consistency (C)? Tweet @jedberg with feedback!
  • 16. Thinking like a coder Partitions are like code branches Tweet @jedberg with feedback!
  • 17. Some examples • ACID systems (Postgres, Oracle, MySql, etc) are PC/EC • Cassandra is PA/EL Tweet @jedberg with feedback!
  • 18. Tweet @jedberg with feedback!
  • 19. Reliability and $$ Tweet @jedberg with feedback!
  • 20. Building for redundancy Tweet @jedberg with feedback!
  • 21. We want to make sure we are building for survival Tweet @jedberg with feedback!
  • 22. 1>2>3 Going from two to three is hard Tweet @jedberg with feedback!
  • 23. 1>2>3 Going from one to two is harder Tweet @jedberg with feedback!
  • 24. Build for Three If possible, plan for 3 or more from the beginning. Tweet @jedberg with feedback!
  • 25. “Build for three” is the secret to success Tweet @jedberg with feedback!
  • 26. Tweet @jedberg with feedback!
  • 30. Database Resiliancy with Sharding Tweet @jedberg with feedback!
  • 31. Sharding • reddit split writes across four master databases • Links/Accounts/Subreddits, Comments,Votes and Misc • Each has at least one slave in another zone • Avoid reading from the master if possible • Wrote their own database access layer, called the “thing” layer Tweet @jedberg with feedback!
  • 32. Sample Schema link_thing int id timestamp date int ups int downs bool deleted bool spam link_data int thing_id string name string value char kind Tweet @jedberg with feedback!
  • 33. The thing layer • Postgres is used like a key/value store • Thing table has denormalized data • Data table has arbitrary keys • Lots of indexes tuned for our specific queries • Thing and data tables are on the same box, but don’t have to be Tweet @jedberg with feedback!
  • 34. I love memcache I make heavy use of memcached Tweet @jedberg with feedback!
  • 35. 1 A 2 3 C B Tweet @jedberg with feedback!
  • 36. 1 D A 2 3 C B Tweet @jedberg with feedback!
  • 38. Tweet @jedberg with feedback!
  • 40. Data What does Netflix do with it all? Tweet @jedberg with feedback!
  • 41. We store it! • Cache (memcached) • Cassandra • RDS (MySql) Tweet @jedberg with feedback!
  • 42. I love memcache I make heavy use of memcached Tweet @jedberg with feedback!
  • 43. RDS (Relational Database Service) Tweet @jedberg with feedback!
  • 45. A/B Testing Tweet @jedberg with feedback!
  • 46. A/B Testing Online Data Offline Data Test Cell allocation Test tracking Test Metadata Retention Start/End date Fraction Viewed UI Directives Pages Viewed Tweet @jedberg with feedback!
  • 48. AWS Usage Dollar amounts have been carefully removed Tweet @jedberg with feedback!
  • 50. More Things Netflix Stores in Cassandra • Video Quality • Network issues • Usage History • Playback Errors Tweet @jedberg with feedback!
  • 51. Service based architecture Tweet @jedberg with feedback!
  • 52. Netflix on AWS 2012 2012 2012 IPv6 IPv6 IPv6 Tweet @jedberg with feedback!
  • 53. Abstraction • Data sources are abstracted away behind restful interfaces • Each application owns its own consistency • Each application can scale independently based on load Tweet @jedberg with feedback!
  • 54. Netflix autoscaling 2 Text 1 Traffic Peak Tweet @jedberg with feedback!
  • 55. The Big Oracle Database Tweet @jedberg with feedback!
  • 56. Circuit Breakers Be liberal in what you accept, strict in what you send Tweet @jedberg with feedback!
  • 61. How it works • Replication factor • Quorum reads / writes • Bloom Filter for fast negative lookups • Immutable files for fast writes • Seed nodes • Multi-region • Gossip protocol Tweet @jedberg with feedback!
  • 62. Cassandra Benefits • Fast writes • Fast negative lookups • Easy incremental scalability • Distributed -- No SPoF Tweet @jedberg with feedback!
  • 63. Why Cassandra? • Availability over consistency • Writes over reads • We know Java • Open source + support Tweet @jedberg with feedback!
  • 64. Tweet @jedberg with feedback!
  • 65. We live in an unreliable world Tweet @jedberg with feedback!
  • 66. Tweet @jedberg with feedback!
  • 67. Tweet @jedberg with feedback!
  • 68. Tweet @jedberg with feedback!
  • 70. Queues are your friend • Votes • Comments • Thumbnail scraper • Precomputed queries • Spam • processing • corrections Tweet @jedberg with feedback!
  • 71. Caching is a good way to hide your failures Tweet @jedberg with feedback!
  • 72. Sometimes users notice your data inconstancy Tweet @jedberg with feedback!
  • 73. EVCache 1 D A 2 3 + C B Tweet @jedberg with feedback!
  • 74. Do you even need a cache? Tweet @jedberg with feedback!
  • 75. Think of SSDs as cheap RAM, not expensive disk Tweet @jedberg with feedback!
  • 76. Going multi-zone or multi-datacenter Tweet @jedberg with feedback!
  • 77. Benefits of Amazon’s Zones • Loosely connected • Low latency between zones • 99.95% uptime guarantee per zone Tweet @jedberg with feedback!
  • 79. Leveraging Mutli-region • 100% uptime is theoretically possible. • You have to replicate your data • This will cost money Tweet @jedberg with feedback!
  • 80. Other options • Backup datacenter • Backup provider Tweet @jedberg with feedback!
  • 81. Cause chaos Tweet @jedberg with feedback!
  • 82. The Monkey Theory • Simulate things that go wrong • Find things that are different Tweet @jedberg with feedback!
  • 83. The simian army • Chaos -- Kills random instances • Latency -- Slows the network down • Conformity -- Looks for outliers • Doctor -- Looks for passing health checks • Janitor -- Cleans up unused resources • Howler -- Yells about bad things Tweet @jedberg with feedback!
  • 84. The Chaos Gorilla Tweet @jedberg with feedback!
  • 85. Automate all the things! Tweet @jedberg with feedback!
  • 86. Automate all the things! • Application startup • Configuration • Code deployment • System deployment Tweet @jedberg with feedback!
  • 87. Incident Reviews Ask the key questions: • What went wrong? • How could we have detected it sooner? • How could we have prevented it? • How can we prevent this class of problem in the future? • How can we improve our behavior for next time? Tweet @jedberg with feedback!
  • 88. The Netflix way • Everything is “built for three” • Fully automated build tools to test and make packages • Fully automated machine image bakery • Fully automated image deployment Tweet @jedberg with feedback!
  • 89. All systems choices assume some part will fail at some point. Tweet @jedberg with feedback!
  • 90. Best Practices • Keep data in multiple Availability Zones / DCs • Avoid keeping state on a single instance Tweet @jedberg with feedback!
  • 91. Best Practices • Isolated Services • Three Balanced AZs • Triple replicated persistence • Isolated Regions Tweet @jedberg with feedback!
  • 92. Best Practices • Don’t trust your dependencies • Have good fallbacks • Use circuit breakers/dependency commands Tweet @jedberg with feedback!
  • 93. Best Practices • Be generous in what you accept and stingy in what you give Tweet @jedberg with feedback!
  • 94. Best Practices • Hope for the best, assume the worst Tweet @jedberg with feedback!
  • 95. Tweet @jedberg with feedback!
  • 96. War Stories Tweet @jedberg with feedback!
  • 97. April 2011 EBS outage Tweet @jedberg with feedback!
  • 98. June 29th Outage • Due to a severe storm, power went out in one AZ • Netflix did not do well because of a bug in our internal mid-tier load balancer • However, Cassandra held up just fine! Tweet @jedberg with feedback!
  • 99. October 29th Outage • EBS degradation in one Zone • We did much better this time • Cassandra just kept running • MySql not as well, but fallbacks kicked in Tweet @jedberg with feedback!
  • 100. Hurricane Sandy The outage that never was Tweet @jedberg with feedback!
  • 101. Just a quick reminder... (Some of) Netflix is open source: https://netflix.github.com/ Tweet @jedberg with feedback!
  • 102. Another reminder... reddit is also open source https://github.com/reddit patches are now being accepted! Tweet @jedberg with feedback!
  • 103. Netflix is hiring http://jobs.netflix.com/jobs.html - or - email talent@netflix.com and tell them jedberg sent you Tweet @jedberg with feedback!
  • 105. Tweet @jedberg with feedback!
  • 106. Getting in touch Email: jedberg@gmail.com Twitter: @jedberg Web: www.jedberg.net Facebook: facebook.com/jedberg Linkedin: www.linkedin.com/in/jedberg reddit: www.reddit.com/user/jedberg Tweet @jedberg with feedback!