Professional Documents
Culture Documents
• Data Management
‒ Storage formats
‒ Compression
‒ Schema Design
• Storage Systems – Hbase
• Lab Environment walk through
Key Choices
1. Data Storage Formats (what file format to store data in)
2. Compression
3. Schema Design (organization of the files in the filesystem)
4. Meta-Data Management
5. Security
Server log files on a central Typically key-value log files in binary format; lot’s of small files
web server
Lucene search indexes in Inverted index data structure optimized for full-text search
HDFS
RCFile
Binary Image
Columnar Format ORC
Parquet
Record Compressed
Block Compressed
IP 121.121.121.111 IP 121.122.122.122
SequenceFile
Key Value
21-Aug-2016 server_log_21-aug-2016
22-Aug-2016 server_log_22-aug-2016
… …
… …
Deserialization is the reverse process of turning a byte stream back into a series of structured objects.
Support clients that are written in different Read or write persistent data using
languages to the server Interoperable different languages
1 2 3 4 5 6 7 8 9 10 11 12 Row Oriented
Layout
Row 1 Split Row 2 Split
Col 1 Col 2 Col 3 Col 1 Col 2 Col 3
1 4 2 5 3 6 7 10 8 11 9 12 Column Oriented
Layout
MITB B.5 Big Data Technologies
Hadoop File Formats – Columnar Formats
Advantages of Columnar Formats
• Skips I/O and decompression (if applicable) on columns that are not a part of the query
• Works well for queries that only access a small subset of columns. If many columns are being
accessed, then row-oriented is generally preferable
• Generally very efficient in terms of compression on columns because entropy within a column is
lower than entropy within a block of rows
• Well suited for data-warehousing-type applications where users want to aggregate certain columns
over a large collection of records
LZO files are splittable if they have been indexed in a pre-processing step
• Break up the data set into smaller sets, each subset being called a partition
• Each partition would be in a sub-directory of the directory containing the entire data set
• Example
• <data set
name>/<partition_column_name=partition_column_value>/{files}
• Technique for decomposing large data sets into more manageable sub sets
• Partitioning by the wrong column can result in the small file problem
• Trade-off between number of files – small number is inefficient to manage and large would
cause long scan times and slow down query
Courtesy Hortonworks
http://www.slideshare.net/HadoopSummit/file-format-
benchmark-avro-json-orc-parquet
Courtesy Cloudera
http://blog.cloudera.com/blog/2016/04/benchmarki
ng-apache-parquet-the-allstate-experience/
1 2 3 4 5 6 7 8 9 10 11 12 Row Oriented
Layout
Row 1 Split Row 2 Split
Col 1 Col 2 Col 3 Col 1 Col 2 Col 3
1 4 2 5 3 6 7 10 8 11 9 12 Column Oriented
Layout
MITB B.5 Big Data Technologies
Row Oriented Vs. Column Oriented
• Provides real-time, random read and write access to tables meant to store billions
of rows and millions of columns
• Designed to run on commodity hardware and scale horizontally while retaining
performance
• Fault tolerant leveraging HDFS’s redundancy
‒ When servers fail, data is automatically re-balanced over the remaining
servers
• Strong consistency model – changes are visible to all other clients
• Modeled after Google’s BigTable
• The row key maps to a list of column families, which map to a list of column
qualifiers, which map to a list of timestamps, each of which map to a value, i.e., the
cell itself
Column Families
• This
representation
of the Hbase
data model Column Qualifiers
leads it to being
called a key
value store
• Key is formed
by [row key, Time Stamp / Version
column family,
column qualifier,
timestamp] Cell Value
• Value is the
contents of the
cell
MITB B.5 Big Data Technologies
Hbase Architecture
- Hbase Master
- Region Servers
• ZooKeeper
• HDFS
Start Key Region Start Key Region Start Key Region Start Key Region
• HBase Tables are divided horizontally by row key range into “Regions”
• A region contains all rows in the table between the region’s start key and end key
• Regions are assigned to the nodes in the cluster, called “Region Servers”
• Region Servers are co-located with the HDFS DataNodes, which enable data locality
• Region servers are responsible for all read and write requests for all regions they serve
• Clients communicate directly with them to handle all data-related operations
MITB B.5 Big Data Technologies
Hbase Master
HMaster Client
Start Key Region Start Key Region Start Key Region Start Key Region
Heartbeat
Region Server 1 Region Server 2
Start Key Region Start Key Region Start Key Region Start Key Region
• Zookeeper maintains which servers are alive and available, and provides server failure notification
Block Cache
• Used to store new data that hasn't yet been
persisted to permanent storage
Region Region
Start Key Start Key • Used for recovery in the case of failure.
Memstore Memstore 2. BlockCache (read cache)
Memstore Memstore
• Stores frequently read data in memory.
WAL Hfile Hfile
• Least Recently Used data is evicted when full.
Hfile Hfile
End Key End Key 3. MemStore (write cache)
HDFS • Stores new data which has not yet been written to
disk.
• It is sorted before writing to disk.
• There is one MemStore per column family per
region.
4. Hfiles store the rows as sorted KeyValues on disk.
Region Region
PUT
WAL Memstore WAL Memstore
Memstore Memstore
HDFS HDFS
Region Region
FLUSH
Hfile Hfile
HDFS Hfile Hfile
HDFS
• Memstore stores data as KV pair
• One Memstore per column family • Sorted set written to new HFile in HDFS
• Updates sorted per column family • When one Memstore full, all flush
• Saves last written sequence number
- Avoiding Hotspotting
- Block Cache and Memstore sizes
- Bloom Filters
- Write Amplification
MITB B.5 Big Data Technologies
Critique
Thrift + Finagle
layer
Hbase
• Core storage in
Alibaba search
system since
2010
• 3 clusters each
with 1,000+
nodes
Hbase
Hbase Reference Guide
https://hbase.apache.org/book.html
Facebook
http://www.slideshare.net/cloudera/h-base-in-production-at-facebook-jonthan-grayfacebookfinal
Xiaomi
http://www.slideshare.net/HBaseCon/apache-hbase-improvements-and-practices-at-xiaomi
Alibaba Search
http://www.slideshare.net/HBaseCon/improvements-to-apache-hbase-and-its-applications-in-alibaba-search
Pinterest
http://www.slideshare.net/AbhiKhune/scaling-deep-social-feeds-at-pinterest
Visa
http://www.slideshare.net/HBaseCon/rolling-out-apache-hbase-for-mobile-offerings-at-visa
MITB B.5 Big Data Technologies