大数据Map Reduce 和 MPP数据库 的区别
總結來說MR是一個編程模型,你可以用MR這個編程模型自己實現MPP所做的事。
MPP則是一種SQL的計算引擎。
“MR分而治之的策略” 和 “Massively Parallel Processor類型的數據庫” (即大規模并行處理數據庫,典型代表 AWS Redshift?和 Teradata?以及微軟的 Azure SQL Data Warehouse) 有什么區別呢?
MPP在數據存儲的時候就根據指定的分布方式交給不同節點儲存,?查詢的時候各塊的節點有獨立的計算資源分別處理,?然后匯總到一個leader?node(又叫control?node),?具體的優化和傳統的關系型數據庫很相似,?涉及到了索引,?統計信息等概念. MPP有shared?everything /Disk / Nothing之別.
舉例來說說區別:
比如一張銷售表,?其中有一列產品類別,?現在要知道各個產品類別的總銷量.
| 類別a | 1 |
| 類別a | 2 |
| 類別b | 3 |
| 類別b | 1 |
| 類別c | 4 |
MR處理方法:?在map階段, 將不同的類別的數據map到不同的slaver處理,在統計各個類別總銷量,?然后shuffle到?reduce節點階段生成結果。
MPP處理方法:?每個節點統計各自存儲的數據中各個類別總銷量,?匯總結果到leader?node,?leader做個合并,在這個案例里就是做幾次加法
可以看到在這個場景中MPP的效率絕對比MR高的多,?MPP的每個節點直接處理存儲在自身上的數據,而MR則有一個網絡分發的過程。
在實際應用中的確MPP有更高的效率,?所以對于結構化的大數據, MPP至今仍是首選.?
正如開頭所說,MR的意義在于它是編程模型,相比MPP,它們能處理更加復雜的問題。
MR能自己開發Map、Reduce的代碼,不受SQL語法限制。相比于SQL屈指可數的幾個聚合函數(sum, avg, max, rank...),MR能隨心所欲地開發出各種處理數據的邏輯,把數據分布到不通的節點上去計算。
以下為轉載:
Shared Everything:一般是針對單個主機,完全透明共享CPU/MEMORY/IO,并行處理能力是最差的,典型的代表SQLServer
Shared Disk:各個處理單元使用自己的私有 CPU和Memory,共享磁盤系統。典型的代表Oracle Rac, 它是數據共享,可通過增加節點來提高并行處理的能力,擴展能力較好。其類似于SMP(對稱多處理)模式,但是當存儲器接口達到飽和的時候,增加節點并不能獲得更高的性能?。
Shared Nothing:各個處理單元都有自己私有的CPU/內存/硬盤等,不存在共享資源,類似于MPP(大規模并行處理)模式,各處理單元之間通過協議通信,并行處理和擴展能力更好。典型代表DB2 DPF和hadoop ,各節點相互獨立,各自處理自己的數據,處理后的結果可能向上層匯總或在節點間流轉。
我們常說的?Sharding 其實就是Share Nothing架構,它是把某個表從物理存儲上被水平分割,并分配給多臺服務器(或多個實例),每臺服務器可以獨立工作,具備共同的schema,比如MySQL Proxy和Google的各種架構,只需增加服務器數就可以增加處理能力和容量。
另外MPP 的切分必須在任何時候都是平均的 , 不然某些節點處理的時間就明顯多于另外一些節點。
對于工作負載是不是要平均分布有同種和異種之分,同種就是所有節點在數據裝載的時候都同時轉載,異種就是可以指定部分節點專門用來裝載數據(邏輯上的不 是物理上) , 而其他所有節點用來負責查詢。 Aster Data 和Greenplum 都屬于這種。 兩者之間并沒有明顯的優勢科研,同種的工作負載情況下,需要軟件提供商保證所有節點的負載是平衡的。 而異種的工作負載可以在你覺得數據裝載很慢的情況下手工指定更多節點裝載數據 。 區別其實就是自動化和手工控制,看個人喜好而已。?
?
另外一個問題是查詢如何被初始化的。 比如要查詢銷售最好的10件商品,每個節點都要先計算出自己的最好的10件商品,然后向上匯總,匯總的過程,肯定有些節點做的工作比其他節點要多。
上面只是一個簡單的單表查詢,如果是兩個表的連接查詢,可能還會涉及到節點之間計算的中間過程如何傳遞的問題。 是將大表和小表都平均分布,然后節點計算的時候將得到的結果匯總(可能要兩次匯總),還是將大表平均分布,小表的數據傳輸給每個節點,這樣匯總就只需要一 次。 (其中一個特例可以參考后面給出的Oracle Partition Wise Join) 。 兩種執行計劃很難說誰好誰壞,數據量的大小可能會產生不同的影響。 有些特定的廠商專門對這種執行計劃做過了優化的,比如EMC Greenplum 和 HP Vertica 。 這其中涉及到很多取舍問題,比如數據分布模式,數據重新分布的成本,中間交換數據的網卡速度,儲存介質讀寫的速度和數據量大小(計算過程一般都會用臨時表 儲存中間過程)。?
轉載部分的原文鏈接:
Shared Everything和share-nothing區別_seteor的專欄-CSDN博客
數據倉庫技術中的MPP_fengyuruhui123的博客-CSDN博客_mpp數據倉庫
下面這段描述了MPP(Azure Data Warehouse)中怎么把一張大表分布到各個節點上(Dedicated SQL pool (formerly SQL DW) architecture - Azure Synapse Analytics | Microsoft Docs):?
Hash-distributed tables(轉者注:?在可能經常要filter或join的列上用hash來分布)
A hash distributed table can deliver the highest query performance for joins and aggregations on large tables.
To shard data into a hash-distributed table, SQL Data Warehouse uses a hash function to deterministically assign each row to one distribution. In the table definition, one of the columns is designated as the distribution column. The hash function uses the values in the distribution column to assign each row to a distribution.
The following diagram illustrates how a full (non-distributed table) gets stored as a hash-distributed table.
- Each row belongs to one distribution.
- A deterministic hash algorithm assigns each row to one distribution.
- The number of table rows per distribution varies as shown by the different sizes of tables.
There are performance considerations for the selection of a distribution column, such as distinctness, data skew, and the types of queries that run on the system.
Round-robin distributed tables (轉者注:?純隨機分布)
A round-robin table is the simplest table to create and delivers fast performance when used as a staging table for loads.
A round-robin distributed table distributes data evenly across the table but without any further optimization. A distribution is first chosen at random and then buffers of rows are assigned to distributions sequentially. It is quick to load data into a round-robin table, but query performance can often be better with hash distributed tables. Joins on round-robin tables require reshuffling data and this takes additional time.
Replicated Tables?(轉者注:?這就類似hadoop中的分布式緩存)
A replicated table provides the fastest query performance for small tables.
A table that is replicated caches a full copy of the table on each compute node. Consequently, replicating a table removes the need to transfer data among compute nodes before a join or aggregation. Replicated tables are best utilized with small tables. Extra storage is required and there are additional overheads that are incurred when writing data which make large tables impractical.
The following diagram shows a replicated table. For SQL Data Warehouse, the replicated table is cached on the first distribution on each compute node.
下面在這篇文章里對MR的解釋很好,?從原理的角度出發,?map?reduce其實就是二分查找的一個逆過程,?不過因為計算節點有限,?所以map和reduce前都預先有一個分區的步驟.?二分查找要求數據是排序好的,?所以Map Reduce之間會有一個shuffle的過程對Map的結果排序. Reduce的輸入是排好序的.
大數據數據庫:MPP vs MapReduce_Dreamy_LIN的博客-CSDN博客_mpp數據庫
總結
以上是生活随笔為你收集整理的大数据Map Reduce 和 MPP数据库 的区别的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: FastClick 填坑及源码解析
- 下一篇: 【GBase 8a MPP数据库集群】函