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

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

CS November 2017

CLOUD-SCALE FILE SYSTEMS

Distributed File Systems II

CS November 2018

The Google File System

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

The Google File System

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

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

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

The Google File System

The Google File System

The Google File System

Google File System. Sanjay Ghemawat, Howard Gobioff, and Shun-Tak Leung Google fall DIP Heerak lim, Donghun Koo

The Google File System

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

BigTable. CSE-291 (Cloud Computing) Fall 2016

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

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

BigTable: A Distributed Storage System for Structured Data

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.

GFS: The Google File System. Dr. Yingwu Zhu

Map-Reduce. Marco Mura 2010 March, 31th

The Google File System (GFS)

! Design constraints. " Component failures are the norm. " Files are huge by traditional standards. ! POSIX-like

Authors : Sanjay Ghemawat, Howard Gobioff, Shun-Tak Leung Presentation by: Vijay Kumar Chalasani

Google File System. By Dinesh Amatya

The Google File System. Alexandru Costan

Distributed Filesystem

Bigtable. Presenter: Yijun Hou, Yixiao Peng

CSE 124: Networked Services Lecture-16

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

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

CA485 Ray Walshe NoSQL

The Google File System

Google File System. Arun Sundaram Operating Systems

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

CSE 124: Networked Services Fall 2009 Lecture-19

Distributed System. Gang Wu. Spring,2018

GFS: The Google File System

Distributed Systems 16. Distributed File Systems II

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective

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

CA485 Ray Walshe Google File System

Georgia Institute of Technology ECE6102 4/20/2009 David Colvin, Jimmy Vuong

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

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

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

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

Staggeringly Large Filesystems

CS5412: OTHER DATA CENTER SERVICES

NPTEL Course Jan K. Gopinath Indian Institute of Science

9/26/2017 Sangmi Lee Pallickara Week 6- A. CS535 Big Data Fall 2017 Colorado State University

CSE-E5430 Scalable Cloud Computing Lecture 9

BigTable A System for Distributed Structured Storage

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

Distributed Systems [Fall 2012]

Outline. Spanner Mo/va/on. Tom Anderson

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

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

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

Lessons Learned While Building Infrastructure Software at Google

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

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

7680: Distributed Systems

CS 138: Google. CS 138 XVI 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

Distributed Database Case Study on Google s Big Tables

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

Google File System 2

Google Disk Farm. Early days

NPTEL Course Jan K. Gopinath Indian Institute of Science

MapReduce & BigTable

Data Storage in the Cloud

BigTable: A System for Distributed Structured Storage

DIVING IN: INSIDE THE DATA CENTER

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

Comparing SQL and NOSQL databases

CS5412: DIVING IN: INSIDE THE DATA CENTER

Distributed Systems. 15. Distributed File Systems. Paul Krzyzanowski. Rutgers University. Fall 2017

CS 138: Google. CS 138 XVII 1 Copyright 2016 Thomas W. Doeppner. All rights reserved.

Google is Really Different.

Hadoop File System S L I D E S M O D I F I E D F R O M P R E S E N T A T I O N B Y B. R A M A M U R T H Y 11/15/2017

CS /30/17. Paul Krzyzanowski 1. Google Chubby ( Apache Zookeeper) Distributed Systems. Chubby. Chubby Deployment.

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

goals monitoring, fault tolerance, auto-recovery (thousands of low-cost machines) handle appends efficiently (no random writes & sequential reads)

Engineering Goals. Scalability Availability. Transactional behavior Security EAI... CS530 S05

NPTEL Course Jan K. Gopinath Indian Institute of Science

CS5412: DIVING IN: INSIDE THE DATA CENTER

Seminar Report On. Google File System. Submitted by SARITHA.S

The Google File System GFS

Staggeringly Large File Systems. Presented by Haoyan Geng

The Google File System

Data Informatics. Seon Ho Kim, Ph.D.

Distributed Systems. 15. Distributed File Systems. Paul Krzyzanowski. Rutgers University. Fall 2016

Cloud Computing and Hadoop Distributed File System. UCSB CS170, Spring 2018

Recap. CSE 486/586 Distributed Systems Google Chubby Lock Service. Recap: First Requirement. Recap: Second Requirement. Recap: Strengthening P2

Distributed Systems. GFS / HDFS / Spanner

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective

Transcription:

Distributed Data Management Christoph Lofi Institut für Informationssysteme Technische Universität Braunschweig http://www.ifis.cs.tu-bs.de

Exams 25 minutes oral examination 20.-24.02.2012 19.-23.03.2012 Make an appointment with Regine Distributed Data Management Christoph Lofi IfIS TU Braunschweig 2

11 Storage at Google 11.1 Google Bigtable 11.2 Google File System 11.3 Bigtable Implementation Distributed Data Management Christoph Lofi IfIS TU Braunschweig 3

11.0 Google Google was founded in 1998 by the Stanford Ph.D. candidates Larry Page and Sergey Brin Headquarter in Mountain View, CA, USA Named after the number Googol More than 20 000 employees Distributed Data Management Christoph Lofi IfIS TU Braunschweig 4

11.0 Google Privately held until 2004 Now NASDAQ: GOOG Market capitalization of over 140 billion USD 2009 revenue of 23.7 billion USD (6.5 billion profit) Distributed Data Management Christoph Lofi IfIS TU Braunschweig 5

11.0 Google Initial mission to organize the world's information and make it universally accessible and useful and Don t be evil Originally, Google became famous for their search engine Initial Idea: Google PageRank Not all web pages are equally important Link structure can be used to determine site s importance Resulting search engine showed much higher result quality than established products (e.g. Yahoo, Altavista, etc.) Rise of Google as one of the big internet pioneers starts Distributed Data Management Christoph Lofi IfIS TU Braunschweig 6

11.0 Google Currently, Google offers a multitude of services Google Search Google+ Google Mail Google Maps Google Earth Google Documents Picasa Web Album etc. Thus, Google hosts and actively uses several Petabytes of data! Distributed Data Management Christoph Lofi IfIS TU Braunschweig 7

11.0 Google Servers (some slides from the start ) or how to build one of the most powerful data centers out of crappy hardware Google has jealously guarded the design of its data centers for a long time In 2007 & 2009 some details have been revealed The Google Servers Google only uses custom build servers Google is the world 4 th largest server producer They don t even sell servers In 2007, it was estimated that Google operates over 1.000.000 servers over 34 major and many more minor data centers Distributed Data Management Christoph Lofi IfIS TU Braunschweig 8

11.0 Google Servers Each server rack holds 40 to 80 commodity-class x86 PC servers with custom Linux Each server runs slightly outdated hardware Each system has its own 12V battery to counter unstable power supplies No cases used, racks are setup in standard shipping containers and are just wired together More info: http://www.youtube.com/watch?v=ho1geyftpmq Distributed Data Management Christoph Lofi IfIS TU Braunschweig 9

11.0 Google Servers Challenges to the data center software Deal with hardware failures while avoiding any data loss and ~100% global uptime Decrease maintenance costs to minimum Allow flexible extension of data centers Solution: Use cloud technologies GFS (Google File System) and Google Bigtable Data System Distributed Data Management Christoph Lofi IfIS TU Braunschweig 10

11.0 Google Challenges Google needs to store and access lots of (semi-)structured data URLs and their contents Content, meta data, links, anchors, pageranks, etc. User data User preferences, query history, search results Geographic information Physical entities (shops, restaurants, etc), roads, annotations, POIs, satellite images, etc. Distributed Data Management Christoph Lofi IfIS TU Braunschweig 11

11.0 Google Challenges Google data is extremely large-scale Billions URLs in multiple versions Stores metadata and cleaned content Also, copies of documents are stored PDF, images, Word, Excel, PowerPoint, etc. Hundreds of millions of users, thousands of queries per second Distributed Data Management Christoph Lofi IfIS TU Braunschweig 12

11.1 Bigtable Bigtable F. Chang et al, Bigtable: A Distributed Storage System for Structured Data, ACM Transactions on Computer Systems (TOCS), Vol 26, Iss 2, June 2008 Bigtable is a high-performance proprietary database system used by multiple Google services e.g. used in Google Search, G+, Google Maps, Google Books, Google Earth, Gmail, Google Code, etc. Uses an abstracted and very flexibly row and column storage model Is based on versioning for updates Distributed Data Management Christoph Lofi IfIS TU Braunschweig 13

11.1 Bigtable Requirements Originally designed for storing Google s Web index Special requirements Continuously and asynchronously update and process different pieces of data i.e. continuous Web crawling Store version, usually access just newest one Multiple version can be used to examine change of data in time Very high read / write rates necessary Millions of requests per seconds Support efficient scanning of interesting data subsets Distributed Data Management Christoph Lofi IfIS TU Braunschweig 14

11.1 Bigtable Requirements Additional requirements as usual for web-scale applications Fault tolerant, persistent Use cheap hardware Scale to huge sized infrastructures Support incremental scaling Thousands of servers Terabytes of in-memory data Petabytes of disk-based data Self-managing Servers auto-load balance Servers can be dynamically added and removed Distributed Data Management Christoph Lofi IfIS TU Braunschweig 15

11.1 Bigtable Cells Each distributed Bigtable cluster is responsible for the data of one or multiple applications Called a cell Several hundred cells are deployed Cell size range from 10-20 up to thousands machines In 2006, the largest cell was 0.5 PB Now it is probably much larger Distributed Data Management Christoph Lofi IfIS TU Braunschweig 16

11.1 Bigtable Environment Bigtable heavily relies on additional systems and concepts Google File System (GFS) A distributed and fail-safe file system Physically stores Bigtable data on disks S. Ghemawat, H. Gobioff, S.T. Leung. The Google File System, ACM Symp. Operating Systems Principles, Lake George, USA, 2003 Google Chubby A distributed lock manager, also responsible for bootstrapping M. Burrows. The Chubby Lock Service for Loosely-Coupled Distributed Systems, Symp. Operating System Design and Implementation, Seattle, USA, 2006 Google MapReduce Programming model for distributing computation jobs on parallel machines J. Dean, S. Ghemawat. MapReduce: Simplified Data Processing on Large Clusters, Symp. Operating System Design and Implementation, San Francisco, USA, 2004 Distributed Data Management Christoph Lofi IfIS TU Braunschweig 17

11.2 Bigtable & the GFS GFS (Google File System) is the distributed file system used by most Google services Applications may use GFS directly Bigtable is an application that was especially designed to run on-top of GFS Thus, GFS handles most of the durability requirements of Bigtable GFS itself runs on-top of standard POSIX-compliant Linux file systems Distributed Data Management Christoph Lofi IfIS TU Braunschweig 18

11.2 GFS Design constraints and considerations Run on potentially unreliable commodity hardware Files are large (usually ranging from 100 MB to multiple GBs of size) e.g. satellite imaginary, or a Bigtable file Billions of files need to be stored Most write operations are appends Random writes or updates are rare Most files are write-once, read-many (WORM) Appends are much more resilient in distributed environments than random updates Most Google applications rely on Map and Reduce which naturally results in file appends Distributed Data Management Christoph Lofi IfIS TU Braunschweig 19

11.2 GFS Two common types of read operations Sequential streams of large data quantities e.g. streaming video, transferring a web index chunk, etc. Frequent streaming renders caching useless Random reads of small data quantities However, random reads are usually always forward, e.g. similar to a sequential read skipping large portions of the file Focus of GFS is on high overall bandwidth, not latency In contrast to system like e.g. Amazon Dynamo File system API must be simple and expandable Flat file name space suffices File path is treated as string» No directory listing possible Qualifying file names consist of namespace and file name No POSIX compatibility needed Additional support for file appends and snapshot operations Distributed Data Management Christoph Lofi IfIS TU Braunschweig 20

11.2 GFS A GFS cluster represents a single file system for a certain set of applications Each cluster consists of A single master server The single master is one of the key features of GFS! Multiple chunk servers per master Accessed by multiple clients Running on commodity Linux machines Files are split into fixed-sized chunks Similar to file system blocks Each labeled with a 64-bit unique global ID Stored at a chunk server Usually, each chunk is three times replicated across chunk servers Distributed Data Management Christoph Lofi IfIS TU Braunschweig 21

11.2 GFS Application requests are initially handled by a master server Further, chunk-related communication is performed directly between application and chunk server Distributed Data Management Christoph Lofi IfIS TU Braunschweig 22

11.2 GFS Master server Maintains all metadata Name space, access control, file-to-chunk mappings, garbage collection, chunk migration Queries for chunks are handled by the master server Master returns only chunk locations A client typically asks for multiple chunk locations in a single request The master also optimistically provides chunk locations immediately following those requested GFS clients Consult master for metadata Request data directly from chunk servers No caching at clients and chunk servers due to the frequent streaming Distributed Data Management Christoph Lofi IfIS TU Braunschweig 23

11.2 GFS Files (cont.) Each file consists of multiple chunks For each file, there is a meta-data entry File namespace File to chunk mappings Chunk location information Including replicas! Access control information Chunk version numbers Distributed Data Management Christoph Lofi IfIS TU Braunschweig 24

11.2 GFS Chunks are rather large (usually 64MB) Advantages Less chunk location requests Less overhead when accessing large amounts of data Less overhead for storing meta data Easy caching of chunk metadata Disadvantages Increases risk for fragmentation within chunks Certain chunks may become hot spots Distributed Data Management Christoph Lofi IfIS TU Braunschweig 25

11.2 GFS Meta-Data is kept in main-memory of master server Fast, easy and efficient to periodically scan through meta data Re-replication in the presence of chunk server failure Chunk migration for load balancing Garbage collection Usually, there are 64Bytes of metadata per 64MB chunk Maximum capacity of GFS cluster limited by available main memory of master In practice, query load on master server is low enough such that it never becomes a bottle neck Distributed Data Management Christoph Lofi IfIS TU Braunschweig 26

11.2 GFS Master server relies on soft-states Regularly sends heart-beat messages to chunk servers Is chunk server down? Which chunks does chunk server store? Including replicas Are there any disk failures at a chunk server? Are any replicas corrupted? Test by comparing checksums Master can send instructions to chunk server Delete existing chunks Create new empty chunk Distributed Data Management Christoph Lofi IfIS TU Braunschweig 27

11.2 GFS All modifications to meta-data are logged into an operation log to safeguard against GFS master failures Meta-data updates are not that frequent The operation log contains a historical record of critical metadata changes, replicated on multiple remote machines Checkpoints for fast recovery Operation log can also serve to reconstruct a timeline of changes Files and chunks, as well as their versions are all uniquely and eternally identified by the logical times at which they were created In case of failure, the master recovers its file system state by replaying the operation log Usually, a shadow master is on hot-standby to take over during recovery Distributed Data Management Christoph Lofi IfIS TU Braunschweig 28

11.2 GFS Guarantees of GFS Namespace mutations are always atomic Handled by the master with locks e.g. creating new files or chunks Operation is only treated as successful when operation is performed and all log replicas are flushed to disk Distributed Data Management Christoph Lofi IfIS TU Braunschweig 29

11.2 GFS Data mutations follow a relaxed consistency model A chunk is consistent, if all clients see the same data, independently of the queried replica A chunk is defined, if all its modifications are visible i.e. writes have been atomic GFS can recognize defined and undefined chunks In most cases, all chunks should be consistent and defined but not always. Only using append operations for data mutations minimizes probability for undefined or inconsistent chunks Distributed Data Management Christoph Lofi IfIS TU Braunschweig 30

11.2 GFS Mutation operations To encourage consistency among replicas, the master grants a lease for each chunk to a chunk server Server owning the lease is responsible for that chunk i.e. has the primary replica and is responsible for mutation operations Leases are granted for a limited time (e.g. 1 minute) Granting leases can be piggybacked to heartbeat messages Chunk server may request a lease extension, if it currently mutates the chunk If a chunk server fails, a new leases can be handed out after the original one expired» No inconsistencies in case of partitions Distributed Data Management Christoph Lofi IfIS TU Braunschweig 31

11.2 GFS Mutation operations have a separated data flow and control flow Idea: maximize bandwidth utilization and overall system throughput Primary replica chunk server is responsible for control flow Distributed Data Management Christoph Lofi IfIS TU Braunschweig 32

11.2 GFS Mutation workflow overview 4 Client 3 1 2 Master Secondary Replica A 7 3 Primary Replica 3 6 6 5 5 Control flow Data flow Secondary Replica B Distributed Data Management Christoph Lofi IfIS TU Braunschweig 33

11.2 GFS Application originates mutation request 1. GFS client translates request from (filename, data) to (filename, chunk index), and sends it to master Client knows which chunk to modify Does not know where the chunk and its replicas are located 2. Master responds with chunk handle and (primary + secondary) replica locations Client 1 2 Master Distributed Data Management Christoph Lofi IfIS TU Braunschweig 34

11.2 GFS 3. Client pushes write data to all replicas Client selects the best replica chunk server and transfers all new data e. g. closest in the network, or with highest known bandwidth Not necessarily the server holding the lease New data: the new data and the address range it is supposed to replace Exception: appends Data is stored in chunk servers internal buffers New data is stored as fragments in buffer New data is pipelined forward to next chunk server and then the next Serially pipelined transfer of the data Try to optimize bandwidth usage Client 3 Secondary Replica A 3 Primary Replica 3 Secondary Replica B Distributed Data Management Christoph Lofi IfIS TU Braunschweig 35

11.2 GFS 4. After all replicas received the data, the client sends a write request to the primary chunk server Primary determines serial order for new data fragments stored in its buffer and writes the fragments in that order to the chunk Write of fragments is thus atomic No additional write request are served during write operation Possibly multiple fragments from one or multiple clients Client Primary Replica Distributed Data Management Christoph Lofi IfIS TU Braunschweig 36 4

11.2 GFS 5. After the primary server successfully finished writing the chunk, it orders the replicas to write The same serial order is used! Also, the same timestamps are used Replicas are inconsistent for a short time 6. After the replicas completed, the primary server is notified Secondary Replica A 3 Primary Replica 3 Secondary Replica B 6 6 5 5 Distributed Data Management Christoph Lofi IfIS TU Braunschweig 37

11.2 GFS 7. The primary notifies the client Also, all error are reported to the client Usually, errors are resolved by retrying some parts of the workflow Some replicas may contain the same datum multiple times due to retries Only guarantee of GFS: data will be written at least once atomically Failures may render chunks inconsistent 7 Client Primary Replica Distributed Data Management Christoph Lofi IfIS TU Braunschweig 38

11.2 GFS Google aims at using append operations for most mutations For random updates, clients need to provide the exact range for the new data within the file Easy to have collisions with other clients i.e. client A write to range 1, client B overwrites range 1 because it assumed it as empty Usually, locks would solve the problem Appends can be easily performed in parallel Just transfer new data to chunk server Clients can transfer new data in parallel Chunks server buffers data Chunk server will find a correct position at the end of the chunk Additional logic necessary for creating new chunks if current chunk cannot hold new data Typical use case Multiple producers append to the same file while simultaneously multiple consumer read from it e.g. then of the web crawler and feature extraction engine Distributed Data Management Christoph Lofi IfIS TU Braunschweig 39

11.2 GFS Master takes care of chunk creation and distribution New empty chunk creation, re-replication, rebalances Master server notices if a chunk has to few replicas and can rereplicate Master decides on chunk location. Heuristics: Place new replicas on chunk servers with below-average disk space utilization. Over time this will equalize disk utilization across chunk servers Limit the number of recent creations on each chunk server Chunks should have different age to spread chunk correlation Spread replicas of a chunk across racks Distributed Data Management Christoph Lofi IfIS TU Braunschweig 40

11.2 GFS After a file is deleted, GFS does not immediately reclaim the available physical storage Just delete meta-data entry from the master server File or chunks become stale Chunks or files may also become stale if a chunk server misses an update to a chunk Updated chunk has a different Id than old chunk Master server holds only links to new chunks Master knows the current chunks of a file Heartbeat messages with unknown (e.g. old) chunks are ignored During regular garbage collection, stale chunks are physically deleted Distributed Data Management Christoph Lofi IfIS TU Braunschweig 41

11.2 GFS Experiences with GFS Chunk server workload Bimodal distribution of small and large files Ratio of append to write operations: 4:1 to 8:1 Virtually no overwrites Master workload Most request for chunk locations and open files Reads achieve 75% of the network limit Writes achieve 50% of the network limit Distributed Data Management Christoph Lofi IfIS TU Braunschweig 42

11.2 GFS Summary and notable features GFS GFS is a distributed file system Optimized for file append operations Optimized for large files File are split in rather large 64MB chunks and distributed and replicated Uses single master server for file and chunk management All meta-data in master server in main memory Uses flat namespaces Distributed Data Management Christoph Lofi IfIS TU Braunschweig 43

11.3 Bigtable Implementation back to Bigtable Bigtable is a database especially designed to run on top of GFS Bigtable data model also focuses on appends Assumption: rows are frequently added, but rarely updated Row updates will just result in new rows with a different timestamp GFS takes care of replication and load-balancing issues To accommodate for Google's applications, Bigtable uses a very flexible data model Distributed Data Management Christoph Lofi IfIS TU Braunschweig 44

11.3 Bigtable: Data Model Don t think of Bigtables as spreadsheet or traditional DB table Unfitting name. e.g. rows do not have a fixed size/number of attributes Not: Each column has a data type Not: Missing values denoted as null Table as NOT used by Bigtable rowa rowb rowc rowd cola colb colc cold NULL? NULL? NULL? Distributed Data Management Christoph Lofi IfIS TU Braunschweig 45

11.3 Bigtable: Data Model Instead, Bigtable implements a multi-dimensional sparse map Think of columns as available tags Cells are referenced by (row_name, col_name, timestamp) Each row can use just some columns and story any value Columns are just roughly typed, i.e. binary, string, numeric, Table as used by Bigtable rowa cola value colb value2 colb value2 time: 70 time: 100 rowb colc really long value colc really long value colc really long value time: 40 time: 60 time: 100 rowc colb value3 cold huge blob time: 110 cola value time: 120 Distributed Data Management Christoph Lofi IfIS TU Braunschweig 46

11.3 Bigtable: Data Model Rows Each row has a unique name Name is just an arbitrary string e.g. www.ifis.cs.tu-bs.de Each access to a row is atomic Load and store whole rows Rows are ordered lexicographically Idea: after partitioning the table, lexicographically similar rows are within the same or a nearby fragment e.g. www.ifis.cs.tu-bs.de is close to www.ifis.cs.tu-bs.de/staff Rows will never be split during partitioning Distributed Data Management Christoph Lofi IfIS TU Braunschweig 47

11.3 Bigtable: Data Model Columns Each column has a two-level name structure Family name and qualifier name e.g. <family:qualifier> All column families must be created explicitly as part of schema creation Columns within a family have usually a similar type Data of a row within a family are often stored and compressed together Individual columns can be used by application freely and flexibly Individual columns are not part of schema creation Flexible data model Aims Have a few (max. 100 (!)) column families which rarely change Let application create columns as needed Distributed Data Management Christoph Lofi IfIS TU Braunschweig 48

11.3 Bigtable: Data Model Timestamps Of each cell, different versions are maintained with their respective timestamps 64 Bit integers Updates to a cell usually create a new version with the current system time as timestamp But timestamp can also be set explicitly by application During column family creation, versioning options are provided Either keep n copies or keep versions up to the age of n seconds Typical queries ask for timestamp ranges Distributed Data Management Christoph Lofi IfIS TU Braunschweig 49

11.3 Bigtable: Data Model The base unit of load balancing and partitioning are called tablets i.e. tables are split in multiple tablets Tablets hold a contiguous range of rows Hopefully, row ordering will result in locality Tablets are disjoint No overlapping value ranges Tablets are rather large (1GB by default) and are later stored in GFS i.e. tablets will usually have multiple GFS chunks Tablets need to contain full rows A single row should not exceed several hundred MB such that it will fit into a tablet Distributed Data Management Christoph Lofi IfIS TU Braunschweig 50

11.3 Bigtable - API Bigtable provides only very simple native API interfaces to applications e.g. in C++ or Python No complex query language like SQL API can Create and delete tables and column families Modify cluster, table, and column family metadata such as access control rights, Write or delete directly addressed values in Bigtable Supports just single row transactions (i.e. read-modify-write) No multi-row transactions Look up values from individual rows Iterate over a subset of the data in a table, Can be restricted to certain column families or timestamps Relies on regular expressions on row and columns names Distributed Data Management Christoph Lofi IfIS TU Braunschweig 51

11.3 Bigtable - API Recap Semi-flexible schemas are supported A table consist of named rows and columns All data cells are versioned with timestamps Columns are grouped in column families which are defined in the schema Families are usually stable during application life Columns can be dynamically used and added by applications as they seem fit As a result, table is very sparse i.e. it resembles a multi-dimensional map Tables are broken down into tablets Tables hold a continuous and ordered non-overlapping row name range Horizontal fragmentation Distributed Data Management Christoph Lofi IfIS TU Braunschweig 52

11.3 Bigtable Application 1: Google Analytics Enables webmasters to analyze traffic pattern at their web sites. Provides statistics such as: Number of unique visitors per day and the page views per URL per day Percentage of users that made a purchase given that they earlier viewed a specific page How is it done? A small JavaScript program that the webmaster embeds in their web pages Every time the page is visited, the program is executed Program records the following information about each request User identifier The page being fetched Distributed Data Management Christoph Lofi IfIS TU Braunschweig 53

Bigtable Application 2: Google Earth & Maps Functionality: Storage and display of satellite imagery at different resolution levels One Bigtable stores raw imagery (~ 70 TB): Row name is a geographic segments Names are chosen to ensure adjacent geographic segments are clustered together Column family maintains sources of data for each segment. There are different sets of tables for serving client data, e.g., index table Distributed Data Management Christoph Lofi IfIS TU Braunschweig 54

11.3 Bigtable Application 3: Personalized Search Records user queries and clicks across Google properties Users browse their search histories and request for personalized search results based on their historical usage patterns One Bigtable Row name is userid A column family is reserved for each action type, e.g., web queries, clicks User profiles are generated using MapReduce. These profiles personalize live search results Replicated geographically to reduce latency and increase availability Distributed Data Management Christoph Lofi IfIS TU Braunschweig 55

11.3 Bigtable: Implementation Implementing Bigtable Bigtable runs on standard Google server nodes Each server node usually runs multiple services Some application server instances e.g. a web renderer, a crawler, etc. A map-reduce worker Can accept any map-reduce request by a scheduler when idling A GFS chunk server instance A Bigtable server map-reduce application 2 GFS server application 1 Bigtable server Cluster Management Layer Linux Standard Google Server Distributed Data Management Christoph Lofi IfIS TU Braunschweig 56

11.3 Bigtable: Implementation Usually, a Bigtable cluster consists of multiple tablet servers and a single master server Master controls and maintains tablet servers Assigns and migrates tablets Controls garbage collection and load balancing Maintains schema Clients usually never contact master Tablet servers are responsible for tablets Can be dynamically added and removed Master controls tablet migrations Clients know the tablet server responsible for their data Distributed Data Management Christoph Lofi IfIS TU Braunschweig 57

11.3 Bigtable: Implementation Typical Bigtable cell Cluster Mngt. Server Chubby Lock Manager GFS Master Map-Reduce application 1 Bigtable server Bigtable server Bigtable Master GFS server GFS server GFS server Cluster Mngt. Layer Cluster Mngt. Layer Cluster Mngt. Layer Linux Linux Linux Distributed Data Management Christoph Lofi IfIS TU Braunschweig 58

11.3 Bigtable: Managing Tablets Each tablet server node is responsible for around 10 to 1000 randomly scattered tables Much more tablets than nodes! Each tablet is assigned to just one node Easy recovery After a Bigtable node fails, 10 to 1000 machines need to pick up just one tablet Good initial load balancing Remember: rows within tablets are continuous for locality Node holds very different tablets Some may be hot and some may be cold Very easy runtime load balancing Overloaded node simply migrates a tablet to a under-utilized node Bigtable master decides on load-balancing migration Distributed Data Management Christoph Lofi IfIS TU Braunschweig 59

11.3 Bigtable: Managing Tablets Tablets can be split and migrated if they grow to big Distributed Data Management Christoph Lofi IfIS TU Braunschweig 60

11.3 Bigtable: Managing Tablets Split tablets Distributed Data Management Christoph Lofi IfIS TU Braunschweig 61

11.3 Bigtable: Managing Tablets Clients which try to work on certain data must first locate the responsible tablet Tablets may freely move across the servers Two options A) Just ask master server which must then keep a directory B) Store tablet location in a index within Bigtable itself Option B is implemented Tablets are organized in a 3-tier hierarchy which serves as a distributed index Think of a B-Tree Distributed Data Management Christoph Lofi IfIS TU Braunschweig 62

11.3 Bigtable: Managing Tablets Entry point is always a Chubby file Chubby: distributed lock manager In short: can store a tiny file in a distributed, persistent and indestructible fashion May hand out exclusive locks on the files Root tablet serves as entry point and is never split Just points forward to metadata tablets Metadata tablets represent an index table For each actual data tablet, the row name range (start and end) and the responsible tablet server are stored Root tablet stores row name range (start and end) of the responsible metadata tablet Distributed Data Management Christoph Lofi IfIS TU Braunschweig 63

11.3 Bigtable: Managing Tablets Chubby file points to the tablet server holding the root tablet Root tablet links to meta-data tablets Meta-data tablets link to actual data tablets Distributed Data Management Christoph Lofi IfIS TU Braunschweig 64

11.3 Bigtable: Managing Tablets Each tablet is assigned to one tablet server Each tablet is stored as a GFS file Thus, tablets are durable and distributed Usually, the GFS primary replica and the GFS lease of a tablet file are held by the same machine as the tablet server Remember: each Bigtable server also runs a GFS server Read and writes are thus performed on local disk If a tablet server is assigned a new tablet, it is usually a good idea to request the background transfer of all GFS chunks related to that tablet to the new server Distributed Data Management Christoph Lofi IfIS TU Braunschweig 65

11.3 Bigtable: Managing Tablets Master keeps track of available tablet servers and all tablets not assigned to any server Master can use metadata tables for this Metadata list all tablets Orphaned tablets can be assigned by Master A tablet server opens all tablets it is assigned to e.g. load indexes into main memory Distributed Data Management Christoph Lofi IfIS TU Braunschweig 66

11.3 Bigtable: Managing Tablets A new tablet server joins Tablet server registers itself with the lock-manager (Chubby) by creating an ID file in a special directory and obtaining a time-decaying lock for it Tablet server periodically re-acquires lock Bigtable master monitors directory and contacts new servers A tablet server leaves or fails Server lock expires Bigtable master notices when a lock is lost Distributed Data Management Christoph Lofi IfIS TU Braunschweig 67

11.3 Bigtable: Managing Tablets Detecting lost tablet servers Master server periodically tries to obtain locks on the ID files of all known tablet servers If everything is OK, request is denied If lock is granted, the respective server is dead All its tablets are reassigned (tablets themselves are stored on GFS and are not affected by tablet server loss) Delete the servers ID file Distributed Data Management Christoph Lofi IfIS TU Braunschweig 68

11.3 Bigtable: Managing Tablets If Chubby session holding the server ID file expires or has a time out, masters kills itself A new master starts A unique Chubby lock is acquired to ensure that there is just one master Lock also identifies master Lock may decay and must be renewed If lock is lost, the master failed and a new master must be elected Load current tablet assignments from root tablets Root tablet location is also in Chubby Contact all tablets servers to check if they are OK Distributed Data Management Christoph Lofi IfIS TU Braunschweig 69

11.3 Bigtable: Managing Tablets Recap A big table cell consist of multiple tablet servers and a single master server Distributed lock services is used to check for node failures Bigtable server also run a GFS server Master server distributed tablets to tablet servers Responsible for maintenance Load balancing, failure recovery, etc. Specialized root tablets and metadata tablets are used as an index to look up responsible tablet servers for a given data range Clients don t communicate with master server Usually, they work only with one or very few tablet servers on small data ranges Bigtable can become very complicated to use if clients don t work on limited ranges! Distributed Data Management Christoph Lofi IfIS TU Braunschweig 70

Tablet 11.3 Bigtable: Implementation Each tablet directly interacts with several components Tablet data is stored in several immutable SSTables SSTable are stored in GFS An additional memtable holds data not yet stored in a SSTable Stored in main memory All writes are preformed on memtable first A persistent append-only log for all write operations Log is shared with all tablets of the tablet server in is also stored in GFS Metadata: start row, end row memtable Log SSTable 1 SSTable 2 SSTable n Distributed Data Management Christoph Lofi IfIS TU Braunschweig 71

11.3 Bigtable: Implementation SSTables are immutable ordered maps holding key-value pairs Each entry represents a cells Key are triples of <row, column, timestamp> Value is the actual cell value SSTables can very easily be traversed as they are ordered Each SSTable has a clearly defined start key and end key However, ranges of SSTables may overlap! Immutability eliminates consistency problems A SSTable can never be changed (only completely deleted during compaction) No locks necessary for reads and writes Parallel read are always possible without danger of interference Distributed Data Management Christoph Lofi IfIS TU Braunschweig 72

SSTable 11.3 Bigtable: Implementation Internally, SSTables consist of multiple 64KB blocks of data Again, each block is an ordered map Each SSTable has a special index block mapping key ranges to their responsible block number Every time a tablet is opened, all SSTable index blocks are loaded to the tablet server main memory Metadata: start key, end key 64k block 64k block 64k block Index block Distributed Data Management Christoph Lofi IfIS TU Braunschweig 73

11.3 Bigtable: Write and Read Write operations must ensure atomicity and also store the data within the SSTables Write operation arrives at a tablet server Server checks if the client has sufficient privileges for the write operation (Chubby) A log record is generated to the commit log file Once the write commits, its contents are inserted into the memtable Copy-on-write on row basis to maintain row consistency e.g. a write request is completed at a temporary location and then atomically copied into the memtable Memtable is also sorted by keys similar to SSTables Nothing stored in SSTables yet! write temp Metadata: start row, end row Tablet Log memtable Distributed Data Management Christoph Lofi IfIS TU Braunschweig 74

11.3 Bigtable: Write and Read Memtable size increases with number of write operations After a threshold is reached, the current memtable is frozen and a new one is created Frozen memtable is serialized to disk Called minor compaction Note: with a quite high probability, SSTables will now have overlapping ranges! Also committed to log after operation was successful Data is now persistent and does probably not need recovery from log files Distributed Data Management Christoph Lofi IfIS TU Braunschweig 75

Tablet 11.3 Bigtable: Write and Read Read operation for a certain range / key arrives at a tablet server Server ensures client has sufficient privileges for the read operation (Chubby) Tablet server uses index blocks of all SSTables and the memtable to find all blocks with matching range All related blocks and the memtable are merged into a sorted, unified view Merge can be performed very efficiently as all components are pre-sorted (e.g. like merge-sort) Binary search is possible on the merged view memtable read SSTable 1 SSTable 2 SSTable 3 SSTable n Distributed Data Management Christoph Lofi IfIS TU Braunschweig 76

11.3 Bigtable: Write and Read If keys are to be deleted, they are written with a special delete flag as value In periodic intervals, major compactions are performed Background maintenance operation, normal read and writes can still continue Several overlapping SSTables and/or the memtable are compacted into a set of non-overlapping SSTables Increases read performance (less overlapping SSTable less merging) Deleted records may now be removed Possibly, also all its old versions (sensible data must be guaranteed to be deleted) Distributed Data Management Christoph Lofi IfIS TU Braunschweig 77

11.3 Bigtable: Write and Read If a tablet server crashes, tablets are reassigned by the Bigtable master to a new tablet server All SSTable files are persistently stored in GFS and are not affected by the server failure Memtable is lost Memtable can be reconstructed by replaying the crashed servers log files starting from last minor compaction checkpoint Server log file was also stored in GFS! Distributed Data Management Christoph Lofi IfIS TU Braunschweig 78

11.3 Bigtable: Write and Read Further Bigtable optimizations Locality Groups Group columns frequently accessed together such that their values will be in the same or a close SSTable Creates semantic locality Locality group provided manually by developers Access to SSTables minimized for certain applications e.g. webcraweler: keywords, name, pagerank in one locality group, content in another Distributed Data Management Christoph Lofi IfIS TU Braunschweig 79

11.3 Bigtable: Write and Read Compression Most data in Google can be easily compresses (HTML files, keywords, etc.) SSTable blocks are compressed individually Takes advantage of locality groups: data within a block should be similar E.g. two pages of the same website sharing most navigation components Simple two-pass frequent term compression Due to locality very good reduction rates of 10-to-1 Distributed Data Management Christoph Lofi IfIS TU Braunschweig 80

11.3 Bigtable: Write and Read Recap Tablets are persistently stored in multiple SSTables in GFS SSTable are immutable ordered key-value maps Contains table cells No locking problems for SSTable access All write operations are performed in RAM memtable After memtable is big enough, it is serialized into a new, full and immutable SSTable Read operations dynamically merge all responsible SSTables (from index) and the memtable SSTable need to be compacted from time to time If not, too many SSTable are responsible for the same ranges Distributed Data Management Christoph Lofi IfIS TU Braunschweig 81

11.3 Bigtable Google Bigtable is a NoSQL database No complex query language supported Mainly based on scans and direct key accesses Single table data model No joins No foreign keys No integrity constraints Flexible schemas Column may be added dynamically Usually, Bigtable is not a direct replacement for a distributed database Distributed Data Management Christoph Lofi IfIS TU Braunschweig 82

Bigtable Google projects and tablets in 2006 Distributed Data Management Christoph Lofi IfIS TU Braunschweig 83

HBase Hbase is an open-source clone of Bigtable http://hbase.apache.org/ Created originally at Powerset in 2007 Hbase is a Apache Hadoop subproject Hadoop is strongly supported by Microsoft and Yahoo http://hadoop.apache.org/ Hadoop reimplements multiple Google-inspired infrastructure services MapReduce Google Map And Reduce Hbase Bigtable HDFS GFS ZooKeeper Chubby Distributed Data Management Christoph Lofi IfIS TU Braunschweig 84

Next Lecture 12.0 Data Storage at Yahoo 12.1 Sherpa/PNUTS 12.2 Map & Reduce Distributed Data Management Christoph Lofi IfIS TU Braunschweig 85