28
Copyright © 2013 Cloudera Inc. All rights reserved. Headline Goes Here Speaker Name or Subhead Goes Here Practical Performance Analysis and Tuning for Cloudera Impala Marcel Kornacker | [email protected] 2013-11-11 Copyright © 2013 Cloudera Inc. All rights reserved.

Cloudera Impala technical deep dive

  • Upload
    huguk

  • View
    4.545

  • Download
    12

Embed Size (px)

DESCRIPTION

Why Cloudera build Imapla and how it achieves it's blistering speed.

Citation preview

Page 1: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Headline Goes HereSpeaker Name or Subhead Goes Here

Practical Performance Analysis and Tuning for Cloudera ImpalaMarcel Kornacker | [email protected] 2013-11-11

Copyright © 2013 Cloudera Inc. All rights reserved.

Page 2: Cloudera Impala technical deep dive

You might just be surprised

Just how fast is Impala?

!2

Page 3: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

How fast is Impala?

!3

“DeWitt Clause” prohibits using DBMS vendor name

Page 4: Cloudera Impala technical deep dive

Running with Impala

Practical Performance

!4

Page 5: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Pre-execution Checklist•Data types •Partitioning •File Format

!5

Page 6: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Data Type Choices•Define integer columns as INT/BIGINT

• Operations on INT/BIGINT more efficient than STRING •Convert “external” data to good “internal” types on load •e.g. CAST date strings to TIMESTAMPS •This avoids expensive CASTs in queries later

!6

Page 7: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Partitioning•“The fastest I/O is the one that never takes place.” •Understand your query filter predicates

• For time-series data, this is usually the date/timestamp column • Use this/these column(s) for a partition key(s)

•Validate queries leverage partition pruning using EXPLAIN •You can have too much of a good thing

• A few thousand partitions per table is probably OK • Tens of thousands partitions is probably too much • Partitions/Files should be no less than a few hundred MBs

!7

Page 8: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Partition Pruning in EXPLAINexplain select count(*) from sales_fact where sold_date in('2000-01-01','2000-01-02'); !

— Partition Pruning (partitioned table) 0:SCAN HDFS table=grahn.sales_fact #partitions=2 size=803.15MB tuple ids: 0 !

— Filter Predicate (non-partitioned table) 0:SCAN HDFS table=grahn.sales_fact #partitions=1 size=799.42MB predicates: sold_date IN ('2000-01-01', '2000-01-02') tuple ids: 0

!8

Note the partition count and missing

“predicates” filter due to parse time

Page 9: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Why use Parquet Columnar Format for HDFS?•Well defined open format - http://parquet.io/

• Works in Impala, Pig, Hive & Map/Reduce • I/O reduction by only reading necessary columns •Columnar layout compresses/encodes better •Supports nested data by shredding columns

• Uses techniques used by Google’s ColumnIO • Impala loads use Snappy compression by default

• Gzip available: set PARQUET_COMPRESSION_CODEC=gzip; •Quick word on Snappy vs. Gzip

!9

Page 10: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Parquet: A Motivating Example

!10

Page 11: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Quick Note on Compression•Snappy

• Faster compression/decompression speeds • Less CPU cycles • Lower compression ratio

•Gzip/Zlib • Slower compression/decompression speeds • More CPU cycles • Higher compression ratio

• It’s all about trade-offs!11

Page 12: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

It’s all about the compression codec

Compressed with Snappy

Compressed with Gzip

Hortonworks graphic fails to call out

that different codecs are used. Gzip compresses better than

Snappy, but we all knew that.

!12

Source: http://hortonworks.com/blog/orcfile-in-hdp-2-better-compression-better-performance/

Page 13: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

TPC-DS 500GB Scale Factor% of Original Size - Lower is Better

Snappy

Gzip

0 0.088 0.175 0.263 0.35

27.4%

34.8%

26.9%

32.3%ParquetORCFile

!13

Using the same compression codec

produces comparable results

Page 14: Cloudera Impala technical deep dive

What happens behind the scenes

Query Execution

!14

Page 15: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Left-Deep Join Tree

R1 R2

R3

R4

•The largest* table should be listed first in the FROM clause

• Joins are done in the order tables are listed in FROM clause

•Filter early - most selective joins/tables first

•v1.2.1 will do JOIN ordering

!15

Page 16: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Two Types of Hash Joins•Default hash join type is BROADCAST (aka replicated)

• Each node ends up with a copy of the right table(s)* • Left side, read locally and streamed through local hash join(s) • Best choice for “star join”, single large fact table, multiple small dims

•Alternate hash join type is SHUFFLE (aka partitioned) • Right side hashed and shuffled; each node gets ~1/Nth the data • Left side hashed and shuffled, then streamed through join • Best choice for “large_table JOIN large_table” • Only available if ANALYZE was used to gather table/column stats*

!16

Page 17: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

How to use ANALYZE•Table Stats (from Hive shell)

• analyze table T1 [partition(partition_key)] compute statistics; •Column Stats (from Hive shell)

• analyze table T1 [partition(partition_key)] compute statistics for columns c1,c2,…

• Impala 1.2.1 will have a built-in ANALYZE command !

!17

Page 18: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Hinting Joins

select ... from large_fact join [broadcast] small_dim !

!

select ... from large_fact join [shuffle] large_dim !

*square brackets required

!18

Page 19: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.!19

explain select c_preferred_cust_flag, count(*) from store_sales join customer on (ss_customer_sk = c_customer_sk) group by c_preferred_cust_flag; !2:HASH JOIN | join op: INNER JOIN (PARTITIONED) | hash predicates: | ss_customer_sk = c_customer_sk | tuple ids: 0 1 | |----5:EXCHANGE | tuple ids: 1 | 4:EXCHANGE tuple ids: 0

Determining Join Type From EXPLAINexplain select s_state, count(*) from store_sales join store on (ss_store_sk = s_store_sk) group by s_state; !2:HASH JOIN | join op: INNER JOIN (BROADCAST) | hash predicates: | ss_store_sk = s_store_sk | tuple ids: 0 1 | |----4:EXCHANGE | tuple ids: 1 | 0:SCAN HDFS table=tpcds.store_sales tuple ids: 0

Page 20: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Memory Requirements for Joins & Aggregates• Impala does not “spill” to disk -- pipelines are in-memory •Operators’ mem usage need to fit within the memory limit •This is not the same as “all data needs to fit in memory”

• Buffered data generally significantly smaller than total accessed data

• Aggregations’ mem usage proportional to number of groups •Applies for each in-flight query (sum of total) •Minimum of 128GB of RAM is recommended for impala nodes

!20

Page 21: Cloudera Impala technical deep dive

A great resource for debug information

Impala Debug Web Pages

!21

Page 22: Cloudera Impala technical deep dive
Page 23: Cloudera Impala technical deep dive

!23

Page 24: Cloudera Impala technical deep dive
Page 25: Cloudera Impala technical deep dive

Impala performance checklist

Quick Review

!25

Page 26: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Impala Performance Checklist•Choose appropriate data types •Leverage partition pruning •Adopt Parquet format •Gather table & column stats •Order JOINS optimally •Validate JOIN type •Monitor hardware resources

Automatic in v1.2.1

!26

Page 27: Cloudera Impala technical deep dive

Copyright © 2013 Cloudera Inc. All rights reserved.

Test drive Impala• Impala Community:

• Download: http://cloudera.com/impala • Github: https://github.com/cloudera/impala • User group: impala-user on groups.cloudera.org

!27 Copyright © 2013 Cloudera Inc. All rights reserved.

Page 28: Cloudera Impala technical deep dive

Thank you.

SELECT questions FROM audience;

!28