Data de-tilting method, device, electronic device and storage medium
By breaking up tasks with large amounts of data in batch data and dynamically allocating tasks, the problem of unbalanced data volume of computing node tasks is solved, and the optimal allocation of resources and the improvement of computing speed are achieved.
Patent Information
- Application Number
- CN202010777924.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-08-05
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-08-05
AI Technical Summary
In batch data processing, due to insufficient dispersion of task data, the amount of task data on computing nodes is unbalanced, resulting in single-point computing problems, slowing down the computing rate and prolonging the overall computing time.
By breaking up the tasks with large data volume in the batch data, dynamically allocate the number of tasks according to the data volume of the data subset and the total data volume, and allocate the tasks to multiple computing nodes to ensure that the task volume of each node is balanced. To achieve data deskew.
It achieves optimal allocation of computing resources, avoids single-point computing problems, shortens the overall computing time, makes full use of equipment resources, and increases the computing rate.
Smart Images

Figure CN114064260B
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of resource optimization, and in particular, relates to a data de-tilting method, device, electronic device and storage medium. Background Art
[0002] Data skew refers to the situation in which, during the task allocation and execution of batch data, the task data is not dispersed enough and the amount of task data corresponding to different computing nodes is unbalanced. One (some) computing nodes have a huge amount of task data and need to bear tremendous pressure, while another (some) computing nodes have a smaller amount of task data.
[0003] Computing nodes with large amounts of task data usually take longer to complete task processing, and other nodes have to wait for nodes that have not completed tasks after processing them, which leads to single-point computing problems, slowing down the overall task computing rate of each computing node and extending the overall computing time of the task. Therefore, providing a data de-skew implementation solution to avoid the above-mentioned single-point computing problem, correspondingly improve the overall computing rate of each computing node in batch data processing scenarios, and shorten the overall computing time is a topic worth studying in this field. Summary of the invention
[0004] In view of this, the present application provides a data de-skew method, device, electronic device and storage medium, which optimizes the allocation of node resources for different tasks by breaking up tasks with relatively large data volumes in batch data to avoid the above-mentioned single-point computing problem.
[0005] The specific technical solutions are as follows:
[0006] A data de-skew method, comprising:
[0007] Get the keys of the batch data to be processed;
[0008] Determine corresponding data subsets corresponding to different keys in the data set of the batch data;
[0009] Determine the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number;
[0010] If the number of tasks corresponding to the key is 1, the data subset corresponding to the key is assigned to a task assigned to the key; if the number of tasks corresponding to the key is greater than 1, each piece of data in the data subset corresponding to the key is dispersed into different tasks of the corresponding number of tasks assigned to the key;
[0011] Allocate each task corresponding to each key to multiple computing nodes;
[0012] Among them, the difference in the number of tasks assigned to different computing nodes is less than a threshold, the data corresponding to the same computing node are executed serially, and different computing nodes execute the respectively assigned tasks in parallel.
[0013] Optionally, determining the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set, and the total number of tasks set for the data set includes:
[0014] Determine a corresponding weight for the key according to the data volume of the data subset corresponding to the key and the total data volume of the data set;
[0015] Based on the weight corresponding to the key and the total number of tasks assigned to the data set, the number of tasks to be assigned to the data subset corresponding to the key is determined.
[0016] Optionally, determining the number of tasks to be allocated to the data subset corresponding to the key based on the weight corresponding to the key and the total number of tasks allocated to the data set includes:
[0017] Use the following formula to calculate the number of tasks that need to be assigned to the data subset corresponding to the key:
[0018]
[0019] in:
[0020] N represents the total number of tasks assigned to the dataset;
[0021] D i Indicates the amount of data in the data subset corresponding to the key;
[0022] D represents the total data volume of the data set;
[0023] Indicates the weight corresponding to the key;
[0024] N i Indicates the number of tasks assigned to the data subset corresponding to the key.
[0025] Optionally, if the number of tasks corresponding to the key is greater than 1, each piece of data in the data subset corresponding to the key is dispersed into different tasks of the corresponding number of tasks assigned to the key, including:
[0026] Based on a random variable whose number of values is equal to the number of tasks, a random number is added to the key of each piece of data in the data subset corresponding to the key, to obtain subkeys whose number corresponding to the key is the number of tasks, wherein the subkey is a combination of the key and the added random number;
[0027] Determine the data corresponding to each subkey in the data subset;
[0028] The data corresponding to each subkey in the data subset are allocated one-to-one to different tasks of the number of tasks assigned to the key.
[0029] Optionally, after allocating each task corresponding to each key to multiple computing nodes, the method further includes:
[0030] For keys whose corresponding task number is greater than 1, the task processing results of each task of the key are aggregated to obtain the task processing result corresponding to the key;
[0031] The task processing results of each key are integrated to obtain the data processing result of the batch data.
[0032] Optionally, for a key whose corresponding task number is greater than 1, performing aggregating processing on the task processing results of each task of the key includes:
[0033] Stripping random numbers from subkeys included in each task processing result of the key, so that each subkey included in each task processing result is restored to the key;
[0034] Aggregate the processing results of each task based on the key.
[0035] A data de-tilting device, comprising:
[0036] An acquisition unit, used for obtaining each key of the batch data to be processed;
[0037] A first determining unit, configured to determine corresponding data subsets corresponding to different keys in a data set of the batch data;
[0038] A second determining unit is used to determine the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number;
[0039] The task data configuration unit is used to configure the data subset corresponding to the key to a task assigned to the key when the number of tasks corresponding to the key is 1; when the number of tasks corresponding to the key is greater than 1, disperse each piece of data in the data subset corresponding to the key to different tasks of the corresponding number of tasks assigned to the key;
[0040] A task allocation unit, used to allocate each task corresponding to each key to multiple computing nodes;
[0041] Among them, the difference in the number of tasks assigned to different resource nodes is less than a threshold, the data corresponding to the same computing node are executed serially, and different resource nodes execute the respectively assigned tasks in parallel.
[0042] Optionally, the second determining unit is specifically configured to:
[0043] Determine a corresponding weight for the key according to the data volume of the data subset corresponding to the key and the total data volume of the data set;
[0044] Based on the weight corresponding to the key and the total number of tasks assigned to the data set, the number of tasks to be assigned to the data subset corresponding to the key is determined.
[0045] Optionally, the second determining unit determines the number of tasks to be allocated to the data subset corresponding to the key based on the weight corresponding to the key and the total number of tasks allocated to the data set, specifically including:
[0046] Use the following formula to calculate the number of tasks that need to be assigned to the data subset corresponding to the key:
[0047]
[0048] in:
[0049] N represents the total number of tasks assigned to the dataset;
[0050] D i Indicates the amount of data in the data subset corresponding to the key;
[0051] D represents the total data volume of the data set;
[0052] Indicates the weight corresponding to the key;
[0053] N i Indicates the number of tasks assigned to the data subset corresponding to the key.
[0054] Optionally, when the number of tasks corresponding to the key is greater than 1, the task data configuration unit disperses each piece of data in the data subset corresponding to the key into different tasks of the corresponding number of tasks allocated to the key, including:
[0055] Based on a random variable whose number of values is equal to the number of tasks, a random number is added to the key of each piece of data in the data subset corresponding to the key, to obtain subkeys whose number corresponding to the key is the number of tasks, wherein the subkey is a combination of the key and the added random number;
[0056] Determine the data corresponding to each subkey in the data subset;
[0057] The data corresponding to each subkey in the data subset are allocated one-to-one to different tasks of the number of tasks assigned to the key.
[0058] Optionally, also include:
[0059] Integrated unit for:
[0060] For keys whose corresponding task number is greater than 1, the task processing results of each task of the key are aggregated to obtain the task processing result corresponding to the key;
[0061] The task processing results of each key are integrated to obtain the data processing result of the batch data.
[0062] Optionally, the integration unit aggregates the task processing results of each task of a key whose corresponding task number is greater than 1, including:
[0063] Stripping random numbers from subkeys included in each task processing result of the key, so that each subkey included in each task processing result is restored to the key;
[0064] Aggregate the processing results of each task based on the key.
[0065] An electronic device, comprising:
[0066] Memory, used to store computer instruction sets;
[0067] A processor is used to implement the data de-tilting method as described in any one of the above items by executing an instruction set stored in the memory.
[0068] A computer-readable storage medium stores a computer instruction set, wherein the computer instruction set, when executed by a processor, implements the data de-tilting method as described in any one of the above items.
[0069] The data de-skew method, device, electronic device and storage medium provided in the embodiments of the present application break up the data subsets corresponding to keys with relatively large data volumes, break them up into different tasks, and finally distribute the different tasks corresponding to different keys of the batch data to multiple computing nodes in a relatively balanced manner for execution, thereby realizing task configuration (such as configuring as one task, or breaking it up into multiple tasks) and adaptation of computing resources for the data corresponding to the key based on the data volume. In other words, since the data with large data volumes corresponding to the keys are broken up, there are no longer tasks with large data volumes, and the processing volume of the tasks assigned to each computing node is relatively balanced, thereby realizing data de-skew, making full use of the resources of the device for data calculation, reducing the calculation time of the overall task of batch data, and avoiding the single-point calculation problem caused by data skew. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0071] Figure 1 This is a flow chart of a data de-tilting method provided in an embodiment of the present application;
[0072] Figure 2 It is a schematic diagram of breaking up the data corresponding to the same key into different tasks provided by an embodiment of the present application;
[0073] Figure 3 is another flow chart of the data de-tilting method provided in an embodiment of the present application;
[0074] Figure 4 is a structural schematic diagram of a data de-tilting device provided in an embodiment of the present application;
[0075] Figure 5 is another structural schematic diagram of the data de-tilting device provided in an embodiment of the present application;
[0076] Figure 6 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0077] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0078] Traditional technologies solve the single-point computing problem caused by data skew in the following two ways:
[0079] 1. Increase the reduce jvm (Java Virtual Machine) memory on the device to optimize data skew (i.e., use the increased jvm memory to assist in processing computing nodes with large task processing volumes); however, this processing method has corresponding limitations, such as memory limitations (limited by the available memory resources), and may also have an unstable impact on the running of tasks on other nodes in the cluster or the same physical machine. For example, when an OOM (memory overflow) exception occurs in a computing node with a large data processing volume, part of the data processing tasks of the node will be transferred to other nodes, which may affect the stability of tasks running on other nodes.
[0080] Second, optimize data skew by performing two-stage mapreduce. In this implementation, for the batch data to be processed, in the map stage, the data of the key with a large data volume is scattered into a fixed number of tasks. That is, this method is to artificially set the number of tasks for the key with a large data volume in the batch data, which is relatively limited. The use of device resources is still insufficient and not optimized. Accordingly, the processing speed of the overall task of the batch data cannot reach the optimal level.
[0081] In order to solve the above-mentioned problems existing in traditional technologies, the present application provides a data de-skew method, device, electronic device and storage medium, which can be applied to scenarios where multi-tasking and multi-node operations are performed on batch data based on a server cluster or a single physical machine. The data de-skew method, device, electronic device and storage medium of the present application will be described in detail through multiple embodiments below.
[0082] First, the data de-skew method provided by the embodiment of the present application is introduced. The method can be specifically applied to a server in a server cluster or a separately set physical machine (such as a personal PC or a server). Figure 1 , the method may include the following processing steps:
[0083] Step 101: Obtain each key of the batch data to be processed.
[0084] The batch data to be processed may specifically be batch data records to be processed, such as batch data records in a database.
[0085] Databases usually organize data records in the form of key-value. Each key of batch data refers to the "key" in the key-value data structure form, which can be the primary key of the data record, or non-primary keys such as superkey, candidate key, foreign key, etc. For the various types of keys of data records, please refer to the relevant definitions or descriptions of the prior art, which will not be repeated here.
[0086] For the batch data to be processed, the corresponding keys can be determined first. For example, for the batch student information data, the corresponding keys can include but are not limited to "name", "height", "school / department", etc.
[0087] Step 102: Determine corresponding data subsets corresponding to different keys in the data set of the batch data.
[0088] In multi-task, multi-node running scenarios for batch data, data is usually divided into tasks based on the data key, and the data of the same task will be assigned to the same computing node for execution (that is, the data of the same task will not be executed across nodes). For example, in traditional technology, the data subset corresponding to the same key in the batch data set is generally divided into a task, and the data of a task is assigned to a computing node (such as a thread or process) for execution (of course, for tasks with larger data volumes, the processing capacity of the node is correspondingly larger, the running time is also longer, and the corresponding single-point computing problem will occur).
[0089] In the embodiment of the present application, the batch data is also divided into tasks based on the data keys. Specifically, after obtaining the keys of the batch data to be processed, the corresponding data subsets corresponding to different keys in the data set of the batch data are first determined.
[0090] For example, in a batch of student information data, determine the data subset corresponding to the key "name", the data subset corresponding to the key "height", and the data subset corresponding to the key "school / department", etc.
[0091] Step 103: Determine the number of tasks to be allocated to the data subset corresponding to the key based on the data volume of the data subset corresponding to the key, the total data volume of the data set, and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number.
[0092] Specifically, a corresponding weight can be determined for each key based on the data volume of the data subset corresponding to each key in at least some of the keys (such as the keys of the batch data) and the total data volume of the data set of the batch data; and further based on the weight corresponding to each key and the total number of tasks allocated to the data set of the batch data, the number of tasks to be allocated to the data subset corresponding to the key is determined.
[0093] In implementation, the process of assigning a weight to each key and then determining the number of tasks to be assigned to the data subset corresponding to the key can be as follows:
[0094] For the batch data to be processed, assuming that the number of keys corresponding to it is n (such as "name", "height", "school / department", etc.), after using the key to divide the batch data set D, n branches corresponding to different keys will be generated. The data subset D of any branch i Contains all attributes in the batch data as key i (i.e. the data record of the i-th key).
[0095] Considering that the amount of data contained in the data subsets in the branches corresponding to different keys is different, the total number of batch data sets D and the number of data corresponding to different keys can be counted. i The data subset D i Based on the calculation formula Assign a weight coefficient to the key;
[0096] Among them, D i represents the amount of data in the data subset corresponding to the key; D represents the total amount of data in the data set.
[0097] After that, we can further calculate the key according to the following formula: i The corresponding data subset D i Number of tasks assigned:
[0098]
[0099] Where N is the total number of tasks pre-set for batch data, Express Round down, N i Indicates the number of tasks to be assigned to the data subset corresponding to the key. Rounding down instead of rounding up can ensure that the sum of the number of tasks assigned to each key does not exceed the total number of tasks set for the batch task, which can ensure that the resource allocation of the overall batch data task will not exceed the limit.
[0100] As described above, in a multi-task, multi-node operation scenario for batch data, the data is divided into tasks based on the key of the data, and the data of the same task will be assigned to the same computing node for execution. When a key has a large amount of data relative to other keys, it will take a very long time to calculate the data of the key, and since the total processing time of the overall task of the batch data is the same as the processing time of the longest running task, this will cause the processing efficiency of the overall task of the batch data to be very low, resulting in a single point computing problem, with a high risk of data accumulation. In this embodiment, a weight coefficient is assigned to the data subset corresponding to the key based on the data volume, and combined with the total number of tasks assigned to the batch data and the weight coefficient of the key, a reasonable number of tasks (rather than only one task) is dynamically assigned to the data subset of the key, so as to provide support for breaking up the data of the corresponding key with a larger data volume into different tasks and avoiding the occurrence of tasks with a larger data volume.
[0101] Step 104: If the number of tasks corresponding to the key is 1, configure the data subset corresponding to the key to a task assigned to the key; if the number of tasks corresponding to the key is greater than 1, disperse each piece of data in the data subset corresponding to the key to different tasks of the corresponding number of tasks assigned to the key.
[0102] Among them, if based on the above weight method, it is determined that the number of tasks to be assigned to a key is 1, that is, N i =1, indicating that the amount of data in the data subset corresponding to the key is small and can be completed in a short time. Accordingly, the data in the data subset corresponding to the key can be directly assigned to a task.
[0103] On the contrary, if it is determined that the number of tasks to be assigned to a key is greater than 1, that is, N i ≥2, indicating that the amount of data in the data subset corresponding to the key is large, and thus it needs to be scattered so that different data in the data subset corresponding to the key are scattered into different tasks of the corresponding number of tasks determined for the key.
[0104] Easy to understand, N i The value of is a natural number greater than or equal to 1.
[0105] Still taking the above student information as an example, assuming that the amount of data in the data subset corresponding to "name" is large, and based on the above weight method, it is determined that the number of tasks to be assigned to the key "name" is 3, then the data in the data set corresponding to "name" can be scattered and configured into 3 tasks.
[0106] On a key i The corresponding number of tasks N i ≥2, the corresponding key i The corresponding data subset D iWhen the data in is scattered, preferably, the data subset D i The data in is relatively evenly scattered into N i In different tasks, that is, the amount of data configured for each task is made as equal as possible, so that they have a relatively balanced processing capacity.
[0107] In order to achieve this goal, in this embodiment, D i The key of the data i Add a random variable r, where r will appear randomly N times i (That is, it needs to be key i The number of assigned tasks) has different values, and the number of r is N i The different values of can be arbitrary and not limited. Optionally, the different values of r (the number is N) i ) can be specifically [0, N i -1], so that by adding random variables r, it can finally be realized as a data subset D i The key of each data in i Add a random number and get the key accordingly i The corresponding number is N i Each subkey of the key i The combination of the random number added, that is, subkey = key i + Random numbers.
[0108] On this basis, the key can be i The corresponding data subset D i Further division is performed to obtain a number N i Each subkey in each subkey of the data subset D i The corresponding data in .
[0109] Afterwards, if Figure 2 As shown, the number is N i The subkeys of i The corresponding data in the key is assigned one-to-one to the key in units of subkeys. i The number of allocations is N i In different tasks, the data of keys with larger data volumes can be scattered into different tasks, thus avoiding the emergence of tasks with larger data volumes. This can provide technical support for avoiding single-point computing problems. Figure 2 random1-randomN in i N i Random numbers, Task 1-Task N i N itask.
[0110] Step 105: Allocate each task corresponding to each key to multiple computing nodes.
[0111] In this embodiment, based on the above processing process, the data subsets with larger data volumes corresponding to each key are broken up and multiple tasks with relatively balanced data volumes are obtained. Finally, each task corresponding to each key (one key may correspond to one task, or multiple tasks) is assigned to multiple computing nodes, wherein the difference in the number of tasks assigned to different computing nodes is less than a threshold, illustratively, such as less than 2, to ensure the balance of the amount of tasks assigned to each computing node.
[0112] Each piece of data corresponding to the same task is executed serially, and each piece of data corresponding to the same computing node (which may be data of the same task or different tasks) is executed serially, and different computing nodes can execute respectively assigned tasks in parallel.
[0113] Optionally, a computing node may be a process or a thread, but is not limited thereto. Different computing nodes may be different processes or threads provided by different servers in a cluster or the same server, or may be different processes or threads provided by a separately configured physical machine.
[0114] In implementation, the task scale usually has a corresponding relationship with the computing resources. For example, it can be set based on a predetermined task scale (which can be characterized by the amount of data corresponding to the task) to assign one task to one computing node, or to assign multiple tasks to one computing node, etc. Optionally, one task can be assigned to one computing node, that is, one computing node only runs one task.
[0115] It is easy to understand that under this implementation, when the total number of assigned tasks is set for batch data, it is equivalent to limiting the total available computing nodes for the batch data, and further, it is equivalent to limiting the total available computing resources for the batch data. Based on the above-mentioned processing process of the embodiment of the present application, by breaking up the data of the keys with larger data volumes in the batch data, the data is broken up into multiple tasks with a number that matches the data volumes, thereby achieving dynamic adaptation of computing resources that match the data volumes of the keys with larger data volumes from the total available computing resources, and correspondingly achieving different reasonable computing resources that are adapted to different keys with different data volumes, thereby achieving optimal allocation of available device resources and computing rates during data de-tilting, making full use of device resources for data calculation, reducing the computing time of the overall task of batch data, and avoiding single-point computing problems caused by data skew.
[0116] At the same time, compared with the above two implementation methods of traditional technology, the implementation method of the embodiment of the present application can dynamically and reasonably allocate computing resources for the key based on the total available computing resources and the amount of data corresponding to the key, so there is no memory limitation, and will not cause unstable impact on the operation of other tasks in the cluster or the same physical machine due to problems such as memory overflow; and because the present application dynamically allocates a reasonable number of tasks to the key according to the actual data amount corresponding to the key, the total data amount of batch data and the total number of tasks, it simultaneously solves the problem of insufficient and insufficient optimization of device resources in the traditional technology based on the two-stage MapReduce optimization data tilting method, and realizes the optimal allocation of device available resources and computing rate in the process of data de-tilting.
[0117] In an alternative embodiment, see Figure 3 The data de-tilting method disclosed in the present application may further include the following processing steps after step 105:
[0118] Step 106: For a key whose corresponding task number is greater than 1, aggregate the task processing results of each task of the key to obtain the task processing result corresponding to the key.
[0119] The task processing result of the task corresponding to each key / sub-key at least includes the key / sub-key and processing result information.
[0120] For keys whose corresponding task number is greater than 1, the above-mentioned scattering process can realize that the data in the data subset is scattered into multiple different tasks according to the subkeys for separate processing. However, from a logical point of view, the data subset corresponding to the same key should belong to the same task and should have a unified processing result corresponding to the key. Therefore, for keys whose corresponding task number is greater than 1, after obtaining the task processing results corresponding to each subkey / task, the task processing results of each subkey / task can be further aggregated to obtain a unified task processing result corresponding to the key.
[0121] The aggregation process may include:
[0122] Stripping the random numbers in the subkeys included in each task processing result of the key, so that each subkey included in each task processing result is restored to the key (that is, the original key corresponding to the subkey);
[0123] Aggregate the processing results of each task based on the key.
[0124] After stripping the random numbers in the subkeys and restoring them to the corresponding original keys, the aggregation of the processing results of each task can depend on the actual processing logic of the data subset corresponding to the key. Specifically, for example, the data results of the tasks corresponding to each subkey / task can be added or subtracted, or the result records corresponding to each subkey / task can be simply integrated into one document, etc.
[0125] The following examples illustrate this.
[0126] For the calculation of (1+1+1+2+2+3+3+3+3)=19, based on the above-mentioned scattering processing process, the various data to be calculated can be scattered into three tasks. Assuming that the calculation process assigned to each task is as follows: (1+1+1), (2+2), (3+3+3+3), and they are assigned to 3 threads for calculation, then after obtaining the task calculation results of each thread such as 3, 4, and 12, the task calculation results of each thread can be further accumulated (i.e., aggregation processing), and finally the processing result of 19 is obtained.
[0127] It can be understood that the actual application scenario will not be the simple processing described above. This example is only provided to illustrate the principle of this embodiment, but is not used as an actual application example in the application scenario.
[0128] Step 107: Integrate the task processing results of each key to obtain the data processing result of the batch data.
[0129] Finally, the task processing results corresponding to each key can be integrated to obtain the data processing results of the batch data. The integration processing here can be determined according to the actual processing logic of the batch data. For example, the data can be classified and stored or processed according to different combinations of the processing results of each key, and there is no limitation on this.
[0130] To summarize, the embodiment of the present application breaks up the data subsets corresponding to keys with relatively large data volumes, breaks them up into different tasks, and finally distributes the different tasks corresponding to different keys of the batch data to multiple computing nodes in a relatively balanced manner for execution, thereby achieving task configuration (such as configuring as one task, or breaking it up into multiple tasks) and computing resource adaptation based on the data volume corresponding to the key. To put it another way, since the data with large data volumes corresponding to the keys are broken up, there are no longer tasks with large data volumes, and the processing volume of the tasks assigned to each computing node is relatively balanced, thereby achieving data de-skewness, making full use of the resources of the device for data calculation, reducing the calculation time of the overall batch data task, and avoiding single-point calculation problems caused by data skew.
[0131] Corresponding to the above-mentioned data de-tilting method, the present application also discloses a data de-tilting device, such as Figure 4 As shown, the data de-tilting device comprises:
[0132] An acquisition unit 401 is used to obtain each key of the batch data to be processed;
[0133] A first determining unit 402 is used to determine corresponding data subsets corresponding to different keys in the data set of the batch data;
[0134] The second determining unit 403 is used to determine the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number;
[0135] The task data configuration unit 404 is used to configure the data subset corresponding to the key to a task assigned to the key when the number of tasks corresponding to the key is 1; when the number of tasks corresponding to the key is greater than 1, disperse each piece of data in the data subset corresponding to the key to different tasks of the corresponding number of tasks assigned to the key;
[0136] A task allocation unit 405 is used to allocate each task corresponding to each key to multiple computing nodes;
[0137] Among them, the difference in the number of tasks assigned to different computing nodes is less than a threshold, the data corresponding to the same resource node are executed serially, and different resource nodes execute the respectively assigned tasks in parallel.
[0138] In an optional implementation manner of the embodiment of the present application, the second determining unit 403 is specifically configured to:
[0139] Determine a corresponding weight for the key according to the data volume of the data subset corresponding to the key and the total data volume of the data set;
[0140] Based on the weight corresponding to the key and the total number of tasks assigned to the data set, the number of tasks to be assigned to the data subset corresponding to the key is determined.
[0141] In an optional implementation of the embodiment of the present application, the second determining unit 403 determines the number of tasks to be allocated to the data subset corresponding to the key based on the weight corresponding to the key and the total number of tasks allocated to the data set, specifically including:
[0142] Use the following formula to calculate the number of tasks that need to be assigned to the data subset corresponding to the key:
[0143]
[0144] in:
[0145] N represents the total number of tasks assigned to the dataset;
[0146] D i Indicates the amount of data in the data subset corresponding to the key;
[0147] D represents the total data volume of the data set;
[0148] Indicates the weight corresponding to the key;
[0149] N i Indicates the number of tasks assigned to the data subset corresponding to the key.
[0150] In an optional implementation of the embodiment of the present application, when the number of tasks corresponding to the key is greater than 1, the task data configuration unit 404 distributes each piece of data in the data subset corresponding to the key to different tasks of the corresponding number of tasks assigned to the key, including:
[0151] Based on a random variable whose number of values is equal to the number of tasks, a random number is added to the key of each piece of data in the data subset corresponding to the key, to obtain subkeys whose number corresponding to the key is the number of tasks, wherein the subkey is a combination of the key and the added random number;
[0152] Determine the data corresponding to each subkey in the data subset;
[0153] The data corresponding to each subkey in the data subset are allocated one-to-one to different tasks of the number of tasks assigned to the key.
[0154] In an optional implementation of the present application, see Figure 5 The data de-tilting device may further include: an integration unit 406, configured to:
[0155] For keys whose corresponding task number is greater than 1, the task processing results of each task of the key are aggregated to obtain the task processing result corresponding to the key;
[0156] Integrate the task processing results of each key to obtain the data processing results of the batch data
[0157] In an optional implementation of the embodiment of the present application, the integration unit 406 aggregates the task processing results of each task of the key whose corresponding task number is greater than 1, including:
[0158] Stripping random numbers from subkeys included in each task processing result of the key, so that each subkey included in each task processing result is restored to the key;
[0159] Aggregate the processing results of each task based on the key.
[0160] As for the data de-tilting device disclosed in the embodiment of the present application, since it corresponds to the data de-tilting method disclosed in the above embodiments, the description is relatively simple. For relevant similarities, please refer to the description of the data de-tilting method part in the above embodiments, which will not be described in detail here.
[0161] In addition, an embodiment of the present application further discloses an electronic device, which may be, but is not limited to, a server in a server cluster or a separately set physical machine (such as a personal PC or a server), and is not limited here.
[0162] like Figure 6 As shown, the electronic device at least includes:
[0163] Memory 601, used for storing computer instruction sets;
[0164] Among them, the computer instruction set can be specifically implemented in the form of a computer program.
[0165] The memory 601 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0166] The processor 602 is configured to implement the data de-tilting method provided in any of the above embodiments by executing an instruction set stored in the memory.
[0167] The processor 602 can be a central processing unit (CPU), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, etc.
[0168] In addition, the above electronic device may also include components such as a communication interface and a communication bus. The memory, the processor and the communication interface communicate with each other via the communication bus.
[0169] The communication interface is used for communication between electronic devices and other devices (such as other PCs or servers, etc.). The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0170] In this embodiment, the processor in the electronic device executes a computer instruction set stored in the memory to break up the data subsets corresponding to the keys with relatively large data volumes, and breaks them up into different tasks. Finally, the different tasks corresponding to different keys of the batch data are relatively evenly distributed to multiple computing nodes for execution, thereby realizing task configuration (such as configuring as one task, or breaking it up into multiple tasks) and adaptation of computing resources based on the data volume corresponding to the key. In other words, since the data with large data volumes corresponding to the keys are broken up, there are no longer tasks with large data volumes, and the processing volume of the tasks assigned to each computing node is relatively balanced, thereby realizing data de-skewness, making full use of the resources of the device for data calculation, reducing the calculation time of the overall task of batch data, and avoiding single-point calculation problems caused by data skew.
[0171] At the same time, an embodiment of the present application also discloses a computer-readable storage medium, which stores a computer instruction set. When the computer instruction set is executed by a processor, the data de-tilting method provided in any of the above embodiments is implemented.
[0172] When the instruction set stored in the above-mentioned computer-readable storage medium is run, the data subset corresponding to the key with a relatively large data volume is scattered and scattered into different tasks. Finally, the different tasks corresponding to different keys of the batch data are relatively evenly distributed to multiple computing nodes for execution, thereby realizing task configuration (such as configuring as one task, or breaking it up into multiple tasks) and computing resource adaptation based on the data volume corresponding to the key. In other words, since the data with a large amount of data corresponding to the key is scattered, there are no longer tasks with a large amount of data, and the processing volume of the tasks assigned to each computing node is relatively balanced, thereby realizing data de-skewness, making full use of the resources of the device for data calculation, reducing the calculation time of the overall task of batch data, and avoiding the single-point calculation problem caused by data skew.
[0173] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0174] For the convenience of description, the above system or device is described by dividing it into various modules or units according to its functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0175] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0176] Finally, it should be noted that, in this article, relational terms such as first, second, third and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0177] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A data de-skew method, characterized in that: include: Get the keys of the batch data to be processed; Determine corresponding data subsets corresponding to different keys in the data set of the batch data; Determine the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number; If the number of tasks corresponding to the key is 1, the data subset corresponding to the key is allocated to a task assigned to the key; If the number of tasks corresponding to the key is greater than 1, each piece of data in the data subset corresponding to the key is dispersed into different tasks with the corresponding number of tasks assigned to the key; Allocate each task corresponding to each key to multiple computing nodes; Among them, the difference in the number of tasks assigned to different computing nodes is less than a threshold, the data corresponding to the same computing node are executed serially, and different computing nodes execute the respectively assigned tasks in parallel.
2. The method according to claim 1, characterized in that The determining the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set, and the total number of tasks set for the data set includes: Determine a corresponding weight for the key according to the data volume of the data subset corresponding to the key and the total data volume of the data set; Based on the weight corresponding to the key and the total number of tasks assigned to the data set, the number of tasks to be assigned to the data subset corresponding to the key is determined.
3. The method according to claim 2, characterized in that The determining the number of tasks to be allocated to the data subset corresponding to the key based on the weight corresponding to the key and the total number of tasks allocated to the data set includes: Use the following formula to calculate the number of tasks that need to be assigned to the data subset corresponding to the key: in: N represents the total number of tasks assigned to the dataset; |D i |Indicates the amount of data in the data subset corresponding to the key; |D| represents the total data volume of the data set; Indicates the weight corresponding to the key; N i Indicates the number of tasks assigned to the data subset corresponding to the key.
4. The method according to claim 1, characterized in that: If the number of tasks corresponding to the key is greater than 1, each piece of data in the data subset corresponding to the key is dispersed into different tasks with the corresponding number of tasks assigned to the key, including: Based on a random variable whose number of values is equal to the number of tasks, a random number is added to the key of each piece of data in the data subset corresponding to the key, to obtain subkeys whose number corresponding to the key is the number of tasks, wherein the subkey is a combination of the key and the added random number; Determine the data corresponding to each subkey in the data subset; The data corresponding to each subkey in the data subset are allocated one-to-one to different tasks of the number of tasks assigned to the key.
5. The method according to claim 4, characterized in that After allocating the tasks corresponding to the keys to multiple computing nodes, it also includes: For keys whose corresponding task number is greater than 1, the task processing results of each task of the key are aggregated to obtain the task processing result corresponding to the key; The task processing results of each key are integrated to obtain the data processing result of the batch data.
6. The method according to claim 5, characterized in that For a key whose corresponding task number is greater than 1, the task processing results of each task of the key are aggregated, including: Stripping random numbers from subkeys included in each task processing result of the key, so that each subkey included in each task processing result is restored to the key; Aggregate the processing results of each task based on the key.
7. A data de-tilting device, characterized in that: include: An acquisition unit, used for obtaining each key of the batch data to be processed; A first determining unit, configured to determine corresponding data subsets corresponding to different keys in a data set of the batch data; A second determining unit is used to determine the number of tasks to be allocated to the data subset corresponding to the key according to the data volume of the data subset corresponding to the key, the total data volume of the data set and the total number of tasks set for the data set; the sum of the number of tasks allocated to each key shall not exceed the total number; a task data configuration unit, configured to configure a data subset corresponding to the key to a task assigned to the key when the number of tasks corresponding to the key is 1; When the number of tasks corresponding to a key is greater than 1, each piece of data in the data subset corresponding to the key is dispersed into different tasks of the corresponding number of tasks assigned to the key; A task allocation unit, used to allocate each task corresponding to each key to multiple computing nodes; Among them, the difference in the number of tasks assigned to different resource nodes is less than a threshold, the data corresponding to the same computing node are executed serially, and different resource nodes execute the respectively assigned tasks in parallel.
8. The device according to claim 7, characterized in that The second determining unit is specifically configured to: Determine a corresponding weight for the key according to the data volume of the data subset corresponding to the key and the total data volume of the data set; Based on the weight corresponding to the key and the total number of tasks assigned to the data set, the number of tasks to be assigned to the data subset corresponding to the key is determined.
9. An electronic device, characterized in that: include: Memory, used to store computer instruction sets; A processor, configured to implement the data de-tilting method according to any one of claims 1 to 6 by executing an instruction set stored in the memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer instruction set, and when the computer instruction set is executed by a processor, the data de-tilting method according to any one of claims 1 to 6 is implemented.
