SlideShare a Scribd company logo
1 of 48
Download to read offline
Design Patterns for Distributed
  Non-Relational Databases
                  aka
 Just Enough Distributed Systems To Be
               Dangerous
            (in 40 minutes)


             Todd Lipcon
              (@tlipcon)
                 Cloudera


            June 11, 2009
Introduction
Common Underlying Assumptions
Design Patterns
   Consistent Hashing
   Consistency Models
   Data Models
   Storage Layouts
   Log-Structured Merge Trees
Cluster Management
   Omniscient Master
   Gossip
Questions to Ask Presenters
Why We’re All Here


     Scaling up doesn’t work
     Scaling out with traditional RDBMSs isn’t so
     hot either
         Sharding scales, but you lose all the features that
         make RDBMSs useful!
         Sharding is operationally obnoxious.
     If we don’t need relational features, we want a
     distributed NRDBMS.
Closed-source NRDBMSs
“The Inspiration”




           Google BigTable
                    Applications: webtable, Reader, Maps, Blogger,
                    etc.
           Amazon Dynamo
                    Shopping Cart, ?
           Yahoo! PNUTS
                    Applications: ?
Data Interfaces
“This is the NOSQL meetup, right?”




          Every row has a key (PK)
          Key/value get/put
          multiget/multiput
          Range scan? With predicate pushdown?
          MapReduce?
          SQL?
Underlying Assumptions
Assumptions - Data Size


      The data does not fit on one node.
      The data may not fit on one rack.
      SANs are too expensive.

  Conclusion:
  The system must partition its data across many
  nodes.
Assumptions - Reliability
      The system must be highly available to serve
      web (and other) applications.
      Since the system runs on many nodes, nodes
      will crash during normal operation.
      Data must be safe even though disks and
      nodes will fail.

  Conclusion:
  The system must replicate each row to multiple
  nodes and remain available despite certain node and
  disk failure.
Assumptions - Performance
...and price thereof


            All systems we’re talking about today are
            meant for real-time use.
            95th or 99th percentile is more important than
            average latency
            Commodity hardware and slow disks.

     Conclusion:
     The system needs to perform well on commodity
     hardware, and maintain low latency even during
     recovery operations.
Design Patterns
Partitioning Schemes
“Where does a key live?”




          Given a key, we need to determine which
          node(s) it belongs on.
          If that node is down, we need to find another
          copy elsewhere.
          Difficulties:
                 Unbounded number of keys.
                 Dynamic cluster membership.
                 Node failures.
Consistent Hashing
Maintaining hashing in a dynamic cluster
Consistent Hashing
Key Placement
Consistency Models

     A consistency model determines rules for
     visibility and apparent order of updates.
     Example:
         Row X is replicated on nodes M and N
         Client A writes row X to node N
         Some period of time t elapses.
         Client B reads row X from node M
         Does client B see the write from client A?
     Consistency is a continuum with tradeoffs
Strict Consistency

     All read operations must return the data from
     the latest completed write operation, regardless
     of which replica the operations went to
     Implies either:
         All operations for a given row go to the same node
         (replication for availability)
         or nodes employ some kind of distributed
         transaction protocol (eg 2 Phase Commit or Paxos)
     CAP Theorem: Strict Consistency can’t be
     achieved at the same time as availability and
     partition-tolerance.
Eventual Consistency

     As t → ∞, readers will see writes.
     In a steady state, the system is guaranteed to
     eventually return the last written value
     For example: DNS, or MySQL Slave
     Replication (log shipping)
     Special cases of eventual consistency:
         Read-your-own-writes consistency (“sent mail”
         box)
         Causal consistency (if you write Y after reading X,
         anyone who reads Y sees X)
         gmail has RYOW but not causal!
Timestamps and Vector Clocks
Determining a history of a row



           Eventual consistency relies on deciding what
           value a row will eventually converge to
           In the case of two writers writing at “the
           same” time, this is difficult
           Timestamps are one solution, but rely on
           synchronized clocks and don’t capture causality
           Vector clocks are an alternative method of
           capturing order in a distributed system
Vector Clocks

     Definition:
         A vector clock is a tuple {t1 , t2 , ..., tn } of clock
         values from each node
         v1 < v2 if:
               For all i, v1i ≤ v2i
               For at least one i, v1i < v2i
         v1 < v2 implies global time ordering of events
     When data is written from node i, it sets ti to
     its clock value.
     This allows eventual consistency to resolve
     consistency between writes on multiple replicas.
Data Models
What’s in a row?




          Primary Key → Value
          Value could be:
                   Blob
                   Structured (set of columns)
                   Semi-structured (set of column families with
                   arbitrary columns, eg linkto:<url> in webtable)
                   Each has advantages and disadvantages
          Secondary Indexes? Tables/namespaces?
Multi-Version Storage
Using Timestamps for a 3rd dimension



          Each table cell has a timestamp
          Timestamps don’t necessarily need to
          correspond to real life
          Multiple versions (and tombstones) can exist
          concurrently for a given row
          Reads may return “most recent”, “most recent
          before T”, etc. (free snapshots)
          System may provide optimistic concurrency
          control with compare-and-swap on timestamps
Storage Layouts
How do we lay out rows and columns on disk?




          Determines performance of different access
          patterns
          Storage layout maps directly to disk access
          patterns
          Fast writes? Fast reads? Fast scans?
          Whole-row access or subsets of columns?
Row-based Storage




     Pros:
         Good locality of access (on disk and in cache) of
         different columns
         Read/write of a single row is a single IO operation.
     Cons:
         But if you want to scan only one column, you still
         read all.
Columnar Storage




     Pros:
         Data for a given column is stored sequentially
         Scanning a single column (eg aggregate queries) is
         fast
     Cons:
         Reading a single row may seek once per column.
Columnar Storage with Locality Groups




     Columns are organized into families (“locality
     groups”)
     Benefits of row-based layout within a group.
     Benefits of column-based - don’t have to read
     groups you don’t care about.
Log Structured Merge Trees
aka “The BigTable model”

           Random IO for writes is bad (and impossible in
           some DFSs)
           LSM Trees convert random writes to sequential
           writes
           Writes go to a commit log and in-memory
           storage (Memtable)
           The Memtable is occasionally flushed to disk
           (SSTable)
           The disk stores are periodically compacted
    P. E. O’Neil, E. Cheng, D. Gawlick, and E. J. O’Neil. The log-structured merge-tree

    (LSM-tree). Acta Informatica. 1996.
LSM Data Layout
LSM Write Path
LSM Read Path
LSM Read Path + Bloom Filters
LSM Memtable Flush
LSM Compaction
Cluster Management

     Clients need to know where to find data
     (consistent hashing tokens, etc)
     Internal nodes may need to find each other as
     well
     Since nodes may fail and recover, a
     configuration file doesn’t really suffice
     We need a way of keeping some kind of
     consistent view of the cluster state
Omniscient Master

     When nodes join/leave or change state, they
     talk to a master
     That master holds the authoritative view of the
     world
     Pros: simplicity, single consistent view of the
     cluster
     Cons: potential SPOF unless master is made
     highly available. Not partition-tolerant.
Gossip
     Gossip is one method to propagate a view of
     cluster status.
     Every t seconds, on each node:
         The node selects some other node to chat with.
         The node reconciles its view of the cluster with its
         gossip buddy.
         Each node maintains a “timestamp” for itself and
         for the most recent information it has from every
         other node.
     Information about cluster state spreads in
     O(lgn) rounds (eventual consistency)
     Scalable and no SPOF, but state is only
     eventually consistent
Gossip - Initial State
Gossip - Round 1
Gossip - Round 2
Gossip - Round 3
Gossip - Round 4
Questions to Ask Presenters
Scalability and Reliability

      What are the scaling bottlenecks? How does it
      react when overloaded?
      Are there any single points of failure?
      When nodes fail, does the system maintain
      availability of all data?
      Does the system automatically re-replicate
      when replicas are lost?
      When new nodes are added, does the system
      automatically rebalance data?
Performance

     What’s the goal? Batch throughput or request
     latency?
     How many seeks for reads? For writes? How
     many net RTTs?
     What 99th percentile latencies have been
     measured in practice?
     How do failures impact serving latencies?
     What throughput has been measured in
     practice for bulk loads?
Consistency

     What consistency model does the system
     provide?
     What situations would cause a lapse of
     consistency, if any?
     Can consistency semantics be tweaked by
     configuration settings?
     Is there a way to do compare-and-swap on row
     contents for optimistic locking? Multirow?
Cluster Management and Topology

     Does the system have a single master? Does it
     use gossip to spread cluster management data?
     Can it withstand network partitions and still
     provide some level of service?
     Can it be deployed across multiple datacenters
     for disaster recovery?
     Can nodes be commissioned/decomissioned
     automatically without downtime?
     Operational hooks for monitoring and metrics?
Data Model and Storage

     What data model and storage system does the
     system provide?
     Is it pluggable?
     What IO patterns does the system cause under
     different workloads?
     Is the system best at random or sequential
     access? For read-mostly or write-mostly?
     Are there practical limits on key, value, or row
     sizes?
     Is compression available?
Data Access Methods


     What methods exist for accessing data? Can I
     access it from language X?
     Is there a way to perform filtering or selection
     at the server side?
     Are there bulk load tools to get data in/out
     efficiently?
     Is there a provision for data backup/restore?
Real Life Considerations
(I was talking about fake life in the first 45 slides)

            Who uses this system? How big are the
            clusters it’s deployed on, and what kind of load
            do they handle?
            Who develops this system? Is this a community
            project or run by a single organization? Are
            outside contributions regularly accepted?
            Who supports this system? Is there an active
            community who will help me deploy it and
            debug issues? Docs?
            What is the open source license?
            What is the development roadmap?
Questions?
http://cloudera-todd.s3.amazonaws.com/nosql.pdf

More Related Content

What's hot

A request skew aware heterogeneous distributed
A request skew aware heterogeneous distributedA request skew aware heterogeneous distributed
A request skew aware heterogeneous distributedJoão Gabriel Lima
 
Distributed Systems Theory for Mere Mortals
Distributed Systems Theory for Mere MortalsDistributed Systems Theory for Mere Mortals
Distributed Systems Theory for Mere MortalsEnsar Basri Kahveci
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandraWu Liang
 
Pacemaker+DRBD
Pacemaker+DRBDPacemaker+DRBD
Pacemaker+DRBDDan Frincu
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency TradingViktor Sovietov
 
The Apache Cassandra ecosystem
The Apache Cassandra ecosystemThe Apache Cassandra ecosystem
The Apache Cassandra ecosystemAlex Thompson
 

What's hot (8)

A request skew aware heterogeneous distributed
A request skew aware heterogeneous distributedA request skew aware heterogeneous distributed
A request skew aware heterogeneous distributed
 
Distributed Systems Theory for Mere Mortals
Distributed Systems Theory for Mere MortalsDistributed Systems Theory for Mere Mortals
Distributed Systems Theory for Mere Mortals
 
Dynamo cassandra
Dynamo cassandraDynamo cassandra
Dynamo cassandra
 
Pacemaker+DRBD
Pacemaker+DRBDPacemaker+DRBD
Pacemaker+DRBD
 
chubby_osdi06
chubby_osdi06chubby_osdi06
chubby_osdi06
 
Java in High Frequency Trading
Java in High Frequency TradingJava in High Frequency Trading
Java in High Frequency Trading
 
Cassandra
CassandraCassandra
Cassandra
 
The Apache Cassandra ecosystem
The Apache Cassandra ecosystemThe Apache Cassandra ecosystem
The Apache Cassandra ecosystem
 

Viewers also liked

Linux性能监控cpu内存io网络
Linux性能监控cpu内存io网络Linux性能监控cpu内存io网络
Linux性能监控cpu内存io网络lovingprince58
 
Taobao 海量图片存储与CDN系统02
Taobao 海量图片存储与CDN系统02Taobao 海量图片存储与CDN系统02
Taobao 海量图片存储与CDN系统02lovingprince58
 
分布式Key-value漫谈
分布式Key-value漫谈分布式Key-value漫谈
分布式Key-value漫谈lovingprince58
 
淘宝软件基础设施构建实践
淘宝软件基础设施构建实践淘宝软件基础设施构建实践
淘宝软件基础设施构建实践lovingprince58
 
[Python参考手册(第4版)].(美)比兹利.扫描版
[Python参考手册(第4版)].(美)比兹利.扫描版[Python参考手册(第4版)].(美)比兹利.扫描版
[Python参考手册(第4版)].(美)比兹利.扫描版lovingprince58
 
Google big table 中文版
Google big table 中文版Google big table 中文版
Google big table 中文版lovingprince58
 
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版lovingprince58
 
Irvine_Eric_Ignite
Irvine_Eric_IgniteIrvine_Eric_Ignite
Irvine_Eric_Igniteericirv
 
Jvm内存问题最佳实践
Jvm内存问题最佳实践Jvm内存问题最佳实践
Jvm内存问题最佳实践lovingprince58
 
Jetty服务器架构及调优.v2 2011-5
Jetty服务器架构及调优.v2 2011-5Jetty服务器架构及调优.v2 2011-5
Jetty服务器架构及调优.v2 2011-5lovingprince58
 

Viewers also liked (12)

No sql数据库笔谈
No sql数据库笔谈No sql数据库笔谈
No sql数据库笔谈
 
Linux性能监控cpu内存io网络
Linux性能监控cpu内存io网络Linux性能监控cpu内存io网络
Linux性能监控cpu内存io网络
 
Taobao 海量图片存储与CDN系统02
Taobao 海量图片存储与CDN系统02Taobao 海量图片存储与CDN系统02
Taobao 海量图片存储与CDN系统02
 
分布式Key-value漫谈
分布式Key-value漫谈分布式Key-value漫谈
分布式Key-value漫谈
 
淘宝软件基础设施构建实践
淘宝软件基础设施构建实践淘宝软件基础设施构建实践
淘宝软件基础设施构建实践
 
[Python参考手册(第4版)].(美)比兹利.扫描版
[Python参考手册(第4版)].(美)比兹利.扫描版[Python参考手册(第4版)].(美)比兹利.扫描版
[Python参考手册(第4版)].(美)比兹利.扫描版
 
Google big table 中文版
Google big table 中文版Google big table 中文版
Google big table 中文版
 
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版
[Python.cookbook(第2版)中文版].(美)马特利,(美)阿舍尔.扫描版
 
Trade show photo album
Trade show photo albumTrade show photo album
Trade show photo album
 
Irvine_Eric_Ignite
Irvine_Eric_IgniteIrvine_Eric_Ignite
Irvine_Eric_Ignite
 
Jvm内存问题最佳实践
Jvm内存问题最佳实践Jvm内存问题最佳实践
Jvm内存问题最佳实践
 
Jetty服务器架构及调优.v2 2011-5
Jetty服务器架构及调优.v2 2011-5Jetty服务器架构及调优.v2 2011-5
Jetty服务器架构及调优.v2 2011-5
 

Similar to Design Patterns For Distributed NO-reational databases

Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databasesguestdfd1ec
 
Basics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageBasics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageNilesh Salpe
 
Lecture-04-Principles of data management.pdf
Lecture-04-Principles of data management.pdfLecture-04-Principles of data management.pdf
Lecture-04-Principles of data management.pdfmanimozhi98
 
Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupAdam Hutson
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless DatabasesDan Gunter
 
Handling Data in Mega Scale Web Systems
Handling Data in Mega Scale Web SystemsHandling Data in Mega Scale Web Systems
Handling Data in Mega Scale Web SystemsVineet Gupta
 
CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduceCS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduceJ Singh
 
Spinnaker VLDB 2011
Spinnaker VLDB 2011Spinnaker VLDB 2011
Spinnaker VLDB 2011sandeep_tata
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed CoordinationLuis Galárraga
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraFolio3 Software
 
Distributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityDistributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityRenato Lucindo
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsFirat Atagun
 
Data Engineering for Data Scientists
Data Engineering for Data Scientists Data Engineering for Data Scientists
Data Engineering for Data Scientists jlacefie
 
Everything you always wanted to know about Distributed databases, at devoxx l...
Everything you always wanted to know about Distributed databases, at devoxx l...Everything you always wanted to know about Distributed databases, at devoxx l...
Everything you always wanted to know about Distributed databases, at devoxx l...javier ramirez
 
Distributed systems and scalability rules
Distributed systems and scalability rulesDistributed systems and scalability rules
Distributed systems and scalability rulesOleg Tsal-Tsalko
 

Similar to Design Patterns For Distributed NO-reational databases (20)

Design Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational DatabasesDesign Patterns for Distributed Non-Relational Databases
Design Patterns for Distributed Non-Relational Databases
 
Basics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed StorageBasics of Distributed Systems - Distributed Storage
Basics of Distributed Systems - Distributed Storage
 
Lecture-04-Principles of data management.pdf
Lecture-04-Principles of data management.pdfLecture-04-Principles of data management.pdf
Lecture-04-Principles of data management.pdf
 
Cassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User GroupCassandra & Python - Springfield MO User Group
Cassandra & Python - Springfield MO User Group
 
Schemaless Databases
Schemaless DatabasesSchemaless Databases
Schemaless Databases
 
NoSql Database
NoSql DatabaseNoSql Database
NoSql Database
 
Cassandra
CassandraCassandra
Cassandra
 
Handling Data in Mega Scale Web Systems
Handling Data in Mega Scale Web SystemsHandling Data in Mega Scale Web Systems
Handling Data in Mega Scale Web Systems
 
CS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduceCS 542 Parallel DBs, NoSQL, MapReduce
CS 542 Parallel DBs, NoSQL, MapReduce
 
Cassandra
CassandraCassandra
Cassandra
 
Spinnaker VLDB 2011
Spinnaker VLDB 2011Spinnaker VLDB 2011
Spinnaker VLDB 2011
 
No sql (not only sql)
No sql                 (not only sql)No sql                 (not only sql)
No sql (not only sql)
 
A Quick Look At Cassandra
A Quick Look At CassandraA Quick Look At Cassandra
A Quick Look At Cassandra
 
Distributed Coordination
Distributed CoordinationDistributed Coordination
Distributed Coordination
 
NOSQL Database: Apache Cassandra
NOSQL Database: Apache CassandraNOSQL Database: Apache Cassandra
NOSQL Database: Apache Cassandra
 
Distributed Systems: scalability and high availability
Distributed Systems: scalability and high availabilityDistributed Systems: scalability and high availability
Distributed Systems: scalability and high availability
 
NoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, ImplementationsNoSQL Introduction, Theory, Implementations
NoSQL Introduction, Theory, Implementations
 
Data Engineering for Data Scientists
Data Engineering for Data Scientists Data Engineering for Data Scientists
Data Engineering for Data Scientists
 
Everything you always wanted to know about Distributed databases, at devoxx l...
Everything you always wanted to know about Distributed databases, at devoxx l...Everything you always wanted to know about Distributed databases, at devoxx l...
Everything you always wanted to know about Distributed databases, at devoxx l...
 
Distributed systems and scalability rules
Distributed systems and scalability rulesDistributed systems and scalability rules
Distributed systems and scalability rules
 

Recently uploaded

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialJoão Esperancinha
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesManik S Magar
 

Recently uploaded (20)

Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Kuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorialKuma Meshes Part I - The basics - A tutorial
Kuma Meshes Part I - The basics - A tutorial
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyesHow to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
How to Effectively Monitor SD-WAN and SASE Environments with ThousandEyes
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotesMuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
MuleSoft Online Meetup Group - B2B Crash Course: Release SparkNotes
 

Design Patterns For Distributed NO-reational databases

  • 1. Design Patterns for Distributed Non-Relational Databases aka Just Enough Distributed Systems To Be Dangerous (in 40 minutes) Todd Lipcon (@tlipcon) Cloudera June 11, 2009
  • 2. Introduction Common Underlying Assumptions Design Patterns Consistent Hashing Consistency Models Data Models Storage Layouts Log-Structured Merge Trees Cluster Management Omniscient Master Gossip Questions to Ask Presenters
  • 3. Why We’re All Here Scaling up doesn’t work Scaling out with traditional RDBMSs isn’t so hot either Sharding scales, but you lose all the features that make RDBMSs useful! Sharding is operationally obnoxious. If we don’t need relational features, we want a distributed NRDBMS.
  • 4. Closed-source NRDBMSs “The Inspiration” Google BigTable Applications: webtable, Reader, Maps, Blogger, etc. Amazon Dynamo Shopping Cart, ? Yahoo! PNUTS Applications: ?
  • 5. Data Interfaces “This is the NOSQL meetup, right?” Every row has a key (PK) Key/value get/put multiget/multiput Range scan? With predicate pushdown? MapReduce? SQL?
  • 7. Assumptions - Data Size The data does not fit on one node. The data may not fit on one rack. SANs are too expensive. Conclusion: The system must partition its data across many nodes.
  • 8. Assumptions - Reliability The system must be highly available to serve web (and other) applications. Since the system runs on many nodes, nodes will crash during normal operation. Data must be safe even though disks and nodes will fail. Conclusion: The system must replicate each row to multiple nodes and remain available despite certain node and disk failure.
  • 9. Assumptions - Performance ...and price thereof All systems we’re talking about today are meant for real-time use. 95th or 99th percentile is more important than average latency Commodity hardware and slow disks. Conclusion: The system needs to perform well on commodity hardware, and maintain low latency even during recovery operations.
  • 11. Partitioning Schemes “Where does a key live?” Given a key, we need to determine which node(s) it belongs on. If that node is down, we need to find another copy elsewhere. Difficulties: Unbounded number of keys. Dynamic cluster membership. Node failures.
  • 14. Consistency Models A consistency model determines rules for visibility and apparent order of updates. Example: Row X is replicated on nodes M and N Client A writes row X to node N Some period of time t elapses. Client B reads row X from node M Does client B see the write from client A? Consistency is a continuum with tradeoffs
  • 15. Strict Consistency All read operations must return the data from the latest completed write operation, regardless of which replica the operations went to Implies either: All operations for a given row go to the same node (replication for availability) or nodes employ some kind of distributed transaction protocol (eg 2 Phase Commit or Paxos) CAP Theorem: Strict Consistency can’t be achieved at the same time as availability and partition-tolerance.
  • 16. Eventual Consistency As t → ∞, readers will see writes. In a steady state, the system is guaranteed to eventually return the last written value For example: DNS, or MySQL Slave Replication (log shipping) Special cases of eventual consistency: Read-your-own-writes consistency (“sent mail” box) Causal consistency (if you write Y after reading X, anyone who reads Y sees X) gmail has RYOW but not causal!
  • 17. Timestamps and Vector Clocks Determining a history of a row Eventual consistency relies on deciding what value a row will eventually converge to In the case of two writers writing at “the same” time, this is difficult Timestamps are one solution, but rely on synchronized clocks and don’t capture causality Vector clocks are an alternative method of capturing order in a distributed system
  • 18. Vector Clocks Definition: A vector clock is a tuple {t1 , t2 , ..., tn } of clock values from each node v1 < v2 if: For all i, v1i ≤ v2i For at least one i, v1i < v2i v1 < v2 implies global time ordering of events When data is written from node i, it sets ti to its clock value. This allows eventual consistency to resolve consistency between writes on multiple replicas.
  • 19. Data Models What’s in a row? Primary Key → Value Value could be: Blob Structured (set of columns) Semi-structured (set of column families with arbitrary columns, eg linkto:<url> in webtable) Each has advantages and disadvantages Secondary Indexes? Tables/namespaces?
  • 20. Multi-Version Storage Using Timestamps for a 3rd dimension Each table cell has a timestamp Timestamps don’t necessarily need to correspond to real life Multiple versions (and tombstones) can exist concurrently for a given row Reads may return “most recent”, “most recent before T”, etc. (free snapshots) System may provide optimistic concurrency control with compare-and-swap on timestamps
  • 21. Storage Layouts How do we lay out rows and columns on disk? Determines performance of different access patterns Storage layout maps directly to disk access patterns Fast writes? Fast reads? Fast scans? Whole-row access or subsets of columns?
  • 22. Row-based Storage Pros: Good locality of access (on disk and in cache) of different columns Read/write of a single row is a single IO operation. Cons: But if you want to scan only one column, you still read all.
  • 23. Columnar Storage Pros: Data for a given column is stored sequentially Scanning a single column (eg aggregate queries) is fast Cons: Reading a single row may seek once per column.
  • 24. Columnar Storage with Locality Groups Columns are organized into families (“locality groups”) Benefits of row-based layout within a group. Benefits of column-based - don’t have to read groups you don’t care about.
  • 25. Log Structured Merge Trees aka “The BigTable model” Random IO for writes is bad (and impossible in some DFSs) LSM Trees convert random writes to sequential writes Writes go to a commit log and in-memory storage (Memtable) The Memtable is occasionally flushed to disk (SSTable) The disk stores are periodically compacted P. E. O’Neil, E. Cheng, D. Gawlick, and E. J. O’Neil. The log-structured merge-tree (LSM-tree). Acta Informatica. 1996.
  • 29. LSM Read Path + Bloom Filters
  • 32. Cluster Management Clients need to know where to find data (consistent hashing tokens, etc) Internal nodes may need to find each other as well Since nodes may fail and recover, a configuration file doesn’t really suffice We need a way of keeping some kind of consistent view of the cluster state
  • 33. Omniscient Master When nodes join/leave or change state, they talk to a master That master holds the authoritative view of the world Pros: simplicity, single consistent view of the cluster Cons: potential SPOF unless master is made highly available. Not partition-tolerant.
  • 34. Gossip Gossip is one method to propagate a view of cluster status. Every t seconds, on each node: The node selects some other node to chat with. The node reconciles its view of the cluster with its gossip buddy. Each node maintains a “timestamp” for itself and for the most recent information it has from every other node. Information about cluster state spreads in O(lgn) rounds (eventual consistency) Scalable and no SPOF, but state is only eventually consistent
  • 40. Questions to Ask Presenters
  • 41. Scalability and Reliability What are the scaling bottlenecks? How does it react when overloaded? Are there any single points of failure? When nodes fail, does the system maintain availability of all data? Does the system automatically re-replicate when replicas are lost? When new nodes are added, does the system automatically rebalance data?
  • 42. Performance What’s the goal? Batch throughput or request latency? How many seeks for reads? For writes? How many net RTTs? What 99th percentile latencies have been measured in practice? How do failures impact serving latencies? What throughput has been measured in practice for bulk loads?
  • 43. Consistency What consistency model does the system provide? What situations would cause a lapse of consistency, if any? Can consistency semantics be tweaked by configuration settings? Is there a way to do compare-and-swap on row contents for optimistic locking? Multirow?
  • 44. Cluster Management and Topology Does the system have a single master? Does it use gossip to spread cluster management data? Can it withstand network partitions and still provide some level of service? Can it be deployed across multiple datacenters for disaster recovery? Can nodes be commissioned/decomissioned automatically without downtime? Operational hooks for monitoring and metrics?
  • 45. Data Model and Storage What data model and storage system does the system provide? Is it pluggable? What IO patterns does the system cause under different workloads? Is the system best at random or sequential access? For read-mostly or write-mostly? Are there practical limits on key, value, or row sizes? Is compression available?
  • 46. Data Access Methods What methods exist for accessing data? Can I access it from language X? Is there a way to perform filtering or selection at the server side? Are there bulk load tools to get data in/out efficiently? Is there a provision for data backup/restore?
  • 47. Real Life Considerations (I was talking about fake life in the first 45 slides) Who uses this system? How big are the clusters it’s deployed on, and what kind of load do they handle? Who develops this system? Is this a community project or run by a single organization? Are outside contributions regularly accepted? Who supports this system? Is there an active community who will help me deploy it and debug issues? Docs? What is the open source license? What is the development roadmap?