WO2021052169A1 - 分布式数据的均衡处理方法、装置、计算终端和存储介质 - Google Patents

分布式数据的均衡处理方法、装置、计算终端和存储介质 Download PDF

Info

Publication number
WO2021052169A1
WO2021052169A1 PCT/CN2020/112877 CN2020112877W WO2021052169A1 WO 2021052169 A1 WO2021052169 A1 WO 2021052169A1 CN 2020112877 W CN2020112877 W CN 2020112877W WO 2021052169 A1 WO2021052169 A1 WO 2021052169A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
partition
shuffle
statistics
written
Prior art date
Application number
PCT/CN2020/112877
Other languages
English (en)
French (fr)
Inventor
刘少麟
张强
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2021052169A1 publication Critical patent/WO2021052169A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5083Techniques for rebalancing the load in a distributed system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/06Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
    • G06F3/0601Interfaces specially adapted for storage systems
    • G06F3/0628Interfaces specially adapted for storage systems making use of a particular technique
    • G06F3/0638Organizing or formatting or addressing of data
    • G06F3/0644Management of space entities, e.g. partitions, extents, pools

Definitions

  • This application relates to a balanced processing method, device, computing terminal and storage medium for distributed data.
  • MapReduce is a computing model for processing massive amounts of data. It includes two processing processes: Map and Reduce, and the process of data output from Map task to Reduce task input is shuffle. In the Map, each Map task will output a set of key/value pairs. The Shuffle stage needs to combine key/value pairs with the same key from all Maps and pass them as input to the Reduce task.
  • an embodiment of the present application provides a balanced processing method, device, computing terminal, and storage medium for distributed data, which are used to at least solve the problem of data skew to a certain extent and improve the running speed of distributed data processing.
  • an embodiment of the present application provides a balanced processing method for distributed data, including: obtaining shuffle statistical data, where the shuffle statistical data includes the data volume of each partition in the shuffle phase; and judging according to the shuffle statistical data Whether there is a data sloping partition; when there is a data sloping partition, the data sloping partition is segmented; the physical plan is rewritten according to the partitioned partition; the rewritten physical plan is executed.
  • an embodiment of the present application provides a distributed data balancing processing device, including: a shuffle statistics acquisition module, configured to acquire shuffle statistics, where the shuffle statistics include the data volume of each partition in the shuffle phase;
  • the oblique judging module is used to determine whether there is a data oblique partition based on the shuffle statistical data;
  • the partition splitting module is used to divide the data oblique partition when there is a data oblique partition;
  • the physical plan rewrite module is used to divide the data according to the After the partition, the physical plan is rewritten;
  • the physical plan execution module is used to execute the rewritten physical plan.
  • an embodiment of the present application provides a computing terminal, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor.
  • the computer program executes the distributed data equalization. Approach.
  • an embodiment of the present application provides a computer-readable storage medium that stores computer-executable instructions, and the computer-executable instructions are used to execute the method for equalizing the distributed data.
  • FIG. 1 is a flowchart of a method for balancing distributed data provided by an embodiment of the present application
  • FIG. 2 is a flowchart of obtaining shuffle statistical data in a balanced processing method for distributed data provided by an embodiment of the present application
  • FIG. 3A is a schematic diagram of segmenting data oblique partitions in a balanced processing method for distributed data provided by an embodiment of the present application
  • FIG. 3B is a schematic diagram of dividing data oblique partitions in a balanced processing method for distributed data provided by another embodiment of the present application.
  • FIG. 3C is a schematic diagram of segmenting data oblique partitions in a balanced processing method for distributed data provided by another embodiment of the present application.
  • Fig. 6 is a schematic diagram of a distributed data equalization processing device provided by an embodiment of the present application.
  • Fig. 7 is a schematic diagram of a computing terminal provided by an embodiment of the present application.
  • the existing distributed SQL (Structured Query Language) engine is based on MapReduce theory, whether it is Hive, SparkSQL or Impala, when performing Join or statistical operations, the Map process will summarize data with the same Key.
  • MapReduce theory whether it is Hive, SparkSQL or Impala, when performing Join or statistical operations, the Map process will summarize data with the same Key.
  • the Shuffle file the Reduce process will grab the data with the same Key from the Shuffle and enter it into the same node for processing, because the same Key cannot be calculated on different machines. This is the only processing method under the existing hardware and software architecture. . When there is too much data for a key, data skew will occur.
  • Data skew is reflected in the task execution of most nodes are very fast, but the task execution of individual nodes is extremely slow, and the running speed of the entire job is determined by the task with the longest running time, so the data skew will be lowered. The running speed of the entire job.
  • the embodiment of the present application solves the above-mentioned data skew problem at least to a certain extent.
  • an embodiment of the present application provides a balanced processing method for distributed data, including the following steps:
  • Step S100 obtain shuffle statistical data.
  • the shuffle statistics include the data volume of each partition in the shuffle phase.
  • step S100 may include the following steps:
  • Step S110 every time a record write operation is performed in the shuffle phase, the record statistical value of the corresponding partition is updated;
  • step S120 the data volume of each partition is obtained according to the recorded statistical value.
  • the data volume of each partition in each Map task in this job can be obtained through simple code reconstruction in the ShuffleWrite stage.
  • the data volume includes the number of records. And record size.
  • the specific implementation can use the partition as the statistical unit to update the statistical values of the number of records and the size of the records when each record of the Map is processed in the Shuffle Write stage.
  • the above process is embedded in the existing computing framework, and there is basically no performance loss.
  • the tilt judgment can be made based on the statistical value of the record number and record size of each partition.
  • Step S200 Determine whether there is a data skewed partition based on the shuffle statistical data.
  • a preset record size threshold is used to determine whether there is a data oblique partition. When the sum of the record size of a certain partition in all Maps is greater than the preset record size threshold, it is determined that the partition has data skew.
  • the threshold of the number of records and the threshold of the record size can be defined according to the partition configuration.
  • the partition is considered to be skewed, that is, when R(P)>RSkew or S(P)>SSkew, the partition is considered to be skewed.
  • R(P) represents the number of records in the partition
  • S(P) represents the record size of the partition
  • RSkew represents the record number threshold of the partition configuration
  • SSkew represents the record size threshold of the partition configuration.
  • the record number threshold and record size threshold can also be defined according to the median of the partition data value.
  • the average number is not used here because the average number will be affected by the distribution of the partition. When there is a maximum or minimum value, the average The number loses the meaning of comparison.
  • a parameter can be set to define the median threshold Cthreshold. When R(P)>RMedian*(1+Cthreshold) or S(P)>SMedian*(1+Cthreshold), the partition is determined to be inclined. Among them, RMedian and SMedia respectively represent the median of the number of records and the record size.
  • the method for judging data tilt provided in the embodiment of the present application does not require the user to perceive tilt in any way, that is, automatic data tilt detection and automatic positioning of data tilt partitions can be realized without any performance loss.
  • step S300 when there are data oblique partitions, the data oblique partitions are segmented.
  • step S300 further illustrate step S300 by way of example.
  • segmentation of the data slanted partition may be based on the data volume of the data slanted partition in each Map, and the partition data is written into multiple split files in units of Maps, and the partition data in each split file The amount is less than the preset threshold.
  • the P2 partition is a data oblique partition, and assume that the P2 partition data output from Map1, Map2, and Map3 is greater than the threshold after the addition, while the P2 partition data output by Map1, Map2, and Map3 are not greater than the threshold.
  • the P2 partition can be divided by the following steps:
  • the above is a simple logic that is generally applicable to most computing frameworks. This method can reduce changes to the computing framework and will have good results in practical applications. In this way, the calculation framework needs to be adjusted to support a ReduceTask to read part of the Map data of the Reduce.
  • the above steps can be performed on the Map side. More generally, it can be implemented by adding a start map and an end map to the existing computing framework.
  • the technical solution provided in this embodiment can also be executed on the Reduce side, and this application does not impose excessive restrictions on this.
  • the captured partition data when the captured partition data is written into the input file on the Reduce side, when the data value in the input file is greater than the preset threshold, a new input file is generated and written into the remaining partition data .
  • the Reduce end grabs the data of the P2 partition in Map1 and writes it into the input file.
  • the data value in the input file is When it is greater than the preset threshold, a new input file is generated, and the remaining data of the P2 partition is written into the new input file.
  • step S400 the physical plan is rewritten according to the divided partitions.
  • Step S500 execute the rewritten physical plan.
  • step S400 uses an embodiment to further exemplify step S400 and step S500.
  • Table A and Table B perform Join operations according to Key1;
  • partition A1 is divided into two sub-partitions, A1-1 and A1-2;
  • the SQL engine translates Union into a task of the calculation framework, submits it to the calculation framework for calculation, and returns the result of the entire Join operation after the calculation is completed.
  • step S400 and step S500 through an embodiment.
  • Table A and Table B perform Join operations according to Key1.
  • the table T generated after Join will generate Shuffle data according to Key2;
  • T2 is an oblique partition
  • T table and the C table are joined according to Key2, where T is partitioned according to Key2, this Join is divided into three partitions T1, T2, and T3 according to Key2, and the T2 partition is inclined, including Map ⁇ m1,m2,m3,m4,m5 ⁇ , the C1, C2, and C3 partitions of the C table are not tilted.
  • the T2 partition needs to be segmented.
  • the T2 partition will be segmented into three sub-partitions ⁇ T2m1+T2m2, T2m3, T2m4+T2m5 ⁇ .
  • the SQL engine will regenerate the physical plan according to partitions and the optimized physical plan is:
  • this method can be well satisfied even for scenes after multiple Joins. Similarly, it can be generally satisfied after other sub-queries or calculations. Because the technical solution of this application is dynamically designed based on the general SQL theory, it has a wide range of applicability.
  • an embodiment of the present application provides a distributed data balancing processing device 100, which can be applied to a SQL engine, and the device 100 includes:
  • the shuffle statistics obtaining module 110 is configured to obtain shuffle statistical data, where the shuffle statistical data includes the data volume of each partition in the shuffle phase;
  • the tilt determination module 120 is configured to determine whether there is a data tilt partition based on the shuffle statistical data
  • the partition splitting module 130 is used to split the data sloping partition when there are data sloping partitions
  • the physical plan rewriting module 140 is used to rewrite the physical plan according to the divided partitions
  • the physical plan execution module 150 is used to execute the rewritten physical plan.
  • the shuffle statistics obtaining module 110 is specifically used for:
  • the data volume of each partition is obtained.
  • the tilt judgment module 120 is specifically configured to:
  • the partition splitting module 130 is specifically used for:
  • the partition data is written into multiple segmentation files in the unit of Map, and the partition data volume in each segmentation file is less than a preset threshold.
  • partition splitting module 130 is specifically configured to:
  • the distributed data equalization processing apparatus 100 provided in this embodiment can execute the technical solutions of the various embodiments in the distributed data equalization processing method provided in the first aspect, and its implementation principles and technical effects are similar.
  • the functions of each module can be referred to The corresponding description in the method embodiment will not be repeated here.
  • An embodiment of the present application provides a computing terminal 200, including a processor 210, a memory 220, and a computer program stored on the memory 220 and running on the processor 210.
  • the computer program Execute the balanced processing method of distributed data at the time.
  • the processor 210 and the memory 220 may be connected by a bus or in other ways.
  • the memory 220 can be used to store non-transitory software programs and non-transitory computer-executable programs, such as the distributed data balancing method in the embodiment of the first aspect of the present application.
  • the processor 210 executes the non-transitory software programs and instructions stored in the memory 220 to implement the distributed data balancing method in the above-mentioned first aspect embodiment.
  • the memory 220 may include a storage program area and a storage data area.
  • the storage program area may store an operating system and an application program required by at least one function; the storage data area may store the method in the above-mentioned first aspect embodiment.
  • the memory 220 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices.
  • the memory 220 may optionally include memories remotely provided with respect to the processor 210, and these remote memories may be connected to the terminal through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
  • the non-transitory software programs and instructions required to implement the method for balancing distributed data in the embodiment of the first aspect are stored in the memory 220, and when executed by one or more processors 210, the embodiment of the first aspect is executed.
  • an embodiment of the present application provides a computer-readable storage medium that stores computer-executable instructions, and the computer-executable instructions are used to execute the distributed data balancing method.
  • the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more control processors 210, for example, processed by one of the computing terminals of the embodiments of the third aspect.
  • the above-mentioned one or more processors 210 execute the method for equalizing distributed data in the embodiment of the first aspect, for example, execute the steps S100 to S500 of the method in FIG. 1 described above, and the method in FIG. 2 Method steps S210 to S220.
  • the embodiment of the application includes: obtaining shuffle statistical data; judging whether there is a data sloping partition based on the shuffle statistic data; when there is a data slanting partition, dividing the data sloping partition; rewriting the physical plan according to the divided partition; executing; Physical plan after rewriting.

Abstract

一种分布式数据的均衡处理方法、装置、计算终端和存储介质。分布式数据的均衡处理方法包括:获取shuffle统计数据(S100);根据shuffle统计数据,判断是否存在数据倾斜分区(S200);当存在数据倾斜分区时,对数据倾斜分区进行切分(S300);根据切分后的分区,改写物理计划(S400);执行改写后的物理计划(S500)。

Description

分布式数据的均衡处理方法、装置、计算终端和存储介质
相关申请的交叉引用
本申请基于申请号为201910882725.0、申请日为2019年9月18日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。
技术领域
本申请涉及一种分布式数据的均衡处理方法、装置、计算终端和存储介质。
背景技术
MapReduce是处理海量数据的计算模型,其包括映射(Map)和归约(Reduce)两个处理过程,而数据从Map task输出到Reduce task输入的这段过程为重排(Shuffle)。在Map中,每个Map task会输出一组key/value对,Shuffle阶段需要从所有Map上把key相同的key/value对组合在一起,作为输入传至Reduce task里。
在Shuffle阶段,当某个Key的分区的数据过度集中,就会产生数据倾斜。数据倾斜会导致任务集中在某一台或者某几台机器中处理,这些过度集中的任务由于数据量很大,导致计算过程缓慢,从而拉低了整个作业的运行速度。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
一方面,本申请实施例提供了一种分布式数据的均衡处理方法、装置、计算终端和存储介质,用于至少在一定程度上解决数据倾斜的问题,提升分布式数据处理的运行速度。另一方面,本申请实施例提供了一种分布式数据的均衡处理方法,包括:获取shuffle统计数据,其中,所述shuffle统计数据包括shuffle阶段中各个分区的数据量;根据shuffle统计数据,判断是否存在数据倾斜分区;当存在数据倾斜分区时,对数据倾斜分区进行切分;根据切分后的分区,改写物理计划;执行改写后的物理计划。
另一方面,本申请实施例提供了一种分布式数据均衡处理装置,包括:shuffle统计获取模块,用于获取shuffle统计数据,其中,所述shuffle统计数据包括shuffle阶段中各个分区的数据量;倾斜判断模块,用于根据shuffle统计数据,判断是否存在数据倾斜分区;分区切分模块,用于当存在数据倾斜分区时,对数据倾斜分区进行切分;物理计划改写模块,用于根据切分后的分区,改写物理计划;物理计划执行模块,用于执行改写后的物理计划。
另一方面,本申请实施例提供了一种计算终端,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述计算机程序时执行所述的分布式数据的均衡处理方法。
另一方面,本申请实施例提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行所述的分布式数据的均衡处理所述的方法。
本申请的其它特征和优点将在随后的说明书中阐述,部分将从说明书随后的描述中变得显而易见,或者通过本申请的实施例而了解。本申请的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。
附图说明
附图用来提供对本申请技术方案的进一步理解,并且构成说明书的一部分,与本申请的实施例一起用于解释本申请的技术方案,并不构成对本申请技术方案的限制。
图1是本申请实施例提供的分布式数据的均衡处理方法的流程图;
图2是本申请实施例提供的分布式数据的均衡处理方法中获取shuffle统计数据的流程图;
图3A是本申请实施例提供的分布式数据的均衡处理方法中对数据倾斜分区进行切分的示意图;
图3B是本申请另一实施例提供的分布式数据的均衡处理方法中对数据倾斜分区进行切分的示意图;
图3C是本申请另一实施例提供的分布式数据的均衡处理方法中对数据倾斜分区进行切分的示意图;
图4、图5是本申请实施例提供的分布式数据的均衡处理方法的示例流程图;
图6是本申请实施例提供的分布式数据均衡处理装置的示意图;
图7是本申请实施例提供的计算终端的示意图。
具体实施方式
为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。
需要说明的是,虽然在装置示意图中进行了功能模块划分,在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于装置中的模块划分,或流程图中的顺序执行所示出或描述的步骤。
在本申请实施例的描述中,若干的含义是一个或者多个,多个的含义是两个以上,大于、小于、超过等理解为不包括本数,以上、以下、以内等理解为包括本数。如果有描述到“第一”、“第二”等只是用于区分技术特征为目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量或者隐含指明所指示的技术特征的先后关系。
现有的分布式SQL(结构化查询语言,Structured Query Language)引擎是基于MapReduce理论的,无论是Hive、SparkSQL还是Impala,当进行Join或者统计操作的时候,Map过程会将Key相同的数据进行汇总写入Shuffle文件,Reduce过程会从Shuffle 中抓取Key相同的数据进入同一节点进行处理,因为相同的Key在不同的机器上是无法算出结果,这是现有硬件和软件架构下的唯一处理方式。当某个key的数据特别多,就会产生数据倾斜。数据倾斜体现在绝大多数节点的task执行得都非常快,但个别节点的task执行极慢,而整个作业的运行速度正是由运行时间最长的那个task决定的,所以数据倾斜会拉低整个作业的运行速度。
本申请实施例即为至少在一定程度上解决上述数据倾斜问题。
下面结合附图,对本申请实施例作进一步阐述。
第一方面,参照图1,本申请实施例提供了一种分布式数据的均衡处理方法,包括以下步骤:
步骤S100,获取shuffle统计数据。其中,shuffle统计数据包括shuffle阶段中各个分区的数据量。
参照图2,在一实施例中,步骤S100可以包括以下步骤:
步骤S110,在shuffle阶段每执行一条记录的写入操作,则更新对应分区的记录统计值;
步骤S120,根据记录统计值,获得各个分区的数据量。
举例来说,在不新起单独统计任务的情况下,可以在Shuffle Write阶段,通过简单的代码重构,获取本次作业中每个Map task里每个分区的数据量,数据量包含记录数和记录大小。具体实现可以在Shuffle Write阶段处理Map的每条记录的时候,以分区为统计单位,更新记录数与记录大小的统计值。以上流程嵌入现有的计算框架内部,基本没有性能损失。在后续步骤中,根据各分区记录数与记录大小的统计值,即可进行倾斜判断。
步骤S200,根据shuffle统计数据,判断是否存在数据倾斜分区。
在一些实施例中,通过预置的记录数阈值判断是否存在数据倾斜分区。当某个分区在所有Map的记录数之和大于预置的记录数阈值时,则认定该分区发生数据倾斜。
在另一些实施例中,通过预置的记录大小阈值判断是否存在数据倾斜分区。当某个分区在所有Map的记录大小之和大于预置的记录大小阈值时,则认定该分区发生数据倾斜。
其中,记录数阈值和记录大小阈值可以根据分区配置来定义。当一个分区Shuffle写的记录数或者记录大小的其中一项大于配置值的时候,即认为这个分区倾斜,即当R(P)>RSkew or S(P)>SSkew时,认定该分区倾斜。其中R(P)表示分区记录数,S(P)表示分区记录大小,RSkew表示分区配置的记录数阈值,SSkew表示分区配置的记录大小阈值。
记录数阈值和记录大小阈值还可以根据分区数据值的中位数的方式来定义,这里不使用平均数是因为平均数会受分区的分布情况影响,当存在极大或者极小值时,平均数失去比较的意义。具体实现可设置参数定义中位数阈值Cthreshold,当R(P)>RMedian*(1+Cthreshold)or S(P)>SMedian*(1+Cthreshold),认定该分区倾斜。其中,RMedian、SMedia分别表示记录数和记录大小的中位数。
本申请实施例中提供的判断数据倾斜的方法,无需用户以任何方式感知倾斜,即能实现数据倾斜自动检测和数据倾斜分区的自动定位,也不会带来任何的性能损耗。
步骤S300,当存在数据倾斜分区时,对数据倾斜分区进行切分。
以下通过实施例,示例性地对步骤S300作进一步说明。
在一些实施例中,对数据倾斜分区进行切分可以根据数据倾斜分区在各个Map的数据量,以Map为单位将分区数据写入多个切分文件中,每个切分文件中的分区数据量小于预置阈值。
如图3A所示,假定P2分区为数据倾斜分区,并假定从Map1、Map2和Map3输出的P2分区数据相加后大于阈值,而Map1、Map2和Map3输出的各个P2分区数据均没有大于阈值,这时可以通过如下步骤对P2分区进行切分:
获取P2分区的每个Map的统计信息,设P2分区在Map1、Map2和Map3的记录数为:Rp{R(M1P2),R(M2P2),R(M3P2)},P2分区在Map1、Map2和Map3的记录大小为:Sp{S(M1P2),S(M2P2),S(M3P2)};
将Map1中P2分区的数据写入第一切分文件中;
判断R(M1P2)+R(M2P2)>记录数阈值,或者S(M1P2)+S(M2P2)>记录大小阈值是否成立,若有任一项成立,则生成新的切分文件,此处将新切分文件定义为第二切分文件,然后将Map2中P2分区的数据写入第二切分文件中;
判断R(M2P2)+R(M3P2)>记录数阈值,或者S(M2P2)+S(M3P2)>记录大小阈值是否成立,若两项均不成立,则将Map3中P2分区的数据写入第二切分文件中;
最后输出切分文件{M1P2,(M2P2,M3P2)},对应为P2分区的P2-1和P2-2两个子分区。
上述是一个简单且普遍适用于多数计算框架的逻辑,这种方式可以减小对于计算框架的改动,且实际应用中会有不错的效果。这种方式下需要调整计算框架,支持一个ReduceTask读取该Reduce的部分Map数据。上述步骤可以在Map端执行,更一般的说,可以在现有计算框架中增加起始Map、结束Map来实现。当然本实施例提供的技术方案也可以在Reduce端执行,本申请对此不作过多的限制。
然而在一些实施例中,可能存在某个分区单个Map的Shuffle数据就大于阈值的情况,这时单个Map的数据无法完全写入一个切分列表中。针对这种情况,可以通过另外两个变体实施例来解决,这两个变体实施例分别是在Map端和Reduce端执行。
例如,一个变体实施例中,可以在Map端将分区数据写入输出文件的过程中,当输出文件中某个分区的数据值大于预置阈值时,生成新的输出文件写入余下的分区数据。
示例性地,如图3B所示,当P2分区在Map1的数据量大于记录数阈值或者记录大小阈值时,则在Map1的shuffle阶段,P2分区数据在写入输出文件的过程中,当输出文件的数据值大于预置阈值时,生成新的输出文件,将P2分区余下的数据写入新的输出文件 中。
例如,另一变体实施例中,可以在Reduce端将抓取的分区数据写入输入文件时,当输入文件中的数据值大于预置阈值时,生成新的输入文件写入余下的分区数据。
示例性地,如图3C所示,当P2分区在Map1的数据量大于记录数阈值或者记录大小阈值,Reduce端抓取P2分区在Map1的数据写入输入文件时,当输入文件中的数据值大于预置阈值时,生成一个新的输入文件,将P2分区余下的数据写入新的输入文件中。
以上在Map端或在Reduce端执行的技术方案,均能达到将P2分区分成P2-1和P2-2两个子分区的目的。
步骤S400,根据切分后的分区,改写物理计划。
步骤S500,执行改写后的物理计划。
请参照图4,以下通过一个实施例来对步骤S400和步骤S500作进一步示例性说明。
如图4所示,A表和B表按照Key1进行Join操作;
假设表A的数据经过map函数形成两个分区A1、A2,表B的数据经过map函数形成两个分区B1、B2;
分区A1出现数据倾斜,则将分区A1切分为A1-1、A1-2两个子分区;
对原先的Join物理计划进行改写,生成新的以A1-1、A1-2与B1以及A2与B2子Join组成新的Union物理计划:
Join(A,B)=Union(
Join(A1-1,B1),
Join(A1-2,B1),
Join(A2,B2),
);
SQL引擎将Union翻译成计算框架的任务,提交给计算框架计算,计算完成返回整个Join操作的结果。
请参照图5,以下再通过一个实施例来对步骤S400和步骤S500作进一步示例性说明。
如图5所示,A表与B表按照Key1进行Join操作。
Join后生成的表T会按照Key2生成Shuffle数据;
假定T2分区所有Map的记录数:Rm1+Rm2+Rm3+Rm4+Rm5>RSkew,所以T2为倾斜分区;
T表与C表按照Key2进行Join操作,其中T按照Key2进行分区,本次Join按照Key2分成T1、T2、T3三个分区,T2分区倾斜,包含Map为{m1,m2,m3,m4,m5},C表的C1、C2、C3分区没有倾斜。
因为T表T2分区的记录数满足RT2>RSkew,所以需要对T2分区进行切分,T2分区会被切分为{T2m1+T2m2,T2m3,T2m4+T2m5}三个子分区。
SQL引擎根据分区切分,会将物理计划重新生成,优化后的物理计划为:
Join(T,C)=Union(
Join(T1,C1),
Join(T2m1+T2m2,C2),
Join(T2m3,C2),
Join(T2m4+T2m5,C2),
Join(T3,C3)
);
先执行改写后的物理计划中的各个子Join。
将相应所有子Join的结果执行Union操作,生成一个新的结果。
通过以上本示例性说明,可以看出本方法即使对于多次Join后的场景,也可以很好的满足,同样地,在其它的子查询或者计算后也可以普遍满足。因为本申请的技术方案是基于普遍的SQL理论来动态设计的,所以具有广泛的适用性。
第二方面,请参照图6,本申请实施例提供了一种分布式数据均衡处理装置100,该装置100可应用于SQL引擎中,该装置100包括:
shuffle统计获取模块110,用于获取shuffle统计数据,其中,所述shuffle统计数据包括shuffle阶段中各个分区的数据量;
倾斜判断模块120,用于根据shuffle统计数据,判断是否存在数据倾斜分区;
分区切分模块130,用于当存在数据倾斜分区时,对数据倾斜分区进行切分;
物理计划改写模块140,用于根据切分后的分区,改写物理计划;
物理计划执行模块150,用于执行改写后的物理计划。
所述shuffle统计获取模块110,具体用于:
在shuffle阶段每执行一条记录的写入操作,则更新对应分区的记录统计值;
根据记录统计值,获得各个分区的数据量。
所述倾斜判断模块120具体用于:
当某个分区在所有Map的记录数之和大于预置的记录数阈值时,认定该分区发生数据倾斜;或者当某个分区在所有Map的记录大小之和大于预置的记录大小阈值时,认定该分区发生数据倾斜。
所述分区切分模块130具体用于:
根据数据倾斜分区在各个Map的数据量,以Map为单位将分区数据写入多个切分文件中,每个切分文件中的分区数据量小于预置阈值。
在另一变体中,所述分区切分模块130具体用于:
在Map端将分区数据写入输出文件的过程中,当输出文件中某个分区的数据值大于预置阈值时,生成新的输出文件写入余下的分区数据;或者在Reduce端将抓取的分区数据写入输入文件的过程中,当输入文件中的数据值大于预置阈值时,生成新的输入文件写入 余下的分区数据。
本实施例提供的分布式数据均衡处理装置100,可执行上述第一方面提供的分布式数据均衡处理方法中各个实施例的技术方案,其实现原理和技术效果类似,其中各个模块的功能可以参考方法实施例中相应的描述,此处不再赘述。
第三方面,请参照图7,本申请实施例提供了一种计算终端200,包括处理器210、存储器220及存储在存储器220上并可在处理器210上运行的计算机程序,所述计算机程序时执行所述的分布式数据的均衡处理方法。
处理器210和存储器220可以通过总线或者其他方式连接。
存储器220作为一种非暂态计算机可读存储介质,可用于存储非暂态软件程序以及非暂态性计算机可执行程序,如本申请第一方面实施例中的分布式数据的均衡方法。处理器210通过运行存储在存储器220中的非暂态软件程序以及指令,从而实现上述第一方面实施例中的分布式数据的均衡方法。
存储器220可以包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需要的应用程序;存储数据区可存储执行上述第一方面实施例中的方法。此外,存储器220可以包括高速随机存取存储器,还可以包括非暂态存储器,例如至少一个磁盘存储器件、闪存器件、或其他非暂态固态存储器件。在一些实施方式中,存储器220可选包括相对于处理器210远程设置的存储器,这些远程存储器可以通过网络连接至该终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
实现上述第一方面实施例中的分布式数据的均衡方法所需的非暂态软件程序以及指令存储在存储器220中,当被一个或者多个处理器210执行时,执行上述第一方面实施例中的方法,例如执行图1中描述的方法步骤S100至S500,图2中描述的方法步骤S210至S220。
第四方面,本申请实施例提供了一种计算机可读存储介质,存储有计算机可执行指令,所述计算机可执行指令用于执行所述的分布式数据的均衡方法。
在一实施例中,该计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个或多个控制处理器210执行,例如,被第三方面实施例的计算终端中的一个处理器210执行,可使得上述一个或多个处理器210执行上述第一方面实施例中的分布式数据的均衡方法,例如,执行以上描述的图1中的方法步骤S100至S500,图2中的方法步骤S210至S220。
本申请实施例包括:获取shuffle统计数据;根据shuffle统计数据,判断是否存在数据倾斜分区;当存在数据倾斜分区时,对数据倾斜分区进行切分;根据切分后的分区,改写物理计划;执行改写后的物理计划。通过以上技术手段,能至少在一定程度上解决数据倾斜情况下导致性能大幅下降问题,实现分布式数据的均衡处理,提升分布式计算的运行速度。
当然,上述说明并非是对本申请的限制,本申请也并不仅限于上述举例,本技术领域的技术人员在本申请的实质范围内所做出的变化、改型、添加或替换,也应属于本申请的保护范围。

Claims (12)

  1. 分布式数据的均衡处理方法,包括:
    获取shuffle统计数据,其中,所述shuffle统计数据包括shuffle阶段中各个分区的数据量;
    根据shuffle统计数据,判断是否存在数据倾斜分区;
    当存在数据倾斜分区时,对数据倾斜分区进行切分;
    根据切分后的分区,改写物理计划;
    执行改写后的物理计划。
  2. 根据权利要求1所述的方法,其中,所述获取shuffle统计数据,包括:
    在shuffle阶段每执行一条记录的写入操作,则更新对应分区的记录统计值;
    根据记录统计值,获得各个分区的数据量。
  3. 根据权利要求1所述的方法,其中,
    所述根据shuffle统计数据,判断是否存在数据倾斜分区,包括:
    当某个分区在所有Map的记录数之和大于预置的记录数阈值时,认定该分区发生数据倾斜;
    或者
    当某个分区在所有Map的记录大小之和大于预置的记录大小阈值时,认定该分区发生数据倾斜。
  4. 根据权利要求1所述的方法,其中,所述当存在数据倾斜分区时,对数据倾斜分区进行切分,包括:
    根据数据倾斜分区在各个Map的数据量,以Map为单位将分区数据写入多个切分文件中,每个切分文件中的分区数据量小于预置阈值。
  5. 根据权利要求1所述的方法,其中,所述当存在数据倾斜分区时,对数据倾斜分区进行切分,包括:
    在Map端将分区数据写入输出文件的过程中,当输出文件中某个分区的数据值大于预置阈值时,生成新的输出文件写入余下的分区数据;
    或者
    在Reduce端将抓取的分区数据写入输入文件的过程中,当输入文件中的数据值大于预置阈值时,生成新的输入文件写入余下的分区数据。
  6. 分布式数据均衡处理装置,包括:
    shuffle统计获取模块,用于获取shuffle统计数据,其中,所述shuffle统计数据包括shuffle阶段中各个分区的数据量;
    倾斜判断模块,用于根据shuffle统计数据,判断是否存在数据倾斜分区;
    分区切分模块,用于当存在数据倾斜分区时,对数据倾斜分区进行切分;
    物理计划改写模块,用于根据切分后的分区,用于改写物理计划;
    物理计划执行模块,用于执行改写后的物理计划。
  7. 根据权利要求6所述的装置,其中,所述shuffle统计获取模块具体用于:
    在shuffle阶段每执行一条记录的写入操作,则更新对应分区的记录统计值;
    根据记录统计值,获得各个分区的数据量。
  8. 根据权利要求6所述的装置,其中,所述倾斜判断模块具体用于:
    当某个分区在所有Map的记录数之和大于预置的记录数阈值时,认定该分区发生数据倾斜;
    或者
    当某个分区在所有Map的记录大小之和大于预置的记录大小阈值时,认定该分区发生数据倾斜。
  9. 根据权利要求6所述的装置,其中,所述分区切分模块具体用于:
    根据数据倾斜分区在各个Map的数据量,以Map为单位将分区数据写入多个切分文件中,每个切分文件中的分区数据量小于预置阈值。
  10. 根据权利要求6所述的装置,其中,所述分区切分模块具体用于:
    在Map端将分区数据写入输出文件的过程中,当输出文件中某个分区的数据值大于预置阈值时,生成新的输出文件写入余下的分区数据;
    或者
    在Reduce端将抓取的分区数据写入输入文件的过程中,当输入文件中的数据值大于预置阈值时,生成新的输入文件写入余下的分区数据。
  11. 计算终端,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,其中,所述计算机程序时执行权利要求1-5任一所述的方法。
  12. 计算机可读存储介质,存储有计算机可执行指令,其中,所述计算机可执行指令用于执行权利要求1-5任一所述的方法。
PCT/CN2020/112877 2019-09-18 2020-09-01 分布式数据的均衡处理方法、装置、计算终端和存储介质 WO2021052169A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910882725.0A CN110673794B (zh) 2019-09-18 2019-09-18 分布式数据的均衡处理方法、装置、计算终端和存储介质
CN201910882725.0 2019-09-18

Publications (1)

Publication Number Publication Date
WO2021052169A1 true WO2021052169A1 (zh) 2021-03-25

Family

ID=69076785

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/112877 WO2021052169A1 (zh) 2019-09-18 2020-09-01 分布式数据的均衡处理方法、装置、计算终端和存储介质

Country Status (2)

Country Link
CN (1) CN110673794B (zh)
WO (1) WO2021052169A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238993A (zh) * 2021-05-14 2021-08-10 中国人民银行数字货币研究所 一种数据处理方法和装置
CN116561171A (zh) * 2023-07-10 2023-08-08 浙江邦盛科技股份有限公司 一种倾斜数据双时序分布处理方法、装置、设备及介质

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110673794B (zh) * 2019-09-18 2021-12-17 中兴通讯股份有限公司 分布式数据的均衡处理方法、装置、计算终端和存储介质
CN111538459B (zh) * 2020-04-16 2023-07-21 北京奇艺世纪科技有限公司 数据倾斜的确定方法、装置、电子设备及可读存储介质
CN112905628B (zh) * 2021-03-26 2024-01-02 第四范式(北京)技术有限公司 数据处理方法及装置
CN113407354B (zh) * 2021-08-18 2022-01-21 阿里云计算有限公司 分布式作业调整方法、主节点、系统、物理机及存储介质
CN113821541A (zh) * 2021-09-27 2021-12-21 北京沃东天骏信息技术有限公司 数据倾斜处理方法、设备、存储介质及程序产品

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106202364A (zh) * 2016-07-07 2016-12-07 华南理工大学 面向MapReduce的XML数据划分优化方法及其系统
US20160364273A1 (en) * 2014-02-27 2016-12-15 Huawei Technologies Co., Ltd. Data Processing Apparatus and Method for Processing Serial Tasks
CN108196970A (zh) * 2017-12-29 2018-06-22 东软集团股份有限公司 Spark平台的内存动态管理方法和装置
CN108595268A (zh) * 2018-04-24 2018-09-28 咪咕文化科技有限公司 一种基于MapReduce的数据分配方法、装置及计算机可读存储介质
CN110069502A (zh) * 2019-04-24 2019-07-30 东南大学 基于Spark架构的数据均衡分区方法及计算机存储介质
CN110673794A (zh) * 2019-09-18 2020-01-10 中兴通讯股份有限公司 分布式数据的均衡处理方法、装置、计算终端和存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101908075A (zh) * 2010-08-17 2010-12-08 上海云数信息科技有限公司 基于sql的并行计算系统及方法
CN105930479A (zh) * 2016-04-28 2016-09-07 乐视控股(北京)有限公司 一种数据倾斜处理方法及装置
CN106250233B (zh) * 2016-07-21 2020-03-27 浙江清华长三角研究院 MapReduce性能优化系统及优化方法
CN107220123A (zh) * 2017-05-25 2017-09-29 郑州云海信息技术有限公司 一种解决Spark数据倾斜方法及系统
CN107562542B (zh) * 2017-09-06 2020-04-07 腾讯科技(深圳)有限公司 分布式数据处理系统数据分区方法及装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160364273A1 (en) * 2014-02-27 2016-12-15 Huawei Technologies Co., Ltd. Data Processing Apparatus and Method for Processing Serial Tasks
CN106202364A (zh) * 2016-07-07 2016-12-07 华南理工大学 面向MapReduce的XML数据划分优化方法及其系统
CN108196970A (zh) * 2017-12-29 2018-06-22 东软集团股份有限公司 Spark平台的内存动态管理方法和装置
CN108595268A (zh) * 2018-04-24 2018-09-28 咪咕文化科技有限公司 一种基于MapReduce的数据分配方法、装置及计算机可读存储介质
CN110069502A (zh) * 2019-04-24 2019-07-30 东南大学 基于Spark架构的数据均衡分区方法及计算机存储介质
CN110673794A (zh) * 2019-09-18 2020-01-10 中兴通讯股份有限公司 分布式数据的均衡处理方法、装置、计算终端和存储介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113238993A (zh) * 2021-05-14 2021-08-10 中国人民银行数字货币研究所 一种数据处理方法和装置
CN113238993B (zh) * 2021-05-14 2023-12-05 中国人民银行数字货币研究所 一种数据处理方法和装置
CN116561171A (zh) * 2023-07-10 2023-08-08 浙江邦盛科技股份有限公司 一种倾斜数据双时序分布处理方法、装置、设备及介质
CN116561171B (zh) * 2023-07-10 2023-09-15 浙江邦盛科技股份有限公司 一种倾斜数据双时序分布处理方法、装置、设备及介质

Also Published As

Publication number Publication date
CN110673794B (zh) 2021-12-17
CN110673794A (zh) 2020-01-10

Similar Documents

Publication Publication Date Title
WO2021052169A1 (zh) 分布式数据的均衡处理方法、装置、计算终端和存储介质
US11868315B2 (en) Method for splitting region in distributed database, region node, and system
TWI549060B (zh) Access methods and devices for virtual machine data
US20170286484A1 (en) Graph Data Search Method and Apparatus
CN107493327B (zh) 分布式缓存管理方法、系统及数据管理系统
US10831612B2 (en) Primary node-standby node data transmission method, control node, and database system
CN108363621B (zh) numa架构下的报文转发方法、装置、存储介质及电子设备
WO2017143957A1 (zh) 一种数据重分布的方法及装置
WO2020042813A1 (zh) 一种分布式数据连接处理方法、装置、设备及存储介质
TWI746511B (zh) 資料表連接方法及裝置
US20200364080A1 (en) Interrupt processing method and apparatus and server
CN112887437A (zh) 区块链交易处理方法、区块链节点和区块链
WO2023124945A1 (zh) 多方数据处理方法、系统、电子装置和存储介质
WO2021259217A1 (zh) 数据的关联查询方法、装置、设备及存储介质
CN110704438B (zh) 一种区块链中布隆过滤器的生成方法及装置
WO2014153940A1 (zh) 处理数据库重做数据的方法和装置
CN107181636B (zh) 一种负载均衡系统中的健康检查方法及装置
US10496616B2 (en) Log fragmentation method and apparatus
US20240061712A1 (en) Method, apparatus, and system for creating training task on ai training platform, and medium
WO2022048358A1 (zh) 数据处理方法、装置及存储介质
CN107220069B (zh) 一种针对非易失性内存的Shuffle方法
WO2024041376A1 (zh) 分布式图数据处理系统、方法、装置、设备及存储介质
WO2021226822A1 (zh) 日志写入方法、装置、电子设备以及存储介质
WO2016175880A1 (en) Merging incoming data in a database
CN111274616A (zh) 基于Ceph对象存储整体上传分段校验的实现方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20864494

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20864494

Country of ref document: EP

Kind code of ref document: A1