SlideShare uma empresa Scribd logo
1 de 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!

Mais conteúdo relacionado

Mais 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
 

Mais 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?
 

Último

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 

Último (20)

Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 

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!