An Introduction to Impala – Low Latency Queries for Apache Hadoop

  • 3,140 views
Uploaded on

View the accompanying video on vimeo: http://vimeo.com/chug/introduction-to-impala

View the accompanying video on vimeo: http://vimeo.com/chug/introduction-to-impala

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,140
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
241
Comments
0
Likes
8

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Impala: A Modern SQL Engine for Hadoop Marcel Kornacker Cloudera, Inc. 12/03/2012
  • 2. Impala Overview: Goals● General-purpose SQL query engine: ○ should work both for analytic and transactional workloads ○ will support queries that take from microseconds to hours● Runs directly within Hadoop: ○ reads widely used Hadoop file formats ○ talks to widely used Hadoop storage managers ○ runs on same nodes that run Hadoop processes● High performance: ○ C++ instead of Java ○ runtime code generation ○ completely new execution engine that doesnt build on MapReduce
  • 3. User View of Impala: Overview● Runs as a distributed service in cluster: one Impala daemon on each node with data● User submits query via ODBC/Beeswax Thrift API to any of the daemons● Query is distributed to all nodes with relevant data● If any node fails, the query fails● Impala uses Hives metadata interface, connects to Hives metastore● Supported file formats: ○ text files (GA: with compression, including lzo) ○ sequence files with snappy/gzip compression ○ GA: Avro data files ○ GA: Trevni (columnar format; more on that later)
  • 4. User View of Impala: SQL● SQL support: ○ patterned after Hives version of SQL ○ limited to Select, Project, Join, Union, Subqueries, Aggregation and Insert ○ Order By only with Limit ○ GA: DDL support (CREATE, ALTER)● Functional limitations: ○ no custom UDFs, file formats, SerDes ○ no beyond SQL (buckets, samples, transforms, arrays, structs, maps, xpath, json) ○ only hash joins; joined table has to fit in memory: ■ beta: of single node ■ GA: aggregate memory of all (executing) nodes ○ beta: join order = FROM clause order ○ GA: rudimentary cost-based optimizer
  • 5. User View of Impala: HBase● HBase functionality: ○ uses Hives mapping of HBase table into metastore table ○ predicates on rowkey columns are mapped into start/stop row ○ predicates on other columns are mapped into SingleColumnValueFilters● HBase functional limitations: ○ no nested-loop joins ○ all data stored as text
  • 6. Impala Architecture● Two binaries: impalad and statestored● Impala daemon (impalad) a. handles client requests and all internal requests related to query execution b. exports Thrift services for these two roles● State store daemon (statestored) a. provides name service and metadata distribution b. also exports a Thrift service
  • 7. Impala Architecture● Query execution phases ○ request arrives via odbc/beeswax Thrift API ○ planner turns request into collections of plan fragments ○ coordinator initiates execution on remote impalads ○ during execution ■ intermediate results are streamed between executors ■ query results are streamed back to client ■ subject to limitations imposed to blocking operators (top-n, aggregation)
  • 8. Impala Architecture● Planner: ○ join order = FROM clause order GA target: rudimentary cost-based optimizer ○ plan operators: Scan, HashJoin, HashAggregation, Union, TopN, Exchange ○ distributed aggregation: pre-aggregation in all nodes, merge aggregation in single node GA: hash-partitioned aggregation ○ partitions plans along scan boundaries
  • 9. Impala Architecture● Example: query with join and aggregation SELECT state, SUM(revenue) FROM HdfsTbl h JOIN HbaseTbl b ON (...) GROUP BY 1 ORDER BY 2 desc LIMIT 10 TopN Agg TopN Agg Hash Agg Join Hash Join Hdfs Hbase Exch Exch Scan Scan Hdfs Hbase at coordinator at DataNodes at region servers Scan Scan
  • 10. Impala Architecture: Query ExecutionRequest arrives via odbc/beeswax Thrift API SQL App Hive HDFS NN Statestore ODBC Metastore SQL request Query Planner Query Planner Query Planner Query Coordinator Query Coordinator Query Coordinator Query Executor Query Executor Query Executor HDFS DN HBase HDFS DN HBase HDFS DN HBase
  • 11. Impala Architecture: Query ExecutionPlanner turns request into collections of plan fragmentsCoordinator initiates execution on remote impalads SQL App Hive HDFS NN Statestore ODBC Metastore Query Planner Query Planner Query Planner Query Coordinator Query Coordinator Query Coordinator Query Executor Query Executor Query Executor HDFS DN HBase HDFS DN HBase HDFS DN HBase
  • 12. Impala Architecture: Query ExecutionIntermediate results are streamed between impaladsQuery results are streamed back to client SQL App Hive HDFS NN Statestore ODBC Metastore query results Query Planner Query Planner Query Planner Query Coordinator Query Coordinator Query Coordinator Query Executor Query Executor Query Executor HDFS DN HBase HDFS DN HBase HDFS DN HBase
  • 13. Impala Architecture● Metadata handling: ○ utilizes Hives metastore ○ caches metadata: no synchronous metastore API calls during query execution ○ beta: impalads read metadata from metastore at startup ○ GA: metadata distribution through statestore
  • 14. Impala Architecture● Execution engine ○ written in C++ ○ runtime code generation for "big loops" ■ example: insert batch of rows into hash table ■ code generation with llvm ■ inlines all expressions; no function calls inside loop ○ all data is copied into canonical in-memory tuple format; all fixed-width data is located at fixed offsets ○ uses intrinsics/special cpu instructions for text parsing, crc32 computation, etc.
  • 15. Impalas Statestore● Central system state repository ○ name service (membership) ○ GA: metadata ○ GA: other scheduling-relevant or diagnostic state● Soft-state ○ all impalads register at startup ○ impalads re-register after losing connection ○ Impala service continues to function in absence of statestored (but: with increasingly stale state) ○ State pushed to impalads periodically ○ Repeated failed heartbeat means impalad evicted from cluster view● Thrift API for service / subscription registration
  • 16. Comparing Impala to Dremel● What is Dremel: ○ columnar storage for data with nested structures ○ distributed scalable aggregation on top of that● Columnar storage in Hadoop: Trevni ○ new columnar format created by Doug Cutting ○ stores data in appropriate native/binary types ○ can also store nested structures similar to Dremels ColumnIO● Distributed aggregation: Impala● Impala plus Trevni: a superset of the published version of Dremel (which didnt support joins)
  • 17. Comparing Impala to Hive● Hive: MapReduce as an execution engine ○ High latency, low throughput queries ○ Fault-tolerance model based on MapReduces on- disk checkpointing; materializes all intermediate results ○ Java runtime allows for easy late-binding of functionality: file formats and UDFs. ○ Extensive layering imposes high runtime overhead● Impala: ○ direct, process-to-process data exchange ○ no fault tolerance ○ an execution engine designed for low runtime overhead
  • 18. Comparing Impala to Hive● Impalas performance advantage over Hive: no hard numbers, but ○ Impala can get full disk throughput (~100MB/sec/disk); I/O-bound workloads often faster by 3-4x ○ queries that require multiple map-reduce phases in Hive see a higher speedup ○ queries that run against in-memory data see a higher speedup (observed up to 100x)
  • 19. Try it out!● Beta version available since 10/24/12● Were targeting GA for end of Q1 2013● Questions/comments? impala-user@cloudera.org● My email address: marcel@cloudera.com