前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >一套数据,多种引擎

一套数据,多种引擎

作者头像
大数据和云计算技术
发布2018-03-08 10:56:38
1K0
发布2018-03-08 10:56:38
举报

以前写过一篇文档讨论MPP DB的发展,《MPP DB 是 大数据实时分析系统 未来的选择吗?》,当时主要是想讨论下Greenplum数据库是否合适做数据存储,以及实时查询。文章我主要提的MPP DB短板是扩展性和对并发的支持,从目前Pivotal公司主推的HAWK,已经可以清楚的看到,业界主流的思路是SQL onhadoop,用传统引擎的高性能加上hadoop 存储的鲁棒性,来构建大数据实时分析。

一、为什么SQL on hadoop会流行?

SQL其实也是一种DSL,将复杂的数据操作抽象成几个关键字(insert,update,select,delect等),SQL易学易用,程序员和DBA掌握的很多。因此Hadoop成为流行的大数据分析解决套件之后,SQL on hadoop成为无法阻挡的趋势。总结两句话:为什么非要把SQL放到Hadoop上? SQL易于使用。那为什么非得基于Hadoop呢?the robust and scalable architecture of Hadoop。

SQL on hadoop有Dremel/PowerDrill(Google) Impala(Cloudera) HIVE/Stinger/Tez(Hortonworks) HAWK(EMC) SQL on spark/Shark(Berkeley) 等,这些系统各有各的发展历程,以及特点,同时也存在显著的缺点。

二、今天讨论一个思路:一套数据,多个引擎。

SQL on hadoop目前最成熟的应该是Hive,发展早,使用多。Hive是目前互联网企业中处理大数据、构建数据仓库最常用的解决方案,甚至在很多公司部署了Hadoop集群不是为了跑原生MapReduce程序,而全用来跑Hive SQL的查询任务。目前Hive的主要缺点: 1,data shuffle时网络瓶颈,Reduce要等Map结束才能开始,不能高效利用网络带宽 2,一般一个SQL都会解析成多个MR job,Hadoop每次Job输出都直接写HDFS,性能差 3,每次执行Job都要启动Task,花费很多时间,无法做到实时 4,由于把SQL转化成MapReduce job时,map,shuffle和reduce所负责执行的SQL功能不同。那么就有Map->MapReduce或者MapReduce->Reduce这样的需求。这样可以降低写HDFS的次数,从而提高性能。很明显,由于架构上的天然涉及,Hive只适合批处理。

Cloudera的impala是另外一个典型的代表,Impala可以看成是Google Dremel架构和MPP (Massively Parallel Processing)结构的混合体,根据Cloudera公司的宣传,也是目前业界开源的最快的引擎,相关测试结果可以参考http://blog.cloudera.com/blog/2014/05/new-sql-choices-in-the-apache-hadoop-ecosystem-why-impala-continues-to-lead/。

最近发布的CDH5.2中包含了impala 2.0,impala 2.0对SQL兼容性和关键的join有重大改进。

Impala 2.0 (Ships in Fall 2014)

1. SQL 2003-compliant analytic window functions (aggregation OVER PARTITION, RANK, LEAD, LAG, NTILE, and so on) – to provide more advanced SQL analytic capabilities

2. External joins and aggregations using disk – enables operations to spill to disk if their internal state exceeds the aggregate memory size

3. Subqueries inside WHERE clauses

4. Incremental statistics – only run statistics on the new or changed data for even faster statistics computations

5. Additional data types – including VARCHAR, CHAR

6. Additional built-in functions – enables easier migration of custom language extensions for users of traditional SQL engines

当能impala也不是包打天下,对批量数据的处理如数据挖掘分析,还是不如HIVE稳定可靠。而impala天然是继承Hive的元数据,所以完全可以综合两者的优点,同一套数据,多个引擎。Impala应对秒级的交互查询,Hive应对批量数据的分析。下面是impala官方介绍的impala和Hive的关系。

How Impala Works with Hive

A major Impala goal is to make SQL-on-Hadoop operations fast and efficient enough to appeal to new categories of users and open up Hadoop to new types of use cases. Where practical, it makes use of existing Apache Hive infrastructure that many Hadoop users already have in place to perform long-running, batch-oriented SQL queries.

In particular, Impala keeps its table definitions in a traditional MySQL or PostgreSQL database known as the metastore, the same database where Hive keeps this type of data. Thus, Impala can access tables defined or loaded by Hive, as long as all columns use Impala-supported data types, file formats, and compression codecs.

The initial focus on query features and performance means that Impala can read more types of data with the SELECT statement than it can write with the INSERT statement. To query data using the Avro, RCFile, or SequenceFile file formats, you load the data using Hive.

The Impala query optimizer can also make use of table statistics and column statistics. Originally, you gathered this information with the ANALYZE TABLE statement in Hive; in Impala 1.2.2 and higher, use the Impala COMPUTE STATS statement instead. COMPUTE STATS requires less setup, is more reliable and faster, and does not require switching back and forth between impala-shell and the Hive shell.

如果需要更高的OLAP分析速度,可以考虑kylin,最近有ebay开源的OLAP引擎。核心思路,数据提取建模,通过HIVE将数据转换成cube,存入HBASE中方便查询。这个就是要求提前建立cube,智能应对特定的模型。

三、需要做的工作:

要做到HIVE/impala共一套数据,其实也有很多工作。目前impala主要在Parquet格式下性能高,HIVE主要使用的是ORCFile。两种存储格式都是列式存储,各有优势。Parquet主要是支持嵌套式数据,ORCFile的每个strip中有一段index data。Index data包含每列的最大和最小值以及每列所在的行。行索引里面提供了偏移量,它可以跳到正确的压缩块位置。具有相对频繁的行索引,使得在stripe中快速读取的过程中可以跳过很多行,尽管这个stripe的大小很大。所以需要两个引擎各自兼容对ORCFile/Parquet的支持,或者融合两种存储格式的优点,让HIVE/impala支持。

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2014-11-02,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 大数据和云计算技术 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
数据库
云数据库为企业提供了完善的关系型数据库、非关系型数据库、分析型数据库和数据库生态工具。您可以通过产品选择和组合搭建,轻松实现高可靠、高可用性、高性能等数据库需求。云数据库服务也可大幅减少您的运维工作量,更专注于业务发展,让企业一站式享受数据上云及分布式架构的技术红利!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档