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

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

Bigtable. Presenter: Yijun Hou, Yixiao Peng

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

Distributed Systems [Fall 2012]

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

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

CS November 2017

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

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

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

BigTable: A Distributed Storage System for Structured Data

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

CSE-E5430 Scalable Cloud Computing Lecture 9

Distributed File Systems II

CS November 2018

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

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

BigTable A System for Distributed Structured Storage

BigTable. CSE-291 (Cloud Computing) Fall 2016

BigTable: A System for Distributed Structured Storage

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

Extreme Computing. NoSQL.

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

Bigtable: A Distributed Storage System for Structured Data

Bigtable: A Distributed Storage System for Structured Data

Bigtable: A Distributed Storage System for Structured Data

CA485 Ray Walshe NoSQL

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

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

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

7680: Distributed Systems

CS5412: OTHER DATA CENTER SERVICES

Design & Implementation of Cloud Big table

MapReduce & BigTable

DIVING IN: INSIDE THE DATA CENTER

Distributed Database Case Study on Google s Big Tables

Outline. Spanner Mo/va/on. Tom Anderson

Data Storage in the Cloud

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

CS5412: DIVING IN: INSIDE THE DATA CENTER

CS5412: DIVING IN: INSIDE THE DATA CENTER

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

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

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

Lessons Learned While Building Infrastructure Software at Google

4/9/2018 Week 13-A Sangmi Lee Pallickara. CS435 Introduction to Big Data Spring 2018 Colorado State University. FAQs. Architecture of GFS

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

Distributed Systems 16. Distributed File Systems II

CISC 7610 Lecture 2b The beginnings of NoSQL

Google big data techniques (2)

Distributed computing: index building and use

Integrity in Distributed Databases

Data Informatics. Seon Ho Kim, Ph.D.

The Google File System

Lecture: The Google Bigtable

NPTEL Course Jan K. Gopinath Indian Institute of Science

Programming model and implementation for processing and. Programs can be automatically parallelized and executed on a large cluster of machines

FAQs Snapshots and locks Vector Clock

Google Data Management

Map-Reduce. Marco Mura 2010 March, 31th

The Google File System

CS 655 Advanced Topics in Distributed Systems

Scaling Up HBase. Duen Horng (Polo) Chau Assistant Professor Associate Director, MS Analytics Georgia Tech. CSE6242 / CX4242: Data & Visual Analytics

The Google File System

CLOUD-SCALE FILE SYSTEMS

NoSQL Databases. Amir H. Payberah. Swedish Institute of Computer Science. April 10, 2014

SCALABLE CONSISTENCY AND TRANSACTION MODELS

The Google File System. Alexandru Costan

Cassandra- A Distributed Database

CISC 7610 Lecture 5 Distributed multimedia databases. Topics: Scaling up vs out Replication Partitioning CAP Theorem NoSQL NewSQL

CA485 Ray Walshe Google File System

CSE 124: Networked Services Lecture-16

Distributed Filesystem

Cassandra, MongoDB, and HBase. Cassandra, MongoDB, and HBase. I have chosen these three due to their recent

The Google File System (GFS)

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

YCSB++ benchmarking tool Performance debugging advanced features of scalable table stores

Distributed Computation Models

Ghislain Fourny. Big Data 5. Wide column stores

CSE 124: Networked Services Fall 2009 Lecture-19

The Google File System

Big Data Analytics. Rasoul Karimi

MapReduce. U of Toronto, 2014

Distributed Data Management. Christoph Lofi Institut für Informationssysteme Technische Universität Braunschweig

Big Table. Dennis Kafura CS5204 Operating Systems

Typical size of data you deal with on a daily basis

GFS Overview. Design goals/priorities Design for big-data workloads Huge files, mostly appends, concurrency, huge bandwidth Design for failures

Comparing SQL and NOSQL databases

11 Storage at Google Google Google Google Google 7/2/2010. Distributed Data Management

Google File System (GFS) and Hadoop Distributed File System (HDFS)

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

Webinar Series TMIP VISION

BigData and Map Reduce VITMAC03

The Google File System

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

CS435 Introduction to Big Data FALL 2018 Colorado State University. 11/7/2018 Week 12-B Sangmi Lee Pallickara. FAQs

Distributed Systems. Lec 10: Distributed File Systems GFS. Slide acks: Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung

CPSC 426/526. Cloud Computing. Ennan Zhai. Computer Science Department Yale University

10 Million Smart Meter Data with Apache HBase

PLATFORM AND SOFTWARE AS A SERVICE THE MAPREDUCE PROGRAMMING MODEL AND IMPLEMENTATIONS

Transcription:

Structured Big Data 1: Google Bigtable & HBase Shiow-yang Wu ( 吳秀陽 ) CSIE, NDHU, Taiwan, ROC Lecture material is mostly home-grown, partly taken with permission and courtesy from Professor Shih-Wei Liao of NTU. Outline Problems of big data processing with Hadoop MapReduce Structured big data processing Traditional RDBMS ACID vs BASE Distributed DB Bigtable o Hbase Motivations, data model, system architecture, API, implementation, refinement CAP theorem Structured Big Data 1 Bigtable & HBase 2 Note 1

Problems of BD Processing Hadoop MapReduce is simple and powerful but: The one-input data format (key-value pairs) and twostage dataflow computing are extremely rigid. Custom code has to be written for even the most common operations (e.g., projection and filtering) Programmers could be unfamiliar with the MapReduce and would prefer to use SQL-like lang Performing tasks with a different dataflow (e.g., joins or n stages) would require implementing inelegant workarounds Hadoop MR is not good for interactive queries Structured Big Data 1 Bigtable & HBase 3 Structured Big Data Processing This lecture discuss various solutions on adding SQL flavor on top of the Big Data platforms for processing large-scale structured data. Starting with the structured data store Google Bigtable. Then discuss the open source counterpart Apache Hbase. Move toward NoSQL. Structured Big Data 1 Bigtable & HBase 4 Note 2

Traditional DBMS Mostly based on relational model (tables, tuples, attributes) Well-defined schema Support relational operators (SELECT, PROJECT, JOIN, ) SQL language Transaction management ACID properties Structured Big Data 1 Bigtable & HBase 5 ACID Properties Atomicity either all the operations of a transaction are executed or none of them are (all-or-nothing) Consistency the database is in a legal state before and after a transaction Isolation Durability Structured Big Data 1 Bigtable & HBase 6 Note 3

ACID Properties Atomicity Consistency Isolation the effects of one transaction on the database are isolated from other transactions even under concurrent execution Durability the effects of successfully completed (i.e., committed) transactions endure subsequent failures Structured Big Data 1 Bigtable & HBase 7 Benefits of RDBMS High level semantics o Easy to program o Programmers are more familiar with o (Multi-row) transactions Lots of mature commercial implementations o MySQL, PostgreSQL, MSSQL.. Optimizations makes them really fast o But only under small scale of data Structured Big Data 1 Bigtable & HBase 8 Note 4

Problems of RDBMS on Large Scale Data Most important of all, current implementations lack, or only come with limited support of distributed deployment Not very feasible when it comes to BIG data. o Especially when it come to scalability ACID properties are too strong (next slide) Structured Big Data 1 Bigtable & HBase 9 ACID vs BASE ACID properties seem indispensable They are incompatible with availability, scalability and performance requirements in very large systems. An alternative to ACID is BASE: Basic Availability Soft-state Eventual consistency Structured Big Data 1 Bigtable & HBase 10 Note 5

CAP Theorem Eric Brewer (Brewer s Theorem): It is impossible for a distributed system to simultaneously provide all three of the following guarantees: Consistency Availability Partition tolerance (more on this later) Structured Big Data 1 Bigtable & HBase 11 Distributed Database Remind:Transaction o A unit of consistent and atomic execution against the database. Termination protocol o A protocol by which individual sites can decide how to terminate a particular transaction when they cannot communicate with other sites where the transaction executes. Distributed DBMS, Concurrency control algorithm, Distributed Locking, Logging protocol, One-copy equivalence, Query processing, Query optimization, Quorum-based voting algorithm, Read-once, writeall protocol, Serializability, Transparency, Twophase commit, Two-phase locking Structured Big Data 1 Bigtable & HBase 12 Note 6

BigTable: Motivations Consider Google Lots of (semi-)structured data Copies of the web, satellite data, user data, geographic data, email and USENET, Subversion backing store Millions of machines Different projects/applications Hundreds of millions of users Many incoming requests (thousands of q/sec) 100TB+ of satellite image data Need both offline data processing and online serving Structured Big Data 1 Bigtable & HBase 13 Why not a DBMS? Few DBMS s support the requisite scale Required DB with wide scalability, wide applicability, high performance and high availability Couldn t afford it if there was one Most DBMSs require very expensive infrastructure DBMSs provide more than Google needs E.g., full transactions, SQL Google has highly optimized lower-level systems that could be exploited GFS, Chubby(distributed lock service), MapReduce, Job scheduling Structured Big Data 1 Bigtable & HBase 14 Note 7

BigTable: Goals Wide applicability o Can be used by many Google products and projects o Often want to examine data changes over time, e.g., Contents of a web page over multiple crawls o Both throughput-oriented batch-processing jobs and latency-sensitive serving of data to end users Scalability o Handful to thousands of servers, hundreds of TB to PB High performance o Millions of ops per second High availability o Want access to most current data at any time Structured Big Data 1 Bigtable & HBase 15 What is a BigTable? A BigTable is a sparse, distributed, persistent multidimensional sorted map. The map is indexed by a row key, a column key, and a timestamp; each value in the map is an uninterpreted array of bytes. Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C. Hsieh, Deborah A. Wallach, Mike Burrows, Tushar Chandra, Andrew Fikes, and Robert E. Gruber. Bigtable: A Distributed Storage System for Structured Data. In 7th OSDI 2006. Structured Big Data 1 Bigtable & HBase 16 Note 8

BigTable: Introduction A sparse, distributed, persistent multidimensional sorted map o With an interesting data model Fault-tolerant, persistent Scalable o Thousands of servers o Terabytes of in-memory data o Millions of reads/writes per second, efficient scans Self-managing o Servers can be added/removed dynamically o Servers adjust to load imbalance Structured Big Data 1 Bigtable & HBase 17 Relative to DBMS, BigTable provides Simplified data retrieval mechanism A map <Row, Column, Timestamp> -> string No relational operators Atomic updates only possible at row level Arbitrary number of columns per row Arbitrary data type for each column Designed for Google s application set Provides extremely large scale (data, throughput) at extremely small cost Structured Big Data 1 Bigtable & HBase 18 Note 9

Rows HBase An open source implementation of Bigtable A part of Hadoop Structured Big Data 1 Bigtable & HBase 19 Data Model Row-based, key-value pairs Semi Three Dimensional datacube Input(row, column, timestamp) Output(cell contents) Columns contents:. com.cnn.www... Time Structured Big Data 1 Bigtable & HBase 20 Note 10

Data Model: Rows Row keys are arbitrary strings up to 64KB Row is the unit of transactional consistency Every read or write of data under a single row is atomic Multi-row atomicity not guaranteed Identified and sorted in lexicographic order by row keys Rows with consecutive keys (Row Range) are grouped together as tablets. Unit of distribution and load-balancing reads of short row ranges are efficient and typically require communication with only a small number of machines Structured Big Data 1 Bigtable & HBase 21 Data Model: Columns Provide schema-like semantic Column keys are grouped into sets called column families, which form the unit of access control. Data stored under a column family is usually of the same type (easier to be compressed together) A column family must be created before data can be stored in a column key After a family has been created, any column key within the family can be used for queries Column key is named using: family:qualifier Access control and disk/memory accounting are performed at column family level Managed by the Chubby lock service Structured Big Data 1 Bigtable & HBase 22 Note 11

Data Model: Timestamps Each cell can contain multiple versions of data, each indexed by timestamp (called version in Hbase) Timestamps are 64-bit integers Assigned by: Bigtable: real-time in microseconds Client application: when unique timestamps are a necessity Data is stored in decreasing timestamp order, so that most recent data is easily accessed Application specifies how many versions (n) or how new enough (last 7 days) items to be maintained in a cell Bigtable garbage collects obsolete versions Structured Big Data 1 Bigtable & HBase 23 Data Model Example Example: Zoo Structured Big Data 1 Bigtable & HBase 24 Note 12

Data Model Example Example: Zoo row key col. key timestamp Structured Big Data 1 Bigtable & HBase 25 Data Model Example: Zoo row key col. key timestamp - (zebras, length, 2006) --> 7 ft - (zebras, weight, 2007) --> 600 lbs - (zebras, weight, 2006) --> 620 lbs Structured Big Data 1 Bigtable & HBase 26 Note 13

Data Model Example: Zoo row key col. key timestamp - (zebras, length, 2006) --> 7 ft - (zebras, weight, 2007) --> 600 lbs - (zebras, weight, 2006) --> 620 lbs Each key is sorted in Lexicographic order Structured Big Data 1 Bigtable & HBase 27 Data Model Example: Zoo row key col. key timestamp - (zebras, length, 2006) --> 7 ft - (zebras, weight, 2007) --> 600 lbs - (zebras, weight, 2006) --> 620 lbs Timestamp ordering is defined as most recent appears first Structured Big Data 1 Bigtable & HBase 28 Note 14

Data Model Example: Webtable for storing crawled Web pages Structured Big Data 1 Bigtable & HBase 29 Data Model Row Structured Big Data 1 Bigtable & HBase 30 Note 15

Data Model Columns Structured Big Data 1 Bigtable & HBase 31 Data Model Cells Structured Big Data 1 Bigtable & HBase 32 Note 16

Data Model timestamps Structured Big Data 1 Bigtable & HBase 33 Data Model Column family Structured Big Data 1 Bigtable & HBase 34 Note 17

Data Model Column family family:qualifier Structured Big Data 1 Bigtable & HBase 35 Data Model Column family family: qualifier Structured Big Data 1 Bigtable & HBase 36 Note 18

Bigtable API Bigtable APIs provide functions for: Creating/deleting tables, column families Changing cluster, table and column family metadata such as access control rights Support of single row transactions Allowing cells to be used as integer counters Executing client supplied scripts in the address space of servers Structured Big Data 1 Bigtable & HBase 37 Bigtable API Write API o Write or delete different granularities up to row o Applied atomicity within a row Structured Big Data 1 Bigtable & HBase 38 Note 19

Bigtable API Read API o selection by a combination of row, column or timestamp ranges Structured Big Data 1 Bigtable & HBase 39 Google Applications using BigTable Structured Big Data 1 Bigtable & HBase 40 Note 20

Building Blocks On top of Google File System (vs HDFS) o stores persistent data Scheduler (in-house): o Schedule Bigtable jobs Chubby (vs ZooKeeper) o As synchronization service MapReduce: not a building block, but uses Bigtable / HBase heavily Structured Big Data 1 Bigtable & HBase 41 Building Blocks: GFS Bigtable uses the distributed Google File System (GFS) to store log and data files The Google SSTable file format is used internally to store Bigtable data An SSTable provides a persistent, ordered immutable map from keys to values Operations are provided to look up the value associated with a specified key, and to iterate over all key/value pairs in a specified key range Structured Big Data 1 Bigtable & HBase 42 Note 21

Building Blocks: Chubby Bigtable relies on a highly-available and persistent distributed lock service called Chubby Chubby provides a namespace that consists of directories and small files. Each directory or file can be used as a lock Consists of 5 active replicas, one replica is the master and serves requests Service is functional when majority of the replicas are running and in communication with one another when there is a quorum Structured Big Data 1 Bigtable & HBase 43 BigTable and Chubby Bigtable uses Chubby to: Ensure there is at most one active master at a time, Store the bootstrap location of Bigtable data (Root tablet), Discover tablet servers and finalize tablet server deaths, Store Bigtable schema information (column family information), Store access control list. If Chubby becomes unavailable for an extended period of time, Bigtable becomes unavailable. Structured Big Data 1 Bigtable & HBase 44 Note 22

Building Blocks Shared pool of machines that also run other distributed applications Structured Big Data 1 Bigtable & HBase 45 Organization A Bigtable cluster stores tables Each table consists of tablets Initially each table consists of one tablet As a table grows it is automatically split into multiple tablets Tablets are assigned to tablet servers Multiple tablets per server. Each tablet is 100-200 MB Each tablet lives at only one server Structured Big Data 1 Bigtable & HBase 46 Note 23

System Architecture:Tablet Large tables broken into tablets at row boundaries o Tablet holds contiguous range of rows o Aim for ~100MB to 200MB of data per tablet Serving machine responsible for ~100 tablets o Fast recovery: 100 machines each pick up 1 tablet from failed machine o Fine-grained load balancing: Migrate tablets away from overloaded machine Master makes load-balancing decisions Structured Big Data 1 Bigtable & HBase 47 System Architecture: Tablet Dynamic fragmentation of rows o Unit of load balancing o Distributed over tablet servers o Tablets split and merge automatically based on size and load or manually o Clients can choose row keys to achieve locality Structured Big Data 1 Bigtable & HBase 48 Note 24

Where is my Tablets? Question: given a row, how does a client find the right tablet server? o Tablet server location is ip:port o Need to find tablet whose row range covers the target row o One approach: could use the BigTable master Central server almost certainly would be bottleneck in large system Instead: store tablet location info in special tablets similar to a B+ tree We ll talk about this later Structured Big Data 1 Bigtable & HBase 49 System Architecture Structured Big Data 1 Bigtable & HBase 50 Note 25

System Architecture Structured Big Data 1 Bigtable & HBase 51 System Architecture Structured Big Data 1 Bigtable & HBase 52 Note 26

System Architecture Structured Big Data 1 Bigtable & HBase 53 System Architecture Structured Big Data 1 Bigtable & HBase 54 Note 27

Implementation Tablet Location Tablet Serving Compaction Structured Big Data 1 Bigtable & HBase 55 Tablet Location Remind: Where is my Tablets? Question: given a row, how does a client find the right tablet server? o Tablet server location is ip:port o Need to find tablet whose row range covers the target row o One approach: could use the BigTable master Central server almost certainly would be bottleneck in large system o Instead: store tablet location info in special tablets similar to a B+ tree Structured Big Data 1 Bigtable & HBase 56 Note 28

Finding Tablet Location Client caches tablet locations. In case if it does not know, it has to make three network round-trips in case cache is empty and up to six round trips in case cache is stale Tablet locations are stored in memory, so no GFS accesses are required Structured Big Data 1 Bigtable & HBase 57 Tablet Location A 3-level hierarchy analogous to that of a B+-tree to store tablet location information : A file stored in chubby contains location of the root tablet Root tablet contains location of Metadata tablets The root tablet never splits Each metadata tablet contains the locations of a set of user tablets Client reads the Chubby file that points to the root tablet This starts the location process Client library caches tablet locations Moves up the hierarchy if location N/A Structured Big Data 1 Bigtable & HBase 58 Note 29

Metadata Tablets 3-level B+-tree like scheme for tablets o 1st level: Chubby, points to root tablet o 2nd level: Root tablet data points to appropriate METADATA tablet o 3rd level: METADATA tablets point to data tablets METADATA tablets can be split when necessary Root tablet never splits so number of levels is fixed Structured Big Data 1 Bigtable & HBase 59 Size Analysis Each metadata row stores ~ 1KB of data, With 128 MB tablets, the three level store addresses 2 34 tablets (2 61 bytes in 128 MB tablets). Approaches a Zetabyte (million Petabytes). Structured Big Data 1 Bigtable & HBase 60 Note 30

Tablet Storage Commit log on GFS Redo log o buffered in tablet server's memory A set of locality groups o one locality group = a set of SSTable files on GFS o key = <row, column, timestamp>, value = cell content Structured Big Data 1 Bigtable & HBase 61 SStable(Sorted String Table) SSTable: Sorted String Table o persistent, ordered, immutable map from keys to values. keys and values are arbitrary byte strings. SSTable: Immutable on-disk ordered map from string->string string keys: <row, column, timestamp> triples o contains a sequence of blocks (typical size = 64KB), with a block index at the end of SSTable loaded at open time (next slide). o one disk seek per block read. o operations: lookup(key), iterate(key_range). o an SSTable can be mapped into memory. Structured Big Data 1 Bigtable & HBase 62 Note 31

Tablet Contains some range of rows of the table Built out of multiple SSTables Structured Big Data 1 Bigtable & HBase 63 Table Multiple tablets make up the table SSTables can be shared Tablets do not overlap, SSTables can overlap Tablet aardvark apple Tablet apple boat SSTable SSTable SSTable SSTable Structured Big Data 1 Bigtable & HBase 64 Note 32

System Architecture: Locate Tablet Structured Big Data 1 Bigtable & HBase 65 System Architecture : Serve Tablet Structured Big Data 1 Bigtable & HBase 66 Note 33

Tablet Serving: Write Sorted in-memory buffer for keeping recently committed updates Write Operation: Record the logs in GFS then write data in memtable Structured Big Data 1 Bigtable & HBase 67 Tablet Serving: Read Read Operation: executed on a merged view of data from memtable & SStable Structured Big Data 1 Bigtable & HBase 68 Note 34

Implementation: Three major components A library that is linked into every client One master server Assigning tablets to tablet servers Detecting the addition and deletion of tablet servers Balancing tablet-server load Garbage collection of files in GFS Many tablet servers Tablet servers manage tablets Tablet server splits tablets that get too big Client communicates directly with tablet server for reads/writes. Structured Big Data 1 Bigtable & HBase 69 Architecture BigTable BigTable Client BigTable Master Performs metadata ops and load balancing BigTable Client Library BigTable Tablet Server Serves data BigTable Tablet Server Serves data Cluster scheduling system GFS Chubby Handles failover, monitoring Holds tablet data, logs Holds metadata, handles master election Structured Big Data 1 Bigtable & HBase 70 Note 35

Tablet Server When a tablet server starts, it creates and acquires exclusive lock on a uniquely-named file in a specific Chubby directory Call this servers directory A tablet server stops serving its tablets if it loses its exclusive lock This may happen if there is a network connection failure that causes the tablet server to lose its Chubby session Structured Big Data 1 Bigtable & HBase 71 Tablet Server A tablet server will attempt to reacquire an exclusive lock on its file as long as the file still exists If the file no longer exists then the tablet server will never be able to serve again Kills itself At some point it can restart; it goes to a pool of unassigned tablet servers Structured Big Data 1 Bigtable & HBase 72 Note 36

Master Startup Operation Upon start up the master needs to discover the current tablet assignment. Grabs unique master lock in Chubby Prevents concurrent master instantiations Scans servers directory in Chubby for live servers Communicates with every live tablet server Discover all tablets Scans METADATA table to learn the set of tablets Unassigned tablets are marked for assignment Structured Big Data 1 Bigtable & HBase 73 Master Operation Detect tablet server failures/resumption Master periodically asks each tablet server for the status of its lock Structured Big Data 1 Bigtable & HBase 74 Note 37

Master Operation Tablet server lost its lock or master cannot contact tablet server: Master attempts to acquire exclusive lock on the server s file in the servers directory If master acquires the lock then the tablets assigned to the tablet server are assigned to others Master deletes the server s file in the servers directory Assignment of tablets should be balanced If master loses its Chubby session then it kills itself An election can take place to find a new master Structured Big Data 1 Bigtable & HBase 75 Tablet Server Failure Master Chubby Server Tablet server Tablet server Logical view: Tablet Tablet Tablet Tablet Tablet Tablet GFS Chunkserver GFS Chunkserver Physical layout: SSTable SSTable SSTable SSTable SSTable SSTable (replica) SSTable (replica) SSTable Structured Big Data 1 Bigtable & HBase 76 Note 38

Tablet Server Failure Master Chubby Server X Tablet server X Tablet X server X X Logical view: Tablet Tablet Tablet Tablet Tablet Tablet GFS Chunkserver GFS Chunkserver Physical layout: SSTable SSTable SSTable SSTable SSTable SSTable (replica) SSTable (replica) SSTable Structured Big Data 1 Bigtable & HBase 77 Tablet Server Failure Master Chubby Server Message sent to tablet server by master Tablet server (other tablet servers drafted to serve other abandoned tablets) Logical view: Tablet Tablet Tablet Tablet GFS Chunkserver Backup copy of tablet made primary Physical layout: SSTable SSTable SSTable (replica) SSTable Extra replica of tablet created automatically by GFS Structured Big Data 1 Bigtable & HBase 78 Note 39

Tablet Serving Commit log stores the updates that are made to the data Recent updates are stored in memtable Older updates are stored in SStable files Structured Big Data 1 Bigtable & HBase 79 Tablet Serving Recovery process Reads/Writes that arrive at tablet server o Is the request well-formed? o Authorization: Chubby holds the permission file o If a mutation occurs it is wrote to commit log and finally a group commit is used Structured Big Data 1 Bigtable & HBase 80 Note 40

Tablet Serving Tablet recovery process oread metadata containing SSTables and redo points oredo points are pointers into any commit logs oapply redo points Structured Big Data 1 Bigtable & HBase 81 Compactions As writes execute, size of memtable increases. Once memtable reaches a threshold: Memtable is frozen, A new memtable is created, Frozen metable is converted to an SSTable and written to GFS. This minor compaction convert the memtable into an SSTable Reduce memory usage Reduce log traffic and recovery time on restart Structured Big Data 1 Bigtable & HBase 82 Note 41

Compactions Merging compaction (in the background) Read a few SSTables and memtable to produce one SSTable. (Input SSTables and memtable are discareded.) Reduce number of SSTables Good place to apply policy keep only N versions Major compaction Periodically compact all SSTables for tablet into a new base SSTable on GFS Merging compaction that results in only one SSTable No deletion records, only live data Structured Big Data 1 Bigtable & HBase 83 Minor Compaction When in-memory state fills up, pick tablet with most data and write contents to SSTables stored in GFS Structured Big Data 1 Bigtable & HBase 84 Note 42

Major Compaction Structured Big Data 1 Bigtable & HBase 85 System Performance Not linear, but not bad up to 250 tablet servers Structured Big Data 1 Bigtable & HBase 86 Note 43

Performance Observation Random reads slow because tablet server channel to GFS saturated Random reads (mem) is fast because only memtable involved Random & sequential writes > sequential reads because only log and memtable involved Sequential read > random read because of block caching Scans even faster because tablet server can return more data per RPC Structured Big Data 1 Bigtable & HBase 87 Refinements Locality groups Clients can group multiple column families together into a locality group. Compression Compression applied to each SSTable block separately Uses Bentley and McIlroy's scheme and fast compression algorithm Caching for read performance Uses Scan Cache and Block Cache Bloom filters Reduce the number of disk accesses Structured Big Data 1 Bigtable & HBase 88 Note 44

Refinements Commit-log implementation Suppose one log per tablet rather than one log per tablet server Exploiting SSTable immutability No need to synchronize accesses to file system when reading SSTables Concurrency control over rows efficient Deletes work like garbage collection on removing obsolete SSTables Enables quick tablet split: parent SSTables used by children Structured Big Data 1 Bigtable & HBase 89 CAP Revisit Consistency o Everybody see the same result of an operation Availability o No matter an operation succeeds or fails, a result must be returned -- the system must respond Partition Tolerance o The system must work still despite of message loss or node failure -- communication within cluster Structured Big Data 1 Bigtable & HBase 90 Note 45

CAP Theorem The CAP theorem: in distributed system, consistency, availability & partition tolerance can t be fulfilled together. Proposed by E. Brewer of UCB as a conjecture Proved by Seth Gilbert and Nancy Lynch of MIT Structured Big Data 1 Bigtable & HBase 91 CAP on Bigtable Bigtable is a distributed database Something must be sacrificed o Partition tolerance is required: things will fail o Consistency is fulfilled: row atomicity o Availability not fulfilled: what if Chubby fails? Consistency is more important for their applications than availability Other systems may have different goals Structured Big Data 1 Bigtable & HBase 92 Note 46

NoSQL Databases NoSQL stands for not only SQL The type of systems for structured big data with SQL-like capabilities Arise in the big data era Must trade off between C, A and P. Structured Big Data 1 Bigtable & HBase 93 Structured Big Data 1 Bigtable & HBase 94 Note 47