Today s topics. FAQs. Topics in BigTable. This material is built based on, CS435 Introduction to Big Data Spring 2017 Colorado State University

Similar documents
FAQs Snapshots and locks Vector Clock

11/12/2018 Week 13-A Sangmi Lee Pallickara. CS435 Introduction to Big Data FALL 2018 Colorado State University

CS Amazon Dynamo

Bigtable. Presenter: Yijun Hou, Yixiao Peng

DYNAMO: AMAZON S HIGHLY AVAILABLE KEY-VALUE STORE. Presented by Byungjin Jun

Introduction Data Model API Building Blocks SSTable Implementation Tablet Location Tablet Assingment Tablet Serving Compactions Refinements

CAP Theorem, BASE & DynamoDB

Dynamo: Amazon s Highly Available Key-Value Store

Dynamo: Amazon s Highly Available Key-value Store. ID2210-VT13 Slides by Tallat M. Shafaat

Dynamo: Amazon s Highly Available Key-value Store

Bigtable: A Distributed Storage System for Structured Data By Fay Chang, et al. OSDI Presented by Xiang Gao

Presented By: Devarsh Patel

Scaling Out Key-Value Storage

Horizontal or vertical scalability? Horizontal scaling is challenging. Today. Scaling Out Key-Value Storage

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Dynamo. Smruti R. Sarangi. Department of Computer Science Indian Institute of Technology New Delhi, India. Motivation System Architecture Evaluation

CS 138: Dynamo. CS 138 XXIV 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

BigTable A System for Distributed Structured Storage

Bigtable: A Distributed Storage System for Structured Data. Andrew Hon, Phyllis Lau, Justin Ng

CSE 444: Database Internals. Lectures 26 NoSQL: Extensible Record Stores

CS 655 Advanced Topics in Distributed Systems

Dynamo: Amazon s Highly Available Key-value Store

Big Table. Google s Storage Choice for Structured Data. Presented by Group E - Dawei Yang - Grace Ramamoorthy - Patrick O Sullivan - Rohan Singla

BigTable: A System for Distributed Structured Storage

Dynamo: Key-Value Cloud Storage

CS535 Big Data Fall 2017 Colorado State University 11/7/2017 Sangmi Lee Pallickara Week 12- A.

References. What is Bigtable? Bigtable Data Model. Outline. Key Features. CSE 444: Database Internals

Scaling KVS. CS6450: Distributed Systems Lecture 14. Ryan Stutsman

CS November 2017

CSE-E5430 Scalable Cloud Computing Lecture 9

BigTable: A Distributed Storage System for Structured Data (2006) Slides adapted by Tyler Davis

Dynamo: Amazon s Highly Available Key-value Store

Distributed Systems. 16. Distributed Lookup. Paul Krzyzanowski. Rutgers University. Fall 2017

BigTable. CSE-291 (Cloud Computing) Fall 2016

Distributed Hash Tables Chord and Dynamo

There is a tempta7on to say it is really used, it must be good

Bigtable: A Distributed Storage System for Structured Data by Google SUNNIE CHUNG CIS 612

Recap. CSE 486/586 Distributed Systems Case Study: Amazon Dynamo. Amazon Dynamo. Amazon Dynamo. Necessary Pieces? Overview of Key Design Techniques

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2017)

Recap. CSE 486/586 Distributed Systems Case Study: Amazon Dynamo. Amazon Dynamo. Amazon Dynamo. Necessary Pieces? Overview of Key Design Techniques

CS November 2018

Structured Big Data 1: Google Bigtable & HBase Shiow-yang Wu ( 吳秀陽 ) CSIE, NDHU, Taiwan, ROC

Big Data Infrastructure CS 489/698 Big Data Infrastructure (Winter 2016)

Distributed Systems [Fall 2012]

Distributed File Systems II

Introduction to Distributed Data Systems

Bigtable. A Distributed Storage System for Structured Data. Presenter: Yunming Zhang Conglong Li. Saturday, September 21, 13

Outline. Spanner Mo/va/on. Tom Anderson

Indexing Large-Scale Data

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2015 Lecture 14 NoSQL

Extreme Computing. NoSQL.

Google File System and BigTable. and tiny bits of HDFS (Hadoop File System) and Chubby. Not in textbook; additional information

Reprise: Stability under churn (Tapestry) A Simple lookup Test. Churn (Optional Bamboo paper last time)

ΕΠΛ 602:Foundations of Internet Technologies. Cloud Computing

BigTable. Chubby. BigTable. Chubby. Why Chubby? How to do consensus as a service

Background. Distributed Key/Value stores provide a simple put/get interface. Great properties: scalability, availability, reliability

Federated Array of Bricks Y Saito et al HP Labs. CS 6464 Presented by Avinash Kulkarni

BigTable: A Distributed Storage System for Structured Data

10. Replication. Motivation

EECS 498 Introduction to Distributed Systems

The Google File System

big picture parallel db (one data center) mix of OLTP and batch analysis lots of data, high r/w rates, 1000s of cheap boxes thus many failures

CLOUD-SCALE FILE SYSTEMS

Bigtable: A Distributed Storage System for Structured Data

CSE 544 Principles of Database Management Systems. Magdalena Balazinska Winter 2009 Lecture 12 Google Bigtable

Ghislain Fourny. Big Data 5. Wide column stores

The Google File System

18-hdfs-gfs.txt Thu Oct 27 10:05: Notes on Parallel File Systems: HDFS & GFS , Fall 2011 Carnegie Mellon University Randal E.

References. NoSQL Motivation. Why NoSQL as the Solution? NoSQL Key Feature Decisions. CSE 444: Database Internals

Bigtable: A Distributed Storage System for Structured Data

6.830 Lecture Spark 11/15/2017

Cassandra- A Distributed Database

Dynamo Tom Anderson and Doug Woos

Goal of the presentation is to give an introduction of NoSQL databases, why they are there.

The Google File System

Google Data Management

CA485 Ray Walshe NoSQL

18-hdfs-gfs.txt Thu Nov 01 09:53: Notes on Parallel File Systems: HDFS & GFS , Fall 2012 Carnegie Mellon University Randal E.

Cassandra Design Patterns

Database Architectures

SQL, NoSQL, MongoDB. CSE-291 (Cloud Computing) Fall 2016 Gregory Kesden

Bigtable: A Distributed Storage System for Structured Data

CS655: Advanced Topics in Distributed Systems [Fall 2013] Dept. Of Computer Science, Colorado State University

CS5412: OTHER DATA CENTER SERVICES

Design & Implementation of Cloud Big table

CS /29/18. Paul Krzyzanowski 1. Question 1 (Bigtable) Distributed Systems 2018 Pre-exam 3 review Selected questions from past exams

Chord : A Scalable Peer-to-Peer Lookup Protocol for Internet Applications

Distributed Systems Pre-exam 3 review Selected questions from past exams. David Domingo Paul Krzyzanowski Rutgers University Fall 2018

The Google File System

7680: Distributed Systems

DIVING IN: INSIDE THE DATA CENTER

The Google File System

CS /15/16. Paul Krzyzanowski 1. Question 1. Distributed Systems 2016 Exam 2 Review. Question 3. Question 2. Question 5.

Migrating to Cassandra in the Cloud, the Netflix Way

Distributed Systems. Fall 2017 Exam 3 Review. Paul Krzyzanowski. Rutgers University. Fall 2017

Performance and Forgiveness. June 23, 2008 Margo Seltzer Harvard University School of Engineering and Applied Sciences

Big Data Processing Technologies. Chentao Wu Associate Professor Dept. of Computer Science and Engineering

Chord: A Scalable Peer-to-peer Lookup Service For Internet Applications

Finding Data in the Cloud using Distributed Hash Tables (Chord) IBM Haifa Research Storage Systems

Cassandra - A Decentralized Structured Storage System. Avinash Lakshman and Prashant Malik Facebook

Transcription:

Spring 07 CS5 BIG DATA Today s topics FAQs BigTable: Column-based storage system PART. DATA STORAGE AND FLOW MANAGEMENT Sangmi Lee Pallickara Computer Science, http://www.cs.colostate.edu/~cs5 FAQs PA help session April 7 th, :00PM ~ :50PM CSB0 Data Storage and flow management Column Family Stores Google Big Table This material is built based on, Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C. Hsieh, Debora A. Wallach, Mike Byrrows, Tushar Chandra, Andrew Fikes, and Robert E. Gruber, Bigtable: A Distributed Storage System for Structured Data, OSDI 006 5 Topics in BigTable. Data model. Locating tablet. Data Compaction. Data Compression 5. Caching and prefetching

Spring 07 6 7 System Structure BigTable master Performs metadata ops + load balancing BigTable client BigTable client library Column Family Stores: Big Table. Locating Tablet BigTable tablet BigTable tablet BigTable tablet server server server Serves data Serves data Serves data Cluster scheduling system Handles failover, monitoring GFS Holds tablet data, logs Lock service Holds metadata, handles master-collection 8 Building blocks (/) Memtable: in-memory table writes goes to log then to in-memory table Periodically data are moved from memory table to disk (using SSTable file format) The Google SSTable (Sorted String Table) file format Internally used to store the contents of a part of table (Tablet) Persistently ordered immutable map from key to values s and values are arbitrary byte strings Tablet All of the SSTables for one key range + memtable 9 Building blocks (/) SSTable contains a sequence of blocks 6KB, configurable Block index Stored at the end of SSTable Index is loaded into memory when the SSTable is opened SSTable is used by: Cassandra, Hbase, LevelDB Open-source implementation http://code.google.com/p/leveldb/ 0 SSTable: Sorted String Table Reading and writing data can dominate running time Random reads and writes are critical features SSTable Value Value Value Index Offset Offset Offset Offset Access to the block In-memory map of keys to {SSTables, memtable} Lookup can be performed with a single disk seek Find the block by performing a binary search of the in-memory index Read the block from disk

Spring 07 Locating tablets [/] Since tablets move around from server to server, given a row, how do clients find the right machine? Need to find tablet whose row range covers the target row Using the BigTable master Aggressive prefetching+caching Most ops go right to proper machine Locating tablets [/] -level hierarchical lookup scheme for tablets Location is ip:port of relevant server st level: bootstrapped from Chubby (lock service), points to the root tablet nd level: Uses root tablet data to find owner(node) of appropriate metadata tablets rd level: metadata table holds locations of tablets of all other tables Metadata tablet itself can be split into multiple tablets Root tablet Other metadata tablet Actual tablet in tablet T Central server almost certainly would be bottleneck in large system Instead: store special tables containing tablet location info in BigTable cell itself Pointer to META0 location Stored in lock service Chubby file Row per META table tablet Row per non-meta tablet(all tables) 5 Caching the tablet locations [/] Root tablet is never split To ensure that the tablet location hierarchy has no more than levels Metadata tablet Stores the location of a tablet under a row key Tablet s identifier and its end row Each metadata row stores approximately KB of data in memory Average limit of 8MB Metadata tablets tablets are addressed Client library caches tablet locations Traverses up the tablet location hierarchy If the client does not know the location of a tablet If it discovers that the cached location information is incorrect 6 Caching the tablet locations [/] 7 Caching the tablet locations [/] If the client s cache is empty? One read from Chubby One read from root tablet One read from metadata tablet Three network round-trips is required to locate the tablet Root tablet Other metadata tablet Actual tablet in tablet T Pointer to META0 location If the client s cache is stale? With given information, client could not find the data What is the maximum round-trips needed (If the root server has not changed)? Pointer to META0 location Root tablet Other metadata tablet Actual tablet in tablet T Stored in lock service Chubby file Row per META table tablet Row per non-meta tablet(all tables) Stored in lock service Chubby file Row per META table tablet Row per non-meta tablet(all tables)

b- b- CS5 Introduction to Big Data Spring 07 8 Caching the tablet server locations [/] If the client s cache is stale? With given information, client could not find the data Up to 5 round trips (if the root server has not changed) First round: user accesses tablet and misses data (arrow ) If only the tablet information is staled additional rounds to locate tablet info from the metadata tables (a-, a-) If the metadata table info is also staled additional rounds To the metadata table (it misses tablet info due to the stale info) (b-) To the root server to retrieve the location of the metadata table (b-) To the metadata table to retrieve the tablet server location(b-) Locate tablet from the tablet server(b-) b- a- a- 9 Prefetching tablet locations Client library reads the metadata for more than one tablet Whenever it reads the metadata table No GFS accesses are required Table locations are stored in memory Chubby b- Root tablet Metadata tablet Actual tablet in tablet T 0 Tablet Assignment (/) Each tablet is assigned to one tablet server at a time The master keeps track of: The set of live tablet servers Which tablets are assigned New tablet assignment The master assigns the tablet by sending a tablet load request to the tablet server Tablet Assignment (/) A tablet server starts Chubby creates a uniquely-named file in a specific Chubby directory Exclusive lock Master monitors this directory to discover tablet servers A tablet server terminates Release its lock Master will reassign its tablets more quickly Tablet status The persistent state of a tablet is stored in GFS Tablet Representation read Write buffer in memory (random-access) MemTable Memory Append-only log on GFS GFS write SSTable on GFS SSTable on GFS SSTable on GFS Tablet server SSTable: immutable on-disk ordered map from stringà string String keys <row, column, timestamp> triples

Spring 07 write operation The tablet server checks, If the data is well-formed If the user is authorized to mutate data Operation is committed to a log file The contents are inserted into the MemTable 5 read operation Tablet server checks If the request is well-formed If the user is authorized to read data Merged view of MemTable(in memory) and SSTable(in disk) Read operation is performed 6 7 Data Compaction and Compression What is the difference between data compaction and data compression? Column Family Stores: Big Table. Data Compaction 8 Minor Compactions As write operations executed The size of the memtable increases Minor compaction When the memtable size reaches a threshold The memtable is frozen A new memtable is created A frozen memtable is converted to an SSTable (stored in GFS) Shrinks the memory usage in the tablet server Reduces the amount of data that has to be read from the commit log during recovery (if the server dies) 9 Merging Compaction New SSTable from the minor compaction will increase Read operations need to merge updates from large number of SSTables Merging Compaction Bounds the number of such files periodically Reads the contents of a few SSTables and the memtable and writes out a new SSTable Input SSTables and memtable can be discarded as soon as the merging compaction has finished 5

Spring 07 0 Major Compaction Rewrites multiple SSTables into exactly one SSTable No deletion information or deleted data included Data Compaction: Log-Structured Merge (LSM) Trees Background Sequential IO vs. Random IO Sequential access to disk (magnetic or SSD) is at least three orders of magnitude faster than random IO Journaling, logging or a heap file is fully sequential 00-00 MB/s per drive But transitional logs are only really applicable to SIMPLE workloads Data is accessed entirely Data is accessed by a known offset Do we have sequential datasets in BigTable? 5 Existing approaches to improve performance Hash B+ tree External file: create separate hash or tree index Adding index structure improves read performance It will slow down write performance Update structure and index Log-structured merge trees Fully disk-centric Small memory footage Improved write performance Read performance is still slightly poorer than B+ tree 6

Spring 07 6 Basic idea of LSM trees LSM trees manage batches of writes to be saved Each file contains a batch of changes covering a short period of time Each file is sorted before it is written Files are immutable New updates will create new files Reads inspect all files Periodically files are merged 7 In-memory buffer for LSM (MemTable) Data is stored as a tree (Red-Black, B-tree etc) to preserve keyordering MemTable is replicated on disk as a write-ahead-log When the MemTable fills the sorted data is flushed to a new file on disk Only sequential IO is performed Each file represents a small, chronological subset of changes (sorted) Periodically the system performs a compaction 8 Conceptual view of rolling merge 9 Locality groups C tree C0 tree Clients can group multiple column families together into a locality group Separate SSTable is generated for each locality group in each tablet DISK Memory Example Locality group : Page metadata in Webtable Language and checksum Locality group : Contents of the page Application reading the metadata does not need to read through all of the page content DISK Memory 0 Compression Column Family Stores: Big Table. Data Compression Compression is required for the data stored in BigTable Similar values in the same row/column With different timestamps Similar values in different columns Similar values across adjacent rows Clients can control whether or not the SSTables for a locality group are compressed User specifies the locality group to be compressed and the compression scheme Keep blocks small for random access (~6KB compressed data) Low CPU cost for encoding/decoding Server does not need to encode/decode entire table to access a portion of it 7

Spring 07 Two-pass compression scheme Data to be compressed s in BigTable (row, column and timestamp) Sorted strings Values in BigTable BMDiff (Bentley and McIlroy s Scheme) across all values in one family BMDiff output for values..n is dictionary for value N+ Zippy is used for final pass over whole block Localized repetitions Cross-column-family repetition, compresses keys First pass: BMDiff Second pass: Zippy (now called as snappy) BMDiff Jon Bentley, Douglas McIlroy, Data compression using long common strings In Data Compression Conference (999), pp. 87-95 Adapted to VCDiff (RFC8) Shared Dictionary Compression over HTTP (SDCH) Chrome browser http://tools.ietf.org/html/rfc8 Example of the Constitution of the US and the King James Bible File Text gzip Relative compressed size Const Const+Const Bible Bible+Bible 95 96.0 9906 66.9 60056 95.0 890 689.9995 J. Bentley and D. McIlroy, "Data compression using long common strings," Data Compression Conference, 999. Proceedings. DCC '99, Snowbird, UT, 999, pp. 87-95. doi: 0.09/DCC.999.755678 http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=755678&isnumber=675 5 Text and blocks Recognizes the second occurrence of the input text as a repetition The second string is represented with a reference to the first Finding long common strings The compression block size b Between 0 and 000 Ignore repeated strings of length less than b For the file with length n n/b fingerprints will be stored Hash table To find common fingerprints and locate common strings 6 The compression algorithm Representing the common string <start, length> start: initial position length: size of the common sequence 7 Implementation of Data compression Hash table of fingertable Lookup the hash table Text Calculate hash value e.g. the Constitution of the United States PREAMBLE We, the people of the United States, in order to form a more perfect Union, à the Constitution of the United States PREAMBLE We, the people <6,>, in order to form a more perfect Union, If there is no match, this value is added 8

Spring 07 8 What if we find a match? b = 00 The current block of length b matches block 56 We could encode that single block as <5600, 00> This scheme guarantees not to encode any common sequences less than b 9 Results Compression Bible Bible+Bible Input gzip com50 com0 com50 gzip com0 gzip 60056 890 95 689 80 8 90677 90678 8687 8699 6 6 50 Snappy Based on LZ77 Dictionary coders Sliding window Very fast and stable but not high compression ratio 0~00% lower compression ratio than gzip 5 BigTable and data compressions Large window data compression BMDiff (~ 00MB/s for write, ~000MB/sec for read) Identify large amounts of shared boilerplate in pages from same host Small window data compression Looks for repetitions in 6KB window Snappy e.g. 5.TB of crawled dataset (.B pages). TB compressed size 5 5 Caching for read performance Column Family Stores: Big Table 5. Caching and Prefetching Tablet servers use two levels of caching Scan cache Higher-level cache Caches the key-value pairs returned by the SSTable interface in the table server Block cache Lower-level cache Caches SSTables blocks that were read from GFS 9

Spring 07 5 55 Bloom filters Read operation has to read from all SSTables that make up the state of a tablet SSTables in disk results many disk accesses Bloom filter Detects if an SSTable might contain any data for a specified row/column pair Value Stores: Dynamo Probabilistic data structure Tests whether the element is a member of a set The element either definitely is not in the set or may be in the set 56 This material is built based on, Giuseppe DeCandia, et al. Dynamo: Amazon s Highly Available -Value Store Proceedings of SOSP, 007 Ion Stoica, Robert Morris, David Karger, M. Frans Kaashoek, and Hari Balakrishnan,"Chord: A Scalable Peer-to-peer Lookup Service for Internet Applications" Proc. 00 SIGCOMM, Mar. 00, pp.9-60 57 What Amazon needs (/) Amazon s architecture A highly decentralized, loosely coupled, service oriented architecture consisting of hundreds of services Storage technologies that are always available Customer should be able to view and add items to the shopping cart even if: The disks are failing Network routes are flapping or, Data centers are being destroyed by tornados 58 If you design a data storage system for, Amazon.com to store transaction data for the shopping cart management, how would you prioritize properties: Consistency, Availability, or Partition tolerance? And Why? 59 What Amazon needs Highly available system with failure resilience Small but significant number of servers Network components Failure handling should not impact availability or performance 0

Spring 07 60 Overview of Dynamo (/) Partitions and replicates data using consistent hashing Tracks object version to provide consistency Uses quorum-like technique to ensure consistency among replicas Uses a decentralized synchronization protocol 6 Overview of Dynamo (/) Underlying storage technology Amazon s e-commerce platform Handles peak loads, Over million checkouts in a single day Hundreds of thousands of concurrently active sessions Storage nodes can be added and removed from Dynamo without any manual partitioning or redistribution Gossip based distributed failure detection and membership protocol 6 Why Amazon does not store their state in relational database? Functionality of RDBMS is not required for Amazon s tasks Store and retrieve data by primary key Does not require complex querying and management Excess functionality requires Expensive hardware Highly skilled personnel Hard to achieve scale-out databases 6 System Assumptions (/) Query model Simple read and write operations to a data item Uniquely identified by a key State is stored as binary objects (i.e. blobs) identified by unique keys Usually less than MB No operations span multiple data items No need for relational schema ACID Properties Dynamo targets applications that operate with weaker consistency if this results in high availability Dynamo does not provide any isolation guarantees 6 System Assumptions (/) Efficiency The system needs to function on a commodity hardware infrastructure Stringent latency requirements 65 Summary of techniques Problem Technique () Partitioning Consistent Hashing () High Availability for writes Vector clocks with reconciliation during reads () Handling temporary failures Sloppy Quorum and hinted handoff () Recovering from permanent Anti-entropy using Merkle tree failures (5) Membership and failure detection Gossip-based membership protocol and failure detection

Spring 07 66 67 Partitioning algorithm Value Stores: Dynamo () Partitioning () High Availability for writes () Handling temporary failures () Recovering from permanent failures (5) Membership and failure detection Dynamically partitions the data over the set of nodes Distributes the load across multiple storage hosts Dynamo uses consistent hashing Relies on the Chord Distributed Hash Table 68 69 Hash function What is a hashtable? Hash Functions and Their Uses Hash function Takes a hash-key value as an argument Produces a bucket number as a result Bucket number 0 ~ (B-), where B is the number of buckets Selecting prime number as the bucket number will reduce the probability of collisions 70 Hash function and indexing (/) Index Data structure that makes it efficient to retrieve objects given the value of one or more elements of those objects Index can be one of the fields (name, address, phone) triples and index on the phone field Given phone number, the index allows you to find the record quickly 7 Hash function and indexing (/) Hash function is useful to implement indexing A hash function is applied to the value of the hash-key One of the fields Record is placed in the bucket whose number is determined by the hash function The bucket could be a list of records in main-memory, or a disk block

Spring 07 7 What if hash-keys are not integers? String Convert common types of integers using ASCII or Unicode equivalent Multi-dimension? e.g. a geospatial coordinate? 7 Case study: Geohash Latitude/longitude geocode system Provides arbitrary precision By selecting the length of the code gradually 0.578 N, 05.080 W Geohash: 9xjqbdqm5hy 7 Resolutions with length of geohash string 0 75 Resolutions with length of geohash string 0 0 00 76 Resolutions with length of geohash string 77 Encoding (/) 0000 00 LAT: 0.57765 LON:-05.0865006 (CSU) Phase. Create interleaved bit string geobits[] Even bits are from longitude code, LON Odd bits are from latitude code: LAT Step. If -80<=LON<=0 set geobits[0] as 0 If 0<LON<=80 set geobits[0] as Step. If -90<=LAT<=0 set geobits[] as 0 If 0< LAT<90 set geobits[] as geobits[] = geobits[0] = 0

Spring 07 78 Encoding (/) LAT: 0.57765 LON:-05.0865006 (CSU) 79 Encoding (/) LAT: 0.57765 LON:-05.0865006 (CSU) Step. Since geobits[0] =0, If -80<=LON<=-90 set geobits[] as 0 If -90<LON<=0 set geobits[] as geobits[] = 0 Step. Since geobits[] =0, If -80<=LON<=-5 set geobits[] as 0 If -5<LON<=-90 set geobits[] as geobits[] = Step. Since geobits[] = If 0<=LAT<=5 set geobits[] as 0 If 5< LAT<90 set geobits[] as geobits[] = 0 Step. Since geobits[] = 0 If 0<=LAT<=.5 set geobits[5] as 0 If.5< LAT<5 set geobits[5] as geobits[5] = 80 8 Encoding (/) LAT: 0.57765 LON:-05.0865006 (CSU) Repeat this process until your precision requirements are met Currently geohash bit string is 000 Phase. First five bits 000 are mapped to 9 Encode every five bits from the left side, by mapping to the table, 9xjqbdqm5hy Consistent Hashing Decimal 0-9 0 5 6 7 Base 0-9 b c d e f g g j Decimal 8 9 0 5 6 Base k m n p q r s t u Decimal 7 8 9 0 Base v w x y z 8 Non-consistent hashing vs. consistent hashing When a hash table is resized Non-consistent hashing algorithm requires to re-hash complete table Consistent hashing algorithm requires only partial records of the table 8 Consistent hashing (/) Identifier circle with m = 7 0 A Consistent hash function assigns each node and key an m-bit identifier using a hashing function B 6 m-bit Identifier: m identifiers m has to be big enough to make the probability of two nodes or keys hashing to the same identifier negligible C Hashing value of IP address 5

Spring 07 8 Consistent hashing (/) Identifier: m identifiers 7 0 A Consistent hashing assigns keys to nodes: k will be assigned to the first node whose identifier is equal to or follows k in the identifier space B Machine B is the successor node of key. successor () = 85 Consistent hashing (/) A 0 7 B C 6 5 will be stored in machine C successor() = 5 will be stored in machine successor() = 5 6 If machine C leaves circle, Successor(5) will points to A 5 C If machine N joins circle, successor() will points to N New node N 86 Scalable location In consistent hashing: Each node need only be aware of its successor node on the circle Queries can be passed around the circle via these successor pointers until it finds resource What is the disadvantage of this scheme? 87 Scalable location In consistent hashing: Each node need only be aware of its successor node on the circle Queries can be passed around the circle via these successor pointers until it finds resource What is the disadvantage of this scheme? It may require traversing all N nodes to find the appropriate mapping 88 89 Scalable location in Chord Chord Let m be the number of bits in the key/node identifiers Each node n, maintains, A routing table with (at most ) m entries Called the finger table The i th entry in the table at node n, contains the identity of the first node, s. Succeeds n by at least i- on the identifier circle i.e. s = successor (n+ i- ), where i m (and all arithmetic is modulo m ) The i th entry finger of node n 5

Spring 07 90 Definition of variables for node n, using m-bit identifiers Finger[i]. start = (n+ i- ) mod m, i m Finger[i]. interval = [finger[i].start, finger[i+].start) Finger[i]. node = first node n.finger[i].start 9 The Chord identifier The IP address of the relevant node First finger of n is its immediate successor on the circle 9 9 s [,) [,) [,0) 0 7 0 [,) [,5) 5 [5,) 0 Lookup process(/) Each node stores information about only a small number of other nodes A node s finger table generally does not contain enough information to determine the successor of an arbitrary key k 6 What happens when a node n does not know the successor of a key k? 5 [,5) 0 5 [5,7) 0 7 [7,) 0 If n finds a node whose ID is close than its own to k, that node will know more about the identifier circle in the region of k than n does 9 Lookup process(/) n searches its finger table for the node j Whose ID most immediately precedes k Ask j for the node it knows whose ID is closest to k. Go clockwise. Never overshoot 95 Lookup process(/) [,) [,) [,0) 0. Node asks node 0 to find successor of 5. Successor of 6 is 7 0 0. Request comes into node to find the successor of identifier.. Node wants to find the successor of identifier. Identifier belongs to [7,). 5 Check succ: 0 [,) [,5) 5 [5,) 0 [,5) 0 5 [5,7) 0 7 [7,) 0 6

Spring 07 96 Lookup process: example [,) [,) [,0) 0 6. Node asks node to find successor of 5. Successor 5 of is 0. Identifier 0 belongs 7 to [,5). Check succ: [,) [,5) 5 [5,) 0 0. Request comes into node(machine) to find the successor of id.. Node wants to find the successor of identifier [,5) 0 5 [5,7) 0 7 [7,) 0 97 Lookup process: example [,) [,) [,0) 0. Node asks node 0 to find successor of 5. Machine is using identifier 0 as 6 well.à succ is 0. 7 0 0. Request comes into node.. Node wants to find the successor of identifier 0. Identifier 0 belongs to [7,). 5 Check succ: 0 [,) [,5) 5 [5,) 0 [,5) 0 5 [5,7) 0 7 [7,) 0 98 99 Lookup process(/) [,) [,) [,0) 0 7 0 [,) [,5) 5 [5,) 0 Dynamo s partitioning Inspired by Consistent Hashing and Chord When a node starts for the first time Chooses its set of tokens (virtual nodes in the consistent hash space) Maps nodes to their respective token sets Stores both tokens and nodes onto disk 6 Repeated reconciliation of the membership change 5 [,5) 0 5 [5,7) 0 7 [7,) 0 Partitioning and placement information are propagated via the gossip-based protocol Token ranges handled by its peers Direct forwarding of read/write operations are possible 00 0 Replication (/) () High Availability for writes Problem Technique () Partitioning Consistent Hashing () High Availability for writes Vector clocks with reconciliation during reads () Handling temporary failures Sloppy Quorum and hinted handoff () Recovering from permanent failures Anti-entropy using Merkle tree Dynamo replicates its data on multiple hosts Each data item is replicated at R hosts, where R is a parameter configured per-instance Each key k is assigned to a coordinator node The coordinator is managing the replication of the data items that fall within its range Stores at the R- clockwise successor nodes in the ring Each node is responsible for the region of the ring between it and its R th predecessor (5) Membership and failure detection Gossip-based membership protocol and failure detection 7

Spring 07 0 0 Replication (/) Replication (/) 7 0 A B Preference list The list of nodes that is responsible for storing a particular key Node failures Preference list contains more than R nodes D 6 Machine D will store the keys, [A,B),[B,C), and [C,D) 5 C Virtual nodes can reduce actual number of machines in R nodes The preference list for a key is constructed only by distinct physical nodes 0 05 Data Versioning Dynamo provides eventual consistency Allows for updates to be propagated to all replicas asynchronously A put call may return to its caller before the update has been applied to all the replicas Add to Cart example The shopping cart application requires that an Add to Cart operation can never be forgotten or rejected If the most recent cart is not available and user makes changes to an old version of the cart Still the change should be meaningful and preserved add to cart and delete item from cart should be translated into put operation to Dynamo The divergent versions are reconciled later 06 07 Maintaining vector clock Dynamo treats the result of each modification as a new and immutable version of the data Multiple version of data can be in the system Version branching Due to the failure(s) in node(s), there are conflicting versions of an object Merging Collapses multiple branches of data evolution back into one Semantic reconciliation e.g. merging different versions of shopping cart and preserving all of the items those client put into the cart Vector clocks Used to capture causality between different versions of same object Two versions of object are on parallel branches or have a causal ordering Vector clock A list of (node, counter) pairs One vector clock is associated with every version of every object 8

Spring 07 08 09 Definition of the vector clocks VC(x) denotes the vector clock of event x VC(x) z denotes the component of that clock for process z VC(x) < VC(y) z[vc(x) z VC(y) z ] z'[vc(x) z' < VC(y) z' ] x à y denotes that event x happens before event y If x à y, then VC(x) < VC(y) Examples VC(D)=([Sx, ], [Sy, ], [Sz, ], [Sq, ]) VC(D)=([Sx, ], [Sy, ], [Sz, ], [Sq, ]) VC(D)=([Sx, ], [Sy, ], [Sq, ]) VC(D)=([Sx, ], [Sy, ], [Sz, ], [Sq, ]) Is VC(D) > VC(D)? Is VC(D) > VC(D)? Is VC(D) > VC(D)? VC(x) < VC(y) z[vc(x) z VC(y) z ] z'[vc(x) z' < VC(y) z' ] 0 Properties of the vector clocks Object D Write handled by Sx If VC(a) < VC(b), then a à b Antisymmetry: If VC(a)<VC(b) then NOT VC(b) < VC(a) Transitivity If VC(a)<VC(b) and VC(b)<VC(c), then VC(a)<VC(c) Node performed update Write handled by Sy D([Sx,],[Sy,]) D([Sx,]) D([Sx,]) Write handled by Sx D([Sx,],[Sz,]) counter Write handled by Sz Could not get the time Vector of ([Sx,],[Sy,]) Some of the replications Reconciled and written by Sx might still have (Sx,) D5([Sx,],[Sy,],[Sz,]) Execution of get and put operations Users can send the operations to any storage node in Dynamo Coordinator A node handling a read or write operation The top N nodes in the preference list Client can select a coordinator Route its request through a generic load balancer Use a partition-aware client library Directly access the coordinators Using quorum-like system R Minimum number of nodes that must participate in a successful read operation W Minimum number of nodes that must participate in a successful write operation Setting R and W R + W > N W > N/ The latency of a get (or put) operation is dictated by the slowest of the R (or W) replicas R and W are configured to be less than N 9

Spring 07 put request Coordinator node. Generates the vector clock --For the new version. Writes the new version locally. Sends the new version to the N highest-ranked reachable nodes --Along with the new vector clock 5 get request The coordinator requests all existing versions of data for that key from the N highest-ranked reachable nodes In the preference list Waits for R responses If multiple versions of the data are collected Returns all the versions it deems to be causally unrelated The reconciled version superseding the current versions is written back 6 7 Sloppy quorum All read and write operations are performed on the first N healthy nodes from the preference list May not always be the first N nodes on the hashing ring () Handling temporary failures Problem Technique () Partitioning Consistent Hashing () High Availability for writes Vector clocks with reconciliation during reads () Handling temporary failures Sloppy Quorum and hinted handoff () Recovering from permanent failures Anti-entropy using Merkle tree (5) Membership and failure detection Gossip-based membership protocol and failure detection Hinted handoff If a node is temporarily unavailable, data is propagated to the next node in the ring Metadata contains information about the originally intended node Stored in a separate local database and scanned periodically Upon detecting that the original node is recovered, A data delivery attempt will be made Once the transfer succeeds, the data at the temporary node will be removed 8 9 Example What if W is? 7 0 A If it is temporarily down B Applications that need the highest level of availability can set W as Under Amazon s model A write is accepted as long as a single node in the system has durably written the key to its local store 5 A write request is rejected, Only if all nodes in the system are unavailable The data will be sent to the node D 5 D C This data contains a hint in its metadata After the recovery, D will send data to A -- node where it was supposed to be stored Then, it will remove the data. 0

Spring 07 0 FAQs Programming Assignment has been posted. Due on Oct. Midterm Oct. ~ Dynamo Start with slides Try examples Read papers 6 problem sets Each of them will contain several sub-problems 50 points (5% of cumulative course grade) Term project: Phase II () Recovering from permanent failures Problem Technique () Partitioning Consistent Hashing () High Availability for writes Vector clocks with reconciliation during reads () Handling temporary failures Sloppy Quorum and hinted handoff () Recovering from permanent failures Anti-entropy using Merkle tree (5) Membership and failure detection Gossip-based membership protocol and failure detection Anti-entropy protocol Replica synchronization protocol Hinted replica can be lost before they can be returned to the original replica node Detect inconsistencies between the replicas faster Minimize the amount of transferred data Dynamo uses Merkle tree Merkle tree Hash tree where leaves are hashes of the values of individual keys Parent nodes are hashes of their respective children Each branch of the tree can be checked independently Without requiring nodes to download the entire tree or dataset If the hash values of the root of two trees are equal The values of the leaf nodes in the tree are equal No synchronization needed 5 Uses of Merkle tree Merkle trees can be used to verify any kind of data stored, handled and transferred. Used in a peer-to-peer network Trusted computing systems Sun s ZFS (Zeta File System) Google s Wave protocol Git Cassandra and Dynamo Bittorrent protocol How Merkle tree works H+H means concatenating two values H Hash value of Data H5 Hash value of (H+H) H Hash value of Data Top Hash Hash value of (H5+H6) H Hash value of Data H6 Hash value of (H+H) H Hash value of Data Data Data Data Data

Spring 07 6 7 How Dynamo uses Merkle tree Each node maintains a separate Merkle tree for each key range Two nodes exchange the root of the Merkle tree Corresponding to the key ranges that they host in common Node performs tree traversal and determines if there is any difference Perform the appropriate synchronization action How Merkle tree works for Dynamo H Node A Top Hash A H5 H6. If top hash did not match Compare H5 vs. H and H6 vs. H H H. Compare Top hashes H Top Hash B. If H6 H and H did not match H Compare H vs. H and H vs. H H0 Node B H H H Disadvantage When a new node joins or leaves Tree needs to be recalculated 8 9 Ring Membership (5) Membership and failure detection A node outage should not result in re-balancing of the partition assignment or repair of the unreachable replicas A node outage is mostly temporary Gossip-based protocol Propagates membership changes Maintains an eventually consistent view of membership Problem Technique () Partitioning Consistent Hashing () High Availability for writes Vector clocks with reconciliation during reads () Handling temporary failures Sloppy Quorum and hinted handoff () Recovering from permanent failures Anti-entropy using Merkle tree Each node contacts a peer every second Random selection Two nodes reconcile their persisted membership change history (5) Membership and failure detection Gossip-based membership protocol and failure detection 0 Logical partitioning Almost concurrent addition of two new nodes Node A joins the ring Node B joins the ring A and B consider themselves members of the ring Yet neither would be immediately aware of each other Logical partitioning External Discovery Seeds Discovered via an external mechanism Known to all nodes Statically configured (or from a configuration service) Seed nodes will eventually reconcile their membership with all of the nodes

Spring 07 Communication failure Attempts to Communicate with unreachable peers during a get or put operation Transfer partitions and hinted replicas Detecting communication failures When there is no response to an initiated communication Responding to communication failures Sender will try alternate nodes that map to failed node s partitions Periodically retry failed node for recovery