Docsity

BigTable: Google's Distributed Database System - Prof. Ling Liu, Study notes of Computer Science

Toggle sidebar
bg1
1
BigTable
A Distributed Storage
System For Structured Data
Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C.
Hsieh, Deborah A. Wallach, Mike Burrows, Tushar Chandra,
Andrew Fikes, Robert E. Gruber
Google Inc.
[OSDI 2006]
See UW presentation by Jeff Dean from the link on the seminar page, or just
google for “google bigtable”
Data Storage: BigTable
What is it, really?
• 10-ft view: Row &
• column abstraction for
storing data
• Reality: Distributed,
persistent, multi-level
sorted map
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download BigTable: Google's Distributed Database System - Prof. Ling Liu and more Study notes Computer Science in PDF only on Docsity!

BigTable

A Distributed Storage

System For Structured Data

Fay Chang, Jeffrey Dean, Sanjay Ghemawat, Wilson C.

Hsieh, Deborah A. Wallach, Mike Burrows, Tushar Chandra,

Andrew Fikes, Robert E. Gruber

Google Inc. [OSDI 2006]

See UW presentation by Jeff Dean from the link on the seminar page, or just google for “google bigtable”

Data Storage: BigTable

What is it, really?

• 10-ft view: Row &

• column abstraction for

storing data

• Reality: Distributed,

persistent, multi-level

sorted map

Status

  • Design/initial implementation started beginning of 2004
    • Take about 12 guys and putting in active use for about 8 months
  • By Nov. 2005, it has ~100 BigTable cells
  • Production use or active development for many internal

projects:

  • Google Print
  • My Search History
  • Orkut
  • Crawling/indexing pipeline
  • Google Maps/Google Earth
  • Blogger
  • …
  • Largest bigtable cell manages ~200TB of data spread over

several thousand machines (larger cells planned)

Sample Problem Domains

• Offline batch jobs

  • Large datasets (PBs), bulk reads/writes (MB chunks)
  • Short outages acceptable
  • Web indexing, log processing, satellite imagery, etc.

• Online applications

  • Smaller datasets (TBs), small reads/writes small (KBs)
  • Outages immediately visible to users, low latency vital
  • Web search, Orkut, GMail, Google Docs, etc.

• Many areas: IR, machine learning, image/video

processing, NLP, machine translation, ...

Why not just use commercial DB?

  • Most commercial databases: Scale is too large
  • Cost would be very high
    • Building internally means system can be applied across

many projects for low incremental cost

  • a very small incremental cost for new services and

expanded computing power

  • Low-level storage optimizations help performance significantly - Much harder to do when running on top of a database

layer

Also fun and challenging to build large-scale systems :)

Goals

  • Want asynchronous processes to be continuously updating

different pieces of data

  • Want access to most current data at any time
  • Need to support:
  • Very high read/write rates (millions of ops per second)
  • Efficient scans over all or interesting subsets of data
  • Efficient joins of large one-to-one and one-to-many datasets
  • Often want to examine data changes over time
  • E.g. Contents of a web page over multiple crawls

BigTable as A Storage System

• Distributed multi-level map

  • With an interesting data model

• Fault-tolerant, persistent

• Scalable

  • Thousands of servers
  • Terabytes of in-memory data
  • Petabyte of disk-based data
  • Millions of reads/writes per second, efficient scans

• Self-managing

  • Servers can be added/removed dynamically
  • Servers adjust to load imbalance

BigTable Overview

• Data Model

• Hardware infrastructure

• Distributed systems infrastructure:

  • Scheduling system
  • GFS
  • BigTable
  • MapReduce

• Implementation Structure

  • Tablets, compactions, locality groups, …

• API and other Details

  • Shared logs, compression, replication, …

• Challenges and Future Directions

  • Infrastructure that spans all datacenters
  • More automation

Columns

  • Columns have two-level name structure:
    • Family:optional_qualifier
  • Column family
    • Unit of access control
    • Has associated type information
  • Qualifier gives unbounded columns
    • Additional level of indexing, if desired

“CNN homepage”

“anchor:cnnsi.com”

cnn.com “…”

“contents:” “anchor:stanford.edu”

“CNN”

Timestamps

  • Used to store different versions of data in a cell
    • New writes default to current time, but timestamps for writes can also be set explicitly by clients
  • Lookup options:
    • “Return most recent K values”
    • “Return all values in timestamp range (or all values)”
  • Column families can be marked w/ attributes:
    • “Only retain most recent K values in a cell”
    • “Keep values until they are older than K seconds”

Tablets

• Large tables broken into tablets at row boundaries

  • Tablet holds contiguous range of rows
    • Clients can often choose row keys to achieve locality
  • Tablets are each around ~100MB to 200MB of data

• Serving machine responsible for ~100 tablets

(stored in GFS)

  • Fast recovery:
    • 100 machines each pick up 1 tablet from failed machine
  • Fine-grained load balancing
    • Migrate tablets away from overloaded machine
    • Master makes load-balancing decisions

Tablet Representation

  • SSTable: Immutable on-disk ordered map from stringÆstring
  • String keys: <row, column, timestamp> triples

Write buffer in memory (random-access) Append-only log on GFS

SSTable on GFS

SSTable on GFS

SSTable on GFS (mmap)

Tablet

Write

Read

Tablets contd...

• Contains some range of rows of the table

• Built out of multiple SSTables

Index

64K block

64K block

64K block

SSTable

Index

64K block

64K block

64K block

SSTable

Tablet Start:aardvark^ End:apple

Table

• Multiple tablets make up the table

• SSTables can be shared

• Tablets do not overlap, SSTables can overlap

SSTable SSTable SSTable SSTable

Tablet aardvark apple

Tablet apple_two_E boat

BigTable: Building Blocks

Building blocks:

  • Google File System (GFS): Raw storage
  • Scheduler: schedules jobs onto machines
  • Lock service: distributed lock manager
    • Also can reliably hold tiny files (100s of bytes) w/ high availability
  • MapReduce: simplified large-scale data processing

BigTable uses of building blocks:

  • GFS: stores persistent state
  • Scheduler: schedules jobs involved in BigTable serving
  • Lock service: master election, location bootstrapping
  • MapReduce: often used to read/write BigTable data

BigTable: System Structure

Cluster Scheduling Master

handles failover, monitoring

GFS

holds tablet data, logs

Lock service holds metadata, handles master-election

Bigtable tablet server serves data

Bigtable tablet server serves data

Bigtable tablet server serves data

Bigtable master performs metadata ops, load balancing

Bigtable cell

Bigtable client Bigtable client library

Open()

Current Design

• In-house rack design

• PC-class motherboards

• Low-end storage and

networking hardware

• Linux + in-house

software

The Joys of Real Hardware

Typical first year for a new cluster:

  • ~0.5 overheating (power down most machines in <5 mins, ~1-2 days to recover)
  • ~1 PDU failure (~500-1000 machines suddenly disappear, ~6 hours to come back)
  • ~1 rack-move (plenty of warning, ~500-1000 machines powered down, ~ hours)
  • ~1 network rewiring (rolling ~5% of machines down over 2-day span)
  • ~20 rack failures (40-80 machines instantly disappear, 1-6 hours to get back)
  • ~5 racks go wonky (40-80 machines see 50% packet loss)
  • ~8 network maintenances (4 might cause ~30-minute random connectivity losses)
  • ~12 router reloads (takes out DNS and external vips for a couple minutes)
  • ~3 router failures (have to immediately pull traffic for an hour)
  • ~dozens of minor 30-second blips for dns
  • ~1000 individual machine failures
  • ~thousands of hard drive failures

slow disks, bad memory, misconfigured machines, flaky

machines, etc.

Typical Cluster

Machine 1

Scheduler Slave

GFS Chunkserver

Linux

Cluster Scheduling Master Chubby Lock Service GFS Master

User Task

Machine 2

Scheduler Slave

GFS Chunkserver

Linux

User Task

Machine N

Scheduler Slave

GFS Chunkserver

Linux

Single Task

BigTable Server

BigTable Server (^) BigTable Master

Google File System (GFS)

  • Master manages metadata
  • Data transfers happen directly between clients/chunkservers
  • Files broken into chunks (typically 64 MB)
  • Chunkks triplicated across three machines for safety
  • See SOSP^03 paper at http://labs.google.com/papers/gfs.html

Replicas

Master

GFS Master

GFS Master

Client

Client

C0 C1 C

C3 C4 C

C

C

C

C

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

• One approach: could use the BigTable master

  • Central server almost certainly would be bottleneck in

large system

• Instead: store special tables containing tablet

location info in BigTable cell itself

Locating Tablets (cont.)

• Three-level hierarchical lookup scheme for tablets

  • Location is ip:port of relevant server
  • 1 st^ level: bootstrapped from lock server, points to owner of META
  • 2 nd^ level: Uses META0 data to find owner of appropriate META1 tablet
  • 3 rd^ level: META1 table holds locations of tablets of all other tables
    • META1 table itself can be split into multiple tablets

Pointer

to META

location

META0 tablet

META1 tablets Actual tablet in table T

Aggressive prefetching+caching, Most ops go right to proper machine

Locating tablets (contd..)

Tablet Assignment

  • 1 Tablet => 1 Tablet server
  • Master keeps tracks of set of live tablet serves and

unassigned tablets.

  • Master sends a tablet load request for unassigned tablet to

the tablet server.

  • BigTable uses Chubby to keep track of tablet servers.
  • On startup a tablet server:
    • It creates, acquires an exclusive lock on uniquely named file in Chubby directory.
    • Master monitors the above directory to discover tablet servers.
  • Tablet server stops serving
    • Its tablets if its loses its exclusive lock.
    • Tries to reacquire the lock on its file as long as the file still exists.

• Master startup steps -

  • Grabs unique master lock in Chubby.
  • Scans the server directory in Chubby.
  • Communicates with every live tablet server
  • Scans METADATA table to learn set of tablets.

Tablet Assignment (Contd…)

Tablet Serving

• Updates committed to a commit log

• Recently committed updates are stored in memory –

memtable

• Older updates are stored in a sequence of SSTables.

• Recovering tablet -

  • Tablet server reads data from METADATA table.
  • Metadata contains list of SSTables and pointers into any commit log that may contain data for the tablet.
  • Server reads the indices of the SSTables in memory
  • Reconstructs the memtable by applying all of the updates since redo points.

Compactions

• Tablet state represented as set of immutable

compacted SSTable files, plus tail of log (buffered

in memory)

• Minor compaction:

  • When in-memory state fills up, pick tablet with most data and write contents to SSTables stored in GFS - Separate file for each locality group for each tablet

• Major compaction :

  • Periodically compact all SSTables for tablet into new base SSTable on GFS - Storage reclaimed from deletions at this point

Compactions

• Minor compaction

  • When in-memory state fills up, pick tablet with most data

and write contents to SSTables stored in GFS

  • Separate file for each locality group for each tablet.

• Merging Compaction

  • Periodically compact all SSTables for tablet into new base

SSTables on GFS

  • Storage reclaimed from deletions at this point.

• Major Compaction

  • Merging compaction that results in only one SS table.
  • No deleted records, only sensitive live data.