SlideShare a Scribd company logo
1© Cloudera, Inc. All rights reserved.
Apache Kudu & Apache Spark SQL
for Fast Analytics on Fast Data
Mike Percy
Software Engineer at Cloudera
Apache Kudu PMC member
2© Cloudera, Inc. All rights reserved.
Kudu Overview
3© Cloudera, Inc. All rights reserved.
HDFS
Fast Scans, Analytics
and Processing of
Static Data
Fast On-Line
Updates &
Data Serving
Arbitrary Storage
(Active Archive)
Fast Analytics
(on fast-changing or
frequently-updated data)
Traditional Hadoop Storage Leaves a Gap
Use cases that fall between HDFS and HBase were difficult to manage
Unchanging
Fast Changing
Frequent Updates
HBase
Append-Only
Real-Time
Complex Hybrid
Architectures
Analytic
Gap
Pace of Analysis
PaceofData
4© Cloudera, Inc. All rights reserved.
HDFS
Fast Scans, Analytics
and Processing of
Static Data
Fast On-Line
Updates &
Data Serving
Arbitrary Storage
(Active Archive)
Fast Analytics
(on fast-changing or
frequently-updated data)
Kudu: Fast Analytics on Fast-Changing Data
New storage engine enables new Hadoop use cases
Unchanging
Fast Changing
Frequent Updates
HBase
Append-Only
Real-Time
Kudu Kudu fills the Gap
Modern analytic
applications often
require complex data
flow & difficult
integration work to
move data between
HBase & HDFS
Analytic
Gap
Pace of Analysis
PaceofData
5© Cloudera, Inc. All rights reserved.
Apache Kudu: Scalable and fast tabular storage
Tabular
• Represents data in structured tables like a relational database
• Strict schema, finite column count, no BLOBs
• Individual record-level access to 100+ billion row tables
Scalable
• Tested up to 275 nodes (~3PB cluster)
• Designed to scale to 1000s of nodes and tens of PBs
Fast
• Millions of read/write operations per second across cluster
• Multiple GB/second read throughput per node
6© Cloudera, Inc. All rights reserved.
Storing records in Kudu tables
• A Kudu table has a SQL-like schema
• And a finite number of columns (unlike HBase/Cassandra)
• Types: BOOL, INT8, INT16, INT32, INT64, FLOAT, DOUBLE, STRING, BINARY,
TIMESTAMP
• Some subset of columns makes up a possibly-composite primary key
• Fast ALTER TABLE
• Java, Python, and C++ NoSQL-style APIs
• Insert(), Update(), Delete(), Scan()
• SQL via integrations with Spark and Impala
• Community work in progress / experimental: Drill, Hive
7© Cloudera, Inc. All rights reserved.
Kudu SQL access
- Kudu itself is just storage and native “NoSQL” APIs
- SQL access via integrations with Spark, Impala, etc.
8© Cloudera, Inc. All rights reserved.
Kudu “NoSQL” APIs - Writes
KuduTable table = client.openTable(“my_table”);
KuduSession session = client.newSession();
Insert ins = table.newInsert();
ins.getRow().addString(“host”, “foo.example.com”);
ins.getRow().addString(“metric”, “load-avg.1sec”);
ins.getRow().addDouble(“value”, 0.05);
session.apply(ins);
session.flush();
9© Cloudera, Inc. All rights reserved.
Kudu “NoSQL” APIs - Reads
KuduScanner scanner = client.newScannerBuilder(table)
.setProjectedColumnNames(List.of(“value”))
.build();
while (scanner.hasMoreRows()) {
RowResultIterator batch = scanner.nextRows();
while (batch.hasNext()) {
RowResult result = batch.next();
System.out.println(result.getDouble(“value”));
}
}
10© Cloudera, Inc. All rights reserved.
Kudu “NoSQL” APIs - Predicates
KuduScanner scanner = client.newScannerBuilder(table)
.addPredicate(KuduPredicate.newComparisonPredicate(
table.getSchema().getColumn(“timestamp”),
ComparisonOp.GREATER,
System.currentTimeMillis() / 1000 + 60))
.build();
Note: Kudu can evaluate simple predicates, but no aggregations, complex
expressions, UDFs, etc.
11© Cloudera, Inc. All rights reserved.
Tables and tablets
• Each table is horizontally partitioned into tablets
• Range or hash partitioning
• PRIMARY KEY (host, metric, timestamp) DISTRIBUTE BY
HASH(timestamp) INTO 100 BUCKETS
• Translation: bucketNumber = hashCode(row[‘timestamp’]) % 100
• Each tablet has N replicas (3 or 5), kept consistent with Raft consensus
• Tablet servers host tablets on local disk drives
12© Cloudera, Inc. All rights reserved.
Fault tolerance
• Operations replicated using Raft consensus
• Strict quorum algorithm. See Raft paper for details
• Transient failures:
• Follower failure: Leader can still achieve majority
• Leader failure: automatic leader election (~5 seconds)
• Restart dead TS within 5 min and it will rejoin transparently
• Permanent failures
• After 5 minutes, automatically creates a new follower replica and copies data
• N replicas can tolerate up to (N-1)/2 failures
13© Cloudera, Inc. All rights reserved.
Metadata
• Replicated master
• Acts as a tablet directory
• Acts as a catalog (which tables exist, etc)
• Acts as a load balancer (tracks TS liveness, re-replicates under-replicated
tablets)
• Caches all metadata in RAM for high performance
• Client configured with master addresses
• Asks master for tablet locations as needed and caches them
14© Cloudera, Inc. All rights reserved.
Integrations
Kudu is designed for integrating with higher-level compute frameworks
Integrations exist for:
• Spark
• Impala
• MapReduce
• Flume
• Drill
15© Cloudera, Inc. All rights reserved.
What Kudu brings to Spark
• Parquet-like scan performance with 0-delay inserts and updates
• Push down predicate filters for fast & efficient scans
• Primary key indexing for fast point lookups (compared to Parquet)
16© Cloudera, Inc. All rights reserved.
Spark DataSource
17© Cloudera, Inc. All rights reserved.
Spark DataFrame/DataSource integration
// spark-shell --packages org.apache.kudu:kudu-spark_2.10:1.0.0
// Import kudu datasource
import org.kududb.spark.kudu._
val kuduDataFrame = sqlContext.read.options(
Map("kudu.master" -> "master1,master2,master3",
"kudu.table" -> "my_table_name")).kudu
// Then query using Spark data frame API
kuduDataFrame.select("id").filter("id" >= 5).show()
// (prints the selection to the console)
// Or register kuduDataFrame as a table and use Spark SQL
kuduDataFrame.registerTempTable("my_table")
sqlContext.sql("select id from my_table where id >= 5").show()
// (prints the sql results to the console)
18© Cloudera, Inc. All rights reserved.
Quick demo
19© Cloudera, Inc. All rights reserved.
Writing from Spark
// Use KuduContext to create, delete, or write to Kudu tables
val kuduContext = new KuduContext("kudu.master:7051")
// Create a new Kudu table from a dataframe schema
// NB: No rows from the dataframe are inserted into the table
kuduContext.createTable("test_table", df.schema, Seq("key"),
new CreateTableOptions().setNumReplicas(1))
// Insert, delete, upsert, or update data
kuduContext.insertRows(df, "test_table")
kuduContext.deleteRows(sqlContext.sql("select id from kudu_table where id >= 5"),
"kudu_table")
kuduContext.upsertRows(df, "test_table")
kuduContext.updateRows(df.select(“id”, $”count” + 1, "test_table")
20© Cloudera, Inc. All rights reserved.
Spark DataSource optimizations
Column projection and predicate pushdown
- Only read the referenced columns
- Convert ‘WHERE’ clauses into Kudu predicates
- Kudu predicates automatically convert to primary key scans, etc
scala> sqlContext.sql("select avg(value) from metrics where host =
'e1103.halxg.cloudera.com'").explain
== Physical Plan ==
TungstenAggregate(key=[], functions=[(avg(value#3),mode=Final,isDistinct=false)], output=[_c0#94])
+- TungstenExchange SinglePartition, None
+- TungstenAggregate(key=[], functions=[(avg(value#3),mode=Partial,isDistinct=false)],
output=[sum#98,count#99L])
+- Project [value#3]
+- Scan org.apache.kudu.spark.kudu.KuduRelation@e13cc49[value#3]
PushedFilters: [EqualTo(host,e1103.halxg.cloudera.com)]
21© Cloudera, Inc. All rights reserved.
Spark DataSource optimizations
Partition pruning
scala> df.where("host like 'foo%'").rdd.partitions.length
res1: Int = 20
scala> df.where("host = 'foo'").rdd.partitions.length
res2: Int = 1
22© Cloudera, Inc. All rights reserved.
Use cases
23© Cloudera, Inc. All rights reserved.
Kudu use cases
Kudu is best for use cases requiring:
• Simultaneous combination of sequential and random reads and writes
• Minimal to zero data latencies
Time series
• Examples: Streaming market data; fraud detection & prevention; network monitoring
• Workload: Inserts, updates, scans, lookups
Online reporting / data warehousing
• Example: Operational Data Store (ODS)
• Workload: Inserts, updates, scans, lookups
24© Cloudera, Inc. All rights reserved.
Xiaomi use case
• World’s 4th
largest smart-phone maker (most popular in China)
• Gather important RPC tracing events from mobile app and backend service.
• Service monitoring & troubleshooting tool.
High write throughput
• >20 Billion records/day and growing
Query latest data and quick response
• Identify and resolve issues quickly
Can search for individual records
• Easy for troubleshooting
25© Cloudera, Inc. All rights reserved.
Xiaomi big data analytics pipeline
Before Kudu
Long pipeline
• High data latency
(approx 1 hour – 1 day)
• Data conversion pains
No ordering
• Log arrival (storage) order is
not exactly logical order
• Must read 2 – 3 days of data
to get all of the data points
for a single day
26© Cloudera, Inc. All rights reserved.
Xiaomi big data analytics pipeline
Simplified with Kafka and Kudu
ETL pipeline
• 0 – 10s data latency
• Apps that need to avoid
backpressure or need ETL
Direct pipeline (no latency)
• Apps that don’t require ETL or
backpressure handling
OLAP scan
Side table lookup
Result store
27© Cloudera, Inc. All rights reserved.
Real-time analytics in Hadoop with Kudu
Improvements:
• One system to operate
• No cron jobs or background
processes
• Handle late arrivals or data
corrections with ease
• New data available
immediately for analytics or
operations
Historical and Real-time
Data
Incoming data
(e.g. Kafka)
Reporting
Request
Storage in Kudu
28© Cloudera, Inc. All rights reserved.
Kudu+Impala vs MPP DWH
Commonalities
✓ Fast analytic queries via SQL, including most commonly used modern features
✓ Ability to insert, update, and delete data
Differences
✓ Faster streaming inserts
✓ Improved Hadoop integration
• JOIN between HDFS + Kudu tables, run on same cluster
• Spark, Flume, other integrations
✗ Slower batch inserts
✗ No transactional data loading, multi-row transactions, or indexing
29© Cloudera, Inc. All rights reserved.
Columnar storage
{25059873,
22309487,
23059861,
23010982}
Tweet_id
{newsycbot,
RideImpala,
fastly,
llvmorg}
User_name
{1442865158,
1442828307,
1442865156,
1442865155}
Created_at
{Visual exp…,
Introducing ..,
Missing July…,
LLVM 3.7….}
text
30© Cloudera, Inc. All rights reserved.
Columnar storage
{25059873,
22309487,
23059861,
23010982}
Tweet_id
{newsycbot,
RideImpala,
fastly,
llvmorg}
User_name
{1442865158,
1442828307,
1442865156,
1442865155}
Created_at
{Visual exp…,
Introducing ..,
Missing July…,
LLVM 3.7….}
text
SELECT COUNT(*) FROM tweets WHERE user_name = ‘newsycbot’;
Only read 1 column
1GB 2GB 1GB 200GB
31© Cloudera, Inc. All rights reserved.
Columnar compression
• Many columns can compress to a few bits per row!
• Especially:
• Timestamps
• Time series values
• Low-cardinality strings
• Massive space savings and throughput increase!
32© Cloudera, Inc. All rights reserved.
Kudu Roadmap
33© Cloudera, Inc. All rights reserved.
Open Source “Roadmaps”?
- Kudu is an open source ASF project
- ASF governance means there is no guaranteed roadmap
- Whatever people contribute is the roadmap!
- But I can speak to what my team will be focusing on
- Disclaimer: quality-first mantra = fuzzy timeline commitments
34© Cloudera, Inc. All rights reserved.
Security Roadmap
1) Kerberos authentication
a) Client-server mutual authentication
a) Server-server mutual authentication
b) Execution framework-server authentication (delegation tokens)
2) Extra-coarse-grained authorization
a) Likely a cluster-wide “allowed user list”
3) Group/role mapping
a) LDAP/Unix/etc
4) Data exposure hardening
a) e.g. ensure that web UIs dont leak data
5) Fine-grained authorization
a) Table/database/column level
35© Cloudera, Inc. All rights reserved.
Operability
1) Stability
a) Continued stress testing, fault injection, etc
b) Faster and safer recovery after failures
2) Recovery tools
a) Repair from minority (eg if two hosts explode simultaneously)
b) Replace from empty (eg if three hosts explode simultaneously)
c) Repair file system state after power outage
3) Easier problem diagnosis
a) Client “timeout” errors
b) Easier performance issue diagnosis
36© Cloudera, Inc. All rights reserved.
Performance and scale
- Read performance
- Dynamic predicates (aka runtime filters)
- Spark statistics
- Additional filter pushdown (e.g. “IN (...)”, “LIKE”)
- I/O scheduling from spinning disks
- Write performance
- Improved bulk load capability
- Scalability
- Users planning to run 400 node clusters
- Rack-aware placement
37© Cloudera, Inc. All rights reserved.
Client improvements roadmap
- Python
- Full feature parity with C++ and Java
- Even more pythonic
- Integrations: Pandas, PySpark
- All clients:
- More API documentation, tutorials, examples
- Better error messages/exceptions
- Full support for snapshot consistency level
38© Cloudera, Inc. All rights reserved.
Performance
- Significant improvements to compaction throughput
- Default configurations tuned for much less write amplification
- Reduced lock contention on RPC system, block cache
- 2-3x improvement for selective filters on dictionary-encoded columns
- Other speedups:
- Startup time 2-3x better (more work coming)
- First scan following restart ~2x faster
- More compact and compressed internal index storage
39© Cloudera, Inc. All rights reserved.
Performance (YCSB)
Single node micro-benchmark, 500M record insert, 16 client threads, each record ~110 bytes
Runs Load, followed by ‘C’ (10min), followed by ‘A’ (10min)
175Kop/s 422Kop/s 680 op/s
12K op/s
6K op/s 18K op/s
40© Cloudera, Inc. All rights reserved.
TPC-H (analytics benchmark)
• 75 server cluster
• 12 (spinning) disks each, enough RAM to fit dataset
• TPC-H Scale Factor 100 (100GB)
• Example query:
• SELECT n_name, sum(l_extendedprice * (1 - l_discount)) as revenue FROM customer, orders,
lineitem, supplier, nation, region WHERE c_custkey = o_custkey AND l_orderkey = o_orderkey
AND l_suppkey = s_suppkey AND c_nationkey = s_nationkey AND s_nationkey = n_nationkey AND
n_regionkey = r_regionkey AND r_name = 'ASIA' AND o_orderdate >= date '1994-01-01' AND
o_orderdate < '1995-01-01’ GROUP BY n_name ORDER BY revenue desc;
41© Cloudera, Inc. All rights reserved.
• Kudu outperforms Parquet by 31% (geometric mean) for RAM-resident data
42© Cloudera, Inc. All rights reserved.
Versus other NoSQL storage
• Apache Phoenix: OLTP SQL engine built on HBase
• 10 node cluster (9 worker, 1 master)
• TPC-H LINEITEM table only (6B rows)
43© Cloudera, Inc. All rights reserved.
Joining the growing community
44© Cloudera, Inc. All rights reserved.
Apache Kudu Community
45© Cloudera, Inc. All rights reserved.
Getting started as a user
• On the web: kudu.apache.org
• User mailing list: user@kudu.apache.org
• Public Slack chat channel (see web site for the link)
• Quickstart VM
• Easiest way to get started
• Impala and Kudu in an easy-to-install VM
• CSD and Parcels
• For installation on a Cloudera Manager-managed cluster
46© Cloudera, Inc. All rights reserved.
Getting started as a developer
• Source code: github.com/apache/kudu - all commits go here first
• Code reviews: gerrit.cloudera.org - all code reviews are public
• Developer mailing list: dev@kudu.apache.org
• Public JIRA: issues.apache.org/jira/browse/KUDU - includes bug history since 2013
Contributions are welcome and strongly encouraged!
47© Cloudera, Inc. All rights reserved.
kudu.apache.org
@mike_percy | @ApacheKudu

More Related Content

PDF
A Thorough Comparison of Delta Lake, Iceberg and Hudi
PDF
Building Real-Time BI Systems with Kafka, Spark, and Kudu: Spark Summit East ...
PPTX
Evening out the uneven: dealing with skew in Flink
PPTX
RocksDB compaction
PDF
Producer Performance Tuning for Apache Kafka
PPTX
Snowflake Architecture.pptx
PDF
Streaming all over the world Real life use cases with Kafka Streams
PDF
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka
A Thorough Comparison of Delta Lake, Iceberg and Hudi
Building Real-Time BI Systems with Kafka, Spark, and Kudu: Spark Summit East ...
Evening out the uneven: dealing with skew in Flink
RocksDB compaction
Producer Performance Tuning for Apache Kafka
Snowflake Architecture.pptx
Streaming all over the world Real life use cases with Kafka Streams
Real-Life Use Cases & Architectures for Event Streaming with Apache Kafka

What's hot (20)

PDF
Scaling your Data Pipelines with Apache Spark on Kubernetes
PPTX
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
PPT
Oracle GoldenGate
PDF
Kafka Streams State Stores Being Persistent
PPTX
The Impala Cookbook
PDF
Introducing Change Data Capture with Debezium
PDF
Optimizing Hive Queries
PPTX
HBase and HDFS: Understanding FileSystem Usage in HBase
PPTX
Kafka 101
PDF
What's New in Apache Hive
PDF
PDF
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
PDF
Data Ingest Self Service and Management using Nifi and Kafka
PPTX
Apache Ignite vs Alluxio: Memory Speed Big Data Analytics
PDF
Kappa vs Lambda Architectures and Technology Comparison
PDF
Kafka 101 and Developer Best Practices
PPTX
Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su...
PPTX
Where is my bottleneck? Performance troubleshooting in Flink
PDF
Fundamentals of Apache Kafka
PPT
Apache Spark Introduction and Resilient Distributed Dataset basics and deep dive
Scaling your Data Pipelines with Apache Spark on Kubernetes
Kafka Tutorial - Introduction to Apache Kafka (Part 1)
Oracle GoldenGate
Kafka Streams State Stores Being Persistent
The Impala Cookbook
Introducing Change Data Capture with Debezium
Optimizing Hive Queries
HBase and HDFS: Understanding FileSystem Usage in HBase
Kafka 101
What's New in Apache Hive
Hadoop Interview Questions And Answers Part-2 | Big Data Interview Questions ...
Data Ingest Self Service and Management using Nifi and Kafka
Apache Ignite vs Alluxio: Memory Speed Big Data Analytics
Kappa vs Lambda Architectures and Technology Comparison
Kafka 101 and Developer Best Practices
Deletes Without Tombstones or TTLs (Eric Stevens, ProtectWise) | Cassandra Su...
Where is my bottleneck? Performance troubleshooting in Flink
Fundamentals of Apache Kafka
Apache Spark Introduction and Resilient Distributed Dataset basics and deep dive
Ad

Viewers also liked (20)

PDF
Spark Summit EU talk by Berni Schiefer
PDF
Spark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
PPTX
Producing Spark on YARN for ETL
PPTX
PDF
Spark Summit EU talk by Erwin Datema and Roeland van Ham
PDF
Microservice-based software architecture
PDF
Aioug vizag oracle12c_new_features
PDF
COUG_AAbate_Oracle_Database_12c_New_Features
PDF
Oracle12 - The Top12 Features by NAYA Technologies
PDF
Spark Summit EU talk by Jorg Schad
PPTX
Introduce to Spark sql 1.3.0
PPTX
Spark etl
PPTX
SPARQL and Linked Data Benchmarking
PPTX
AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...
PPTX
Data Science at Scale: Using Apache Spark for Data Science at Bitly
PPTX
Spark meetup v2.0.5
PDF
Pandas, Data Wrangling & Data Science
PDF
Data Science with Spark
PPTX
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Spark Summit EU talk by Berni Schiefer
Spark ETL Techniques - Creating An Optimal Fantasy Baseball Roster
Producing Spark on YARN for ETL
Spark Summit EU talk by Erwin Datema and Roeland van Ham
Microservice-based software architecture
Aioug vizag oracle12c_new_features
COUG_AAbate_Oracle_Database_12c_New_Features
Oracle12 - The Top12 Features by NAYA Technologies
Spark Summit EU talk by Jorg Schad
Introduce to Spark sql 1.3.0
Spark etl
SPARQL and Linked Data Benchmarking
AMIS Oracle OpenWorld 2015 Review – part 3- PaaS Database, Integration, Ident...
Data Science at Scale: Using Apache Spark for Data Science at Bitly
Spark meetup v2.0.5
Pandas, Data Wrangling & Data Science
Data Science with Spark
Building a Unified Data Pipline in Spark / Apache Sparkを用いたBig Dataパイプラインの統一
Ad

Similar to Spark Summit EU talk by Mike Percy (20)

PPTX
Intro to Apache Kudu (short) - Big Data Application Meetup
PPTX
Apache Kudu (Incubating): New Hadoop Storage for Fast Analytics on Fast Data ...
PDF
Big Data Day LA 2016/ NoSQL track - Apache Kudu: Fast Analytics on Fast Data,...
PPTX
Introduction to Kudu - StampedeCon 2016
PPTX
Using Kafka and Kudu for fast, low-latency SQL analytics on streaming data
PPTX
Introducing Apache Kudu (Incubating) - Montreal HUG May 2016
PDF
DatEngConf SF16 - Apache Kudu: Fast Analytics on Fast Data
PDF
Introducing Kudu, Big Data Warehousing Meetup
PPTX
Introducing Kudu
PPTX
SFHUG Kudu Talk
PDF
Kudu: Fast Analytics on Fast Data
PPTX
Introduction to Apache Kudu
PPTX
Enabling the Active Data Warehouse with Apache Kudu
PDF
Big Data Day LA 2016/ Big Data Track - How To Use Impala and Kudu To Optimize...
PDF
Kudu: Resolving Transactional and Analytic Trade-offs in Hadoop
PPTX
Introduction to Kudu: Hadoop Storage for Fast Analytics on Fast Data - Rüdige...
PPTX
Apache Kudu: Technical Deep Dive


PDF
Apache Kudu Fast Analytics on Fast Data (Hadoop / Spark Conference Japan 2016...
PDF
Kudu - Fast Analytics on Fast Data
PPTX
Part 2: Apache Kudu: Extending the Capabilities of Operational and Analytic D...
Intro to Apache Kudu (short) - Big Data Application Meetup
Apache Kudu (Incubating): New Hadoop Storage for Fast Analytics on Fast Data ...
Big Data Day LA 2016/ NoSQL track - Apache Kudu: Fast Analytics on Fast Data,...
Introduction to Kudu - StampedeCon 2016
Using Kafka and Kudu for fast, low-latency SQL analytics on streaming data
Introducing Apache Kudu (Incubating) - Montreal HUG May 2016
DatEngConf SF16 - Apache Kudu: Fast Analytics on Fast Data
Introducing Kudu, Big Data Warehousing Meetup
Introducing Kudu
SFHUG Kudu Talk
Kudu: Fast Analytics on Fast Data
Introduction to Apache Kudu
Enabling the Active Data Warehouse with Apache Kudu
Big Data Day LA 2016/ Big Data Track - How To Use Impala and Kudu To Optimize...
Kudu: Resolving Transactional and Analytic Trade-offs in Hadoop
Introduction to Kudu: Hadoop Storage for Fast Analytics on Fast Data - Rüdige...
Apache Kudu: Technical Deep Dive


Apache Kudu Fast Analytics on Fast Data (Hadoop / Spark Conference Japan 2016...
Kudu - Fast Analytics on Fast Data
Part 2: Apache Kudu: Extending the Capabilities of Operational and Analytic D...

More from Spark Summit (20)

PDF
FPGA-Based Acceleration Architecture for Spark SQL Qi Xie and Quanfu Wang
PDF
VEGAS: The Missing Matplotlib for Scala/Apache Spark with DB Tsai and Roger M...
PDF
Apache Spark Structured Streaming Helps Smart Manufacturing with Xiaochang Wu
PDF
Improving Traffic Prediction Using Weather Data with Ramya Raghavendra
PDF
A Tale of Two Graph Frameworks on Spark: GraphFrames and Tinkerpop OLAP Artem...
PDF
No More Cumbersomeness: Automatic Predictive Modeling on Apache Spark Marcin ...
PDF
Apache Spark and Tensorflow as a Service with Jim Dowling
PDF
Apache Spark and Tensorflow as a Service with Jim Dowling
PDF
MMLSpark: Lessons from Building a SparkML-Compatible Machine Learning Library...
PDF
Next CERN Accelerator Logging Service with Jakub Wozniak
PDF
Powering a Startup with Apache Spark with Kevin Kim
PDF
Improving Traffic Prediction Using Weather Datawith Ramya Raghavendra
PDF
Hiding Apache Spark Complexity for Fast Prototyping of Big Data Applications—...
PDF
How Nielsen Utilized Databricks for Large-Scale Research and Development with...
PDF
Spline: Apache Spark Lineage not Only for the Banking Industry with Marek Nov...
PDF
Goal Based Data Production with Sim Simeonov
PDF
Preventing Revenue Leakage and Monitoring Distributed Systems with Machine Le...
PDF
Getting Ready to Use Redis with Apache Spark with Dvir Volk
PDF
Deduplication and Author-Disambiguation of Streaming Records via Supervised M...
PDF
MatFast: In-Memory Distributed Matrix Computation Processing and Optimization...
FPGA-Based Acceleration Architecture for Spark SQL Qi Xie and Quanfu Wang
VEGAS: The Missing Matplotlib for Scala/Apache Spark with DB Tsai and Roger M...
Apache Spark Structured Streaming Helps Smart Manufacturing with Xiaochang Wu
Improving Traffic Prediction Using Weather Data with Ramya Raghavendra
A Tale of Two Graph Frameworks on Spark: GraphFrames and Tinkerpop OLAP Artem...
No More Cumbersomeness: Automatic Predictive Modeling on Apache Spark Marcin ...
Apache Spark and Tensorflow as a Service with Jim Dowling
Apache Spark and Tensorflow as a Service with Jim Dowling
MMLSpark: Lessons from Building a SparkML-Compatible Machine Learning Library...
Next CERN Accelerator Logging Service with Jakub Wozniak
Powering a Startup with Apache Spark with Kevin Kim
Improving Traffic Prediction Using Weather Datawith Ramya Raghavendra
Hiding Apache Spark Complexity for Fast Prototyping of Big Data Applications—...
How Nielsen Utilized Databricks for Large-Scale Research and Development with...
Spline: Apache Spark Lineage not Only for the Banking Industry with Marek Nov...
Goal Based Data Production with Sim Simeonov
Preventing Revenue Leakage and Monitoring Distributed Systems with Machine Le...
Getting Ready to Use Redis with Apache Spark with Dvir Volk
Deduplication and Author-Disambiguation of Streaming Records via Supervised M...
MatFast: In-Memory Distributed Matrix Computation Processing and Optimization...

Recently uploaded (20)

PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Moving the Public Sector (Government) to a Digital Adoption
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPT
Quality review (1)_presentation of this 21
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
1_Introduction to advance data techniques.pptx
PDF
Foundation of Data Science unit number two notes
PPTX
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PPTX
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
PDF
Lecture1 pattern recognition............
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Moving the Public Sector (Government) to a Digital Adoption
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
IB Computer Science - Internal Assessment.pptx
oil_refinery_comprehensive_20250804084928 (1).pptx
Quality review (1)_presentation of this 21
Business Ppt On Nestle.pptx huunnnhhgfvu
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
05. PRACTICAL GUIDE TO MICROSOFT EXCEL.pptx
Fluorescence-microscope_Botany_detailed content
1_Introduction to advance data techniques.pptx
Foundation of Data Science unit number two notes
advance b rammar.pptxfdgdfgdfsgdfgsdgfdfgdfgsdfgdfgdfg
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
CEE 2 REPORT G7.pptxbdbshjdgsgjgsjfiuhsd
Lecture1 pattern recognition............
Reliability_Chapter_ presentation 1221.5784
Introduction-to-Cloud-ComputingFinal.pptx

Spark Summit EU talk by Mike Percy

  • 1. 1© Cloudera, Inc. All rights reserved. Apache Kudu & Apache Spark SQL for Fast Analytics on Fast Data Mike Percy Software Engineer at Cloudera Apache Kudu PMC member
  • 2. 2© Cloudera, Inc. All rights reserved. Kudu Overview
  • 3. 3© Cloudera, Inc. All rights reserved. HDFS Fast Scans, Analytics and Processing of Static Data Fast On-Line Updates & Data Serving Arbitrary Storage (Active Archive) Fast Analytics (on fast-changing or frequently-updated data) Traditional Hadoop Storage Leaves a Gap Use cases that fall between HDFS and HBase were difficult to manage Unchanging Fast Changing Frequent Updates HBase Append-Only Real-Time Complex Hybrid Architectures Analytic Gap Pace of Analysis PaceofData
  • 4. 4© Cloudera, Inc. All rights reserved. HDFS Fast Scans, Analytics and Processing of Static Data Fast On-Line Updates & Data Serving Arbitrary Storage (Active Archive) Fast Analytics (on fast-changing or frequently-updated data) Kudu: Fast Analytics on Fast-Changing Data New storage engine enables new Hadoop use cases Unchanging Fast Changing Frequent Updates HBase Append-Only Real-Time Kudu Kudu fills the Gap Modern analytic applications often require complex data flow & difficult integration work to move data between HBase & HDFS Analytic Gap Pace of Analysis PaceofData
  • 5. 5© Cloudera, Inc. All rights reserved. Apache Kudu: Scalable and fast tabular storage Tabular • Represents data in structured tables like a relational database • Strict schema, finite column count, no BLOBs • Individual record-level access to 100+ billion row tables Scalable • Tested up to 275 nodes (~3PB cluster) • Designed to scale to 1000s of nodes and tens of PBs Fast • Millions of read/write operations per second across cluster • Multiple GB/second read throughput per node
  • 6. 6© Cloudera, Inc. All rights reserved. Storing records in Kudu tables • A Kudu table has a SQL-like schema • And a finite number of columns (unlike HBase/Cassandra) • Types: BOOL, INT8, INT16, INT32, INT64, FLOAT, DOUBLE, STRING, BINARY, TIMESTAMP • Some subset of columns makes up a possibly-composite primary key • Fast ALTER TABLE • Java, Python, and C++ NoSQL-style APIs • Insert(), Update(), Delete(), Scan() • SQL via integrations with Spark and Impala • Community work in progress / experimental: Drill, Hive
  • 7. 7© Cloudera, Inc. All rights reserved. Kudu SQL access - Kudu itself is just storage and native “NoSQL” APIs - SQL access via integrations with Spark, Impala, etc.
  • 8. 8© Cloudera, Inc. All rights reserved. Kudu “NoSQL” APIs - Writes KuduTable table = client.openTable(“my_table”); KuduSession session = client.newSession(); Insert ins = table.newInsert(); ins.getRow().addString(“host”, “foo.example.com”); ins.getRow().addString(“metric”, “load-avg.1sec”); ins.getRow().addDouble(“value”, 0.05); session.apply(ins); session.flush();
  • 9. 9© Cloudera, Inc. All rights reserved. Kudu “NoSQL” APIs - Reads KuduScanner scanner = client.newScannerBuilder(table) .setProjectedColumnNames(List.of(“value”)) .build(); while (scanner.hasMoreRows()) { RowResultIterator batch = scanner.nextRows(); while (batch.hasNext()) { RowResult result = batch.next(); System.out.println(result.getDouble(“value”)); } }
  • 10. 10© Cloudera, Inc. All rights reserved. Kudu “NoSQL” APIs - Predicates KuduScanner scanner = client.newScannerBuilder(table) .addPredicate(KuduPredicate.newComparisonPredicate( table.getSchema().getColumn(“timestamp”), ComparisonOp.GREATER, System.currentTimeMillis() / 1000 + 60)) .build(); Note: Kudu can evaluate simple predicates, but no aggregations, complex expressions, UDFs, etc.
  • 11. 11© Cloudera, Inc. All rights reserved. Tables and tablets • Each table is horizontally partitioned into tablets • Range or hash partitioning • PRIMARY KEY (host, metric, timestamp) DISTRIBUTE BY HASH(timestamp) INTO 100 BUCKETS • Translation: bucketNumber = hashCode(row[‘timestamp’]) % 100 • Each tablet has N replicas (3 or 5), kept consistent with Raft consensus • Tablet servers host tablets on local disk drives
  • 12. 12© Cloudera, Inc. All rights reserved. Fault tolerance • Operations replicated using Raft consensus • Strict quorum algorithm. See Raft paper for details • Transient failures: • Follower failure: Leader can still achieve majority • Leader failure: automatic leader election (~5 seconds) • Restart dead TS within 5 min and it will rejoin transparently • Permanent failures • After 5 minutes, automatically creates a new follower replica and copies data • N replicas can tolerate up to (N-1)/2 failures
  • 13. 13© Cloudera, Inc. All rights reserved. Metadata • Replicated master • Acts as a tablet directory • Acts as a catalog (which tables exist, etc) • Acts as a load balancer (tracks TS liveness, re-replicates under-replicated tablets) • Caches all metadata in RAM for high performance • Client configured with master addresses • Asks master for tablet locations as needed and caches them
  • 14. 14© Cloudera, Inc. All rights reserved. Integrations Kudu is designed for integrating with higher-level compute frameworks Integrations exist for: • Spark • Impala • MapReduce • Flume • Drill
  • 15. 15© Cloudera, Inc. All rights reserved. What Kudu brings to Spark • Parquet-like scan performance with 0-delay inserts and updates • Push down predicate filters for fast & efficient scans • Primary key indexing for fast point lookups (compared to Parquet)
  • 16. 16© Cloudera, Inc. All rights reserved. Spark DataSource
  • 17. 17© Cloudera, Inc. All rights reserved. Spark DataFrame/DataSource integration // spark-shell --packages org.apache.kudu:kudu-spark_2.10:1.0.0 // Import kudu datasource import org.kududb.spark.kudu._ val kuduDataFrame = sqlContext.read.options( Map("kudu.master" -> "master1,master2,master3", "kudu.table" -> "my_table_name")).kudu // Then query using Spark data frame API kuduDataFrame.select("id").filter("id" >= 5).show() // (prints the selection to the console) // Or register kuduDataFrame as a table and use Spark SQL kuduDataFrame.registerTempTable("my_table") sqlContext.sql("select id from my_table where id >= 5").show() // (prints the sql results to the console)
  • 18. 18© Cloudera, Inc. All rights reserved. Quick demo
  • 19. 19© Cloudera, Inc. All rights reserved. Writing from Spark // Use KuduContext to create, delete, or write to Kudu tables val kuduContext = new KuduContext("kudu.master:7051") // Create a new Kudu table from a dataframe schema // NB: No rows from the dataframe are inserted into the table kuduContext.createTable("test_table", df.schema, Seq("key"), new CreateTableOptions().setNumReplicas(1)) // Insert, delete, upsert, or update data kuduContext.insertRows(df, "test_table") kuduContext.deleteRows(sqlContext.sql("select id from kudu_table where id >= 5"), "kudu_table") kuduContext.upsertRows(df, "test_table") kuduContext.updateRows(df.select(“id”, $”count” + 1, "test_table")
  • 20. 20© Cloudera, Inc. All rights reserved. Spark DataSource optimizations Column projection and predicate pushdown - Only read the referenced columns - Convert ‘WHERE’ clauses into Kudu predicates - Kudu predicates automatically convert to primary key scans, etc scala> sqlContext.sql("select avg(value) from metrics where host = 'e1103.halxg.cloudera.com'").explain == Physical Plan == TungstenAggregate(key=[], functions=[(avg(value#3),mode=Final,isDistinct=false)], output=[_c0#94]) +- TungstenExchange SinglePartition, None +- TungstenAggregate(key=[], functions=[(avg(value#3),mode=Partial,isDistinct=false)], output=[sum#98,count#99L]) +- Project [value#3] +- Scan org.apache.kudu.spark.kudu.KuduRelation@e13cc49[value#3] PushedFilters: [EqualTo(host,e1103.halxg.cloudera.com)]
  • 21. 21© Cloudera, Inc. All rights reserved. Spark DataSource optimizations Partition pruning scala> df.where("host like 'foo%'").rdd.partitions.length res1: Int = 20 scala> df.where("host = 'foo'").rdd.partitions.length res2: Int = 1
  • 22. 22© Cloudera, Inc. All rights reserved. Use cases
  • 23. 23© Cloudera, Inc. All rights reserved. Kudu use cases Kudu is best for use cases requiring: • Simultaneous combination of sequential and random reads and writes • Minimal to zero data latencies Time series • Examples: Streaming market data; fraud detection & prevention; network monitoring • Workload: Inserts, updates, scans, lookups Online reporting / data warehousing • Example: Operational Data Store (ODS) • Workload: Inserts, updates, scans, lookups
  • 24. 24© Cloudera, Inc. All rights reserved. Xiaomi use case • World’s 4th largest smart-phone maker (most popular in China) • Gather important RPC tracing events from mobile app and backend service. • Service monitoring & troubleshooting tool. High write throughput • >20 Billion records/day and growing Query latest data and quick response • Identify and resolve issues quickly Can search for individual records • Easy for troubleshooting
  • 25. 25© Cloudera, Inc. All rights reserved. Xiaomi big data analytics pipeline Before Kudu Long pipeline • High data latency (approx 1 hour – 1 day) • Data conversion pains No ordering • Log arrival (storage) order is not exactly logical order • Must read 2 – 3 days of data to get all of the data points for a single day
  • 26. 26© Cloudera, Inc. All rights reserved. Xiaomi big data analytics pipeline Simplified with Kafka and Kudu ETL pipeline • 0 – 10s data latency • Apps that need to avoid backpressure or need ETL Direct pipeline (no latency) • Apps that don’t require ETL or backpressure handling OLAP scan Side table lookup Result store
  • 27. 27© Cloudera, Inc. All rights reserved. Real-time analytics in Hadoop with Kudu Improvements: • One system to operate • No cron jobs or background processes • Handle late arrivals or data corrections with ease • New data available immediately for analytics or operations Historical and Real-time Data Incoming data (e.g. Kafka) Reporting Request Storage in Kudu
  • 28. 28© Cloudera, Inc. All rights reserved. Kudu+Impala vs MPP DWH Commonalities ✓ Fast analytic queries via SQL, including most commonly used modern features ✓ Ability to insert, update, and delete data Differences ✓ Faster streaming inserts ✓ Improved Hadoop integration • JOIN between HDFS + Kudu tables, run on same cluster • Spark, Flume, other integrations ✗ Slower batch inserts ✗ No transactional data loading, multi-row transactions, or indexing
  • 29. 29© Cloudera, Inc. All rights reserved. Columnar storage {25059873, 22309487, 23059861, 23010982} Tweet_id {newsycbot, RideImpala, fastly, llvmorg} User_name {1442865158, 1442828307, 1442865156, 1442865155} Created_at {Visual exp…, Introducing .., Missing July…, LLVM 3.7….} text
  • 30. 30© Cloudera, Inc. All rights reserved. Columnar storage {25059873, 22309487, 23059861, 23010982} Tweet_id {newsycbot, RideImpala, fastly, llvmorg} User_name {1442865158, 1442828307, 1442865156, 1442865155} Created_at {Visual exp…, Introducing .., Missing July…, LLVM 3.7….} text SELECT COUNT(*) FROM tweets WHERE user_name = ‘newsycbot’; Only read 1 column 1GB 2GB 1GB 200GB
  • 31. 31© Cloudera, Inc. All rights reserved. Columnar compression • Many columns can compress to a few bits per row! • Especially: • Timestamps • Time series values • Low-cardinality strings • Massive space savings and throughput increase!
  • 32. 32© Cloudera, Inc. All rights reserved. Kudu Roadmap
  • 33. 33© Cloudera, Inc. All rights reserved. Open Source “Roadmaps”? - Kudu is an open source ASF project - ASF governance means there is no guaranteed roadmap - Whatever people contribute is the roadmap! - But I can speak to what my team will be focusing on - Disclaimer: quality-first mantra = fuzzy timeline commitments
  • 34. 34© Cloudera, Inc. All rights reserved. Security Roadmap 1) Kerberos authentication a) Client-server mutual authentication a) Server-server mutual authentication b) Execution framework-server authentication (delegation tokens) 2) Extra-coarse-grained authorization a) Likely a cluster-wide “allowed user list” 3) Group/role mapping a) LDAP/Unix/etc 4) Data exposure hardening a) e.g. ensure that web UIs dont leak data 5) Fine-grained authorization a) Table/database/column level
  • 35. 35© Cloudera, Inc. All rights reserved. Operability 1) Stability a) Continued stress testing, fault injection, etc b) Faster and safer recovery after failures 2) Recovery tools a) Repair from minority (eg if two hosts explode simultaneously) b) Replace from empty (eg if three hosts explode simultaneously) c) Repair file system state after power outage 3) Easier problem diagnosis a) Client “timeout” errors b) Easier performance issue diagnosis
  • 36. 36© Cloudera, Inc. All rights reserved. Performance and scale - Read performance - Dynamic predicates (aka runtime filters) - Spark statistics - Additional filter pushdown (e.g. “IN (...)”, “LIKE”) - I/O scheduling from spinning disks - Write performance - Improved bulk load capability - Scalability - Users planning to run 400 node clusters - Rack-aware placement
  • 37. 37© Cloudera, Inc. All rights reserved. Client improvements roadmap - Python - Full feature parity with C++ and Java - Even more pythonic - Integrations: Pandas, PySpark - All clients: - More API documentation, tutorials, examples - Better error messages/exceptions - Full support for snapshot consistency level
  • 38. 38© Cloudera, Inc. All rights reserved. Performance - Significant improvements to compaction throughput - Default configurations tuned for much less write amplification - Reduced lock contention on RPC system, block cache - 2-3x improvement for selective filters on dictionary-encoded columns - Other speedups: - Startup time 2-3x better (more work coming) - First scan following restart ~2x faster - More compact and compressed internal index storage
  • 39. 39© Cloudera, Inc. All rights reserved. Performance (YCSB) Single node micro-benchmark, 500M record insert, 16 client threads, each record ~110 bytes Runs Load, followed by ‘C’ (10min), followed by ‘A’ (10min) 175Kop/s 422Kop/s 680 op/s 12K op/s 6K op/s 18K op/s
  • 40. 40© Cloudera, Inc. All rights reserved. TPC-H (analytics benchmark) • 75 server cluster • 12 (spinning) disks each, enough RAM to fit dataset • TPC-H Scale Factor 100 (100GB) • Example query: • SELECT n_name, sum(l_extendedprice * (1 - l_discount)) as revenue FROM customer, orders, lineitem, supplier, nation, region WHERE c_custkey = o_custkey AND l_orderkey = o_orderkey AND l_suppkey = s_suppkey AND c_nationkey = s_nationkey AND s_nationkey = n_nationkey AND n_regionkey = r_regionkey AND r_name = 'ASIA' AND o_orderdate >= date '1994-01-01' AND o_orderdate < '1995-01-01’ GROUP BY n_name ORDER BY revenue desc;
  • 41. 41© Cloudera, Inc. All rights reserved. • Kudu outperforms Parquet by 31% (geometric mean) for RAM-resident data
  • 42. 42© Cloudera, Inc. All rights reserved. Versus other NoSQL storage • Apache Phoenix: OLTP SQL engine built on HBase • 10 node cluster (9 worker, 1 master) • TPC-H LINEITEM table only (6B rows)
  • 43. 43© Cloudera, Inc. All rights reserved. Joining the growing community
  • 44. 44© Cloudera, Inc. All rights reserved. Apache Kudu Community
  • 45. 45© Cloudera, Inc. All rights reserved. Getting started as a user • On the web: kudu.apache.org • User mailing list: user@kudu.apache.org • Public Slack chat channel (see web site for the link) • Quickstart VM • Easiest way to get started • Impala and Kudu in an easy-to-install VM • CSD and Parcels • For installation on a Cloudera Manager-managed cluster
  • 46. 46© Cloudera, Inc. All rights reserved. Getting started as a developer • Source code: github.com/apache/kudu - all commits go here first • Code reviews: gerrit.cloudera.org - all code reviews are public • Developer mailing list: dev@kudu.apache.org • Public JIRA: issues.apache.org/jira/browse/KUDU - includes bug history since 2013 Contributions are welcome and strongly encouraged!
  • 47. 47© Cloudera, Inc. All rights reserved. kudu.apache.org @mike_percy | @ApacheKudu