Data processing method and related equipment
By introducing a global load balancing mechanism into the data system, stateful tasks are converted into stateless tasks and transferred to nodes with lower loads for processing, which solves the problem of data system load overload, improves service capabilities and load balancing, and adapts to write Peak pressure for incoming traffic and data analysis.
Patent Information
- Application Number
- CN202310430614.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-19
- Publication Date
- 2024-10-22
AI Technical Summary
Data systems are prone to overload when processing high loads, resulting in the inability to provide normal services. Especially under tasks such as sudden increases in write traffic, large-scale data writing, or data analysis pulses, the system is overloaded and cannot process tasks in a timely manner.
By introducing a global load balancing mechanism into the data system and using global load service equipment to dynamically allocate optional nodes, the first node converts stateful tasks into stateless tasks and transfers them to the second node with lower load for processing. The global load balancing principle selects alternative nodes, giving priority to nodes with small load, low network overhead and different clusters.
Effectively solves the problem of data system load overload, ensures that tasks can be processed in a timely manner, reduces the load on the first and second nodes, improves the overall service capability and load balancing of the data system, and avoids sudden increases in write traffic and ultra-large scale Service pressure caused by data analysis.
Smart Images

Figure CN118819792A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a data processing method, a data processing apparatus, a computer device, a computer-readable storage medium, and a computer program product. Background Art
[0002] There are many data systems on the Internet that provide data services such as writing, querying, and analyzing massive amounts of data. Practice has shown that most of the data services provided by data systems are load-intensive services that consume a lot of processing resources. In actual applications, there may be load overload problems in data systems. For example, there are tasks such as sudden increases in write traffic, large-scale data writing, or large-scale data analysis pulses that need to be processed in the data system. The processing of these tasks may exceed the processing capacity of the data system, which will cause the data system to be overloaded, resulting in the data system being unable to provide normal services. Summary of the invention
[0003] The embodiments of the present application provide a data processing method and related equipment, which can solve the problem of data system overload and achieve load balancing of the data system.
[0004] On the one hand, an embodiment of the present application provides a data processing method, which is applied to a data system, the data system includes multiple nodes, and the method is executed by a first node, and the first node is any node in the data system; the method includes:
[0005] When the load of the first node is overloaded, a second node is selected from the data system, where the second node refers to any node in the data system except the first node; the second node is determined based on the principle of global load balancing of the data system;
[0006] Converting a stateful task to be processed in the first node into a stateless task;
[0007] Sending a task processing request to the second node, the task processing request carrying the stateless task, the task processing request being used to request the second node to process the stateless task and return processing information;
[0008] Post-process the processing information returned by the second node to obtain the processing result of the stateful task.
[0009] On the one hand, an embodiment of the present application provides a data processing method, which is applied to a data system, the data system includes multiple nodes, the method is executed by a second node, and the second node is any node in the data system; the method includes:
[0010] receiving a task processing request sent by a first node in the data system, the first node being any node in the data system except the second node; the task processing request comprising a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded; the second node is determined based on a principle of global load balancing of the data system;
[0011] In response to the task processing request, the stateless task is processed to obtain processing information;
[0012] The processing information is returned to the first node, so that the first node performs post-processing on the processing information to obtain a processing result of the stateful task.
[0013] On the one hand, an embodiment of the present application provides a data processing device, which is arranged in a first node, and the first node is any node among a plurality of nodes included in a data system; the device includes:
[0014] A processing unit, configured to select a second node from the data system when the first node is overloaded, wherein the second node refers to any node in the data system except the first node; the second node is determined based on a principle of global load balancing of the data system;
[0015] The processing unit is further used to convert the stateful task to be processed in the first node into a stateless task;
[0016] A sending unit, used to send a task processing request to the second node, wherein the task processing request carries a stateless task, and the task processing request is used to request the second node to process the stateless task and return processing information;
[0017] The processing unit is further used to perform post-processing on the processing information returned by the second node to obtain the processing result of the stateful task.
[0018] In one embodiment, the nodes in the data system include one or more of data nodes and independent nodes, the data nodes are distributed in one or more clusters in the data system, and the independent nodes are independently set in the data system;
[0019] The load overload of the first node includes at least one of the following: the current load of the first node is greater than or equal to the load threshold; the resources consumed to process the stateful task exceed the available resources of the first node; the first node will affect the processing process of the current task in the first node when processing the stateful task.
[0020] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage the node information and load information of each node in the data system; the device also includes a receiving unit, wherein:
[0021] The sending unit is further used to send an allocation request to the global load service device, where the allocation request is used to request the global load service device to allocate a backup node to the first node;
[0022] The receiving unit is further used to receive a node list allocated by the global load service device, wherein the node list includes one or more candidate nodes; the candidate node refers to any node in the data system except the first node;
[0023] Among them, the global load service equipment is allocated based on the principle of global load balancing of the data system. The principle of global load balancing of the data system includes at least one of the following: allocating alternative nodes in order of load from small to large; allocating alternative nodes in order of network overhead between the first node from small to large; and giving priority to allocating nodes belonging to different clusters from the first node as alternative nodes.
[0024] In one embodiment, the processing unit is specifically configured to:
[0025] Selecting a candidate node from the node list according to a preset rule to determine it as the second node; the preset rule includes at least one of the following: sequential selection, random selection, and selection based on the priority of the candidate node;
[0026] Among them, the setting factors of the priority of the alternative node include at least one of the following: load, network overhead and cluster; the lower the load of the alternative node, the higher the priority of the alternative node; the less the network overhead between the alternative node and the first node, the higher the priority of the alternative node; the alternative node and the first node belong to different clusters, the higher the priority of the alternative node.
[0027] In one embodiment, the preset rule is sequential selection or random selection; the processing unit is specifically used to:
[0028] Traverse the node list and select a candidate node in order or randomly from the node list;
[0029] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0030] In one embodiment, the preset rule is to select the candidate nodes according to their priorities; the processing unit is specifically configured to:
[0031] Traverse the node list and select a candidate node from the node list in descending order of priority;
[0032] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0033] In one embodiment, the processing unit is specifically configured to:
[0034] Sending a preprocessing request to the selected candidate node;
[0035] If an acceptance response returned by the selected candidate node is received within a preset response time, the selected candidate node is determined as the second node;
[0036] If an acceptance response is not received from the second node within the preset response time, or a rejection response is received from the selected alternative node within the preset response time, an unavailable mark is added to the node list for the selected alternative node; and, according to the preset rules, a new alternative node is reselected from the node list to determine the second node.
[0037] In one embodiment, the processing unit is further configured to:
[0038] If the processing information returned by the second node is received within the preset response time, a step of performing post-processing on the processing information returned by the second node to obtain a processing result of the stateful task is performed;
[0039] If the processing information returned by the second node is not received within the preset response time, or if the processing rejection information returned by the second node is received within the preset response time, an unavailable mark is added to the node list for the second node; and,
[0040] Reselect a new second node from the node list.
[0041] In one embodiment, a stateful task includes one or more subtasks; a processing unit is specifically configured to:
[0042] Extracting a target subtask from a stateful task, the target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent of other subtasks in the stateful task;
[0043] Encapsulate the extracted target subtask into a stateless task.
[0044] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; and the processing unit is specifically used to:
[0045] Obtain the data information to be written and the metadata information of the data information corresponding to the data writing subtask, where the metadata information of the data information is used to define the processing method of the data information to be written;
[0046] Encapsulate data information and metadata information of data information into stateless tasks.
[0047] In one embodiment, the processing information returned by the second node includes one or more file fragments obtained after the data information is written; the processing unit is specifically configured to:
[0048] Determine the file shard to which one or more file fragments belong;
[0049] Get the directory corresponding to the file segment;
[0050] Write one or more file fragments to a directory, and,
[0051] Update the metadata information of the file shard. The metadata information of the file shard is used to define the storage and indexing method of each file fragment in the file shard.
[0052] In one embodiment, the processing information returned by the second node also includes one or more log information generated during the writing process of the data information; the processing unit is further used to:
[0053] Add one or more log information in sequence to the log file corresponding to the stateful task in the first node.
[0054] In one embodiment, the processing unit is further configured to:
[0055] Responding to the load processing request sent by the business system, obtaining the stateful tasks to be processed;
[0056] Performing pre-processing on the stateful task and detecting load information of the first node; and,
[0057] After post-processing the processing information returned by the second node to obtain the processing result of the stateful task, feedback information is output to the business system.
[0058] On the one hand, an embodiment of the present application provides a data processing device, which is arranged in a second node, and the second node is any node among a plurality of nodes included in a data system; the device includes:
[0059] A receiving unit, configured to receive a task processing request sent by a first node in a data system, wherein the first node refers to any node in the data system except a second node; the task processing request includes a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded; the second node is determined based on a principle of global load balancing of the data system;
[0060] A processing unit, used for processing the stateless task to obtain processing information in response to the task processing request;
[0061] The sending unit is used to return the processing information to the first node, so that the first node performs post-processing on the processing information to obtain the processing result of the stateful task.
[0062] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage node information and load information of each node in the data system; based on the principle of global load balancing of the data system, the global load service device allocates a node list to the first node, and the node list includes one or more candidate nodes; the second node is a candidate node selected by the first node from the node list;
[0063] A stateless task is obtained by encapsulating the target subtask extracted from a stateful task;
[0064] A stateful task includes one or more subtasks; a target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent from other subtasks in the stateful task.
[0065] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; the stateless task includes data information to be written corresponding to the data writing subtask and metadata information of the data information;
[0066] The processing unit is specifically used for:
[0067] In response to the task processing request, creating a temporary index write class in the memory of the second node;
[0068] Call the temporary index writing class to write the data information based on the metadata information of the data information to obtain one or more file fragments;
[0069] Based on the one or more file segments, processing information is generated.
[0070] In one embodiment, the processing unit is further configured to:
[0071] Create a temporary log class in the memory of the second node;
[0072] Based on the process of data information being written, a temporary log class is called to generate one or more log information;
[0073] Generate processing information based on one or more log information.
[0074] In one aspect, an embodiment of the present application provides a computer device, the computer device comprising:
[0075] a processor suitable for executing a computer program;
[0076] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned data processing method is implemented.
[0077] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is loaded by a processor and executes the above-mentioned data processing method.
[0078] On the one hand, an embodiment of the present application provides a computer program product, which includes a computer program or computer instructions, and the computer program or computer instructions implement the above-mentioned data processing method when executed by a processor.
[0079] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0080] 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 some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0081] Figure 1 is a schematic diagram of the architecture of a data system provided by an exemplary embodiment of the present application;
[0082] Figure 2 It is a flowchart of a data writing process provided by an exemplary embodiment of the present application;
[0083] Figure 3 It is a flowchart of a data processing method provided by an exemplary embodiment of the present application;
[0084] Figure 4 It is a schematic diagram of a process of a first node acquiring a node list provided by an exemplary embodiment of the present application;
[0085] Figure 5 is a schematic diagram of a process of determining a second node from a node list provided by an exemplary embodiment of the present application;
[0086] Figure 6 is a flowchart of a data processing method provided by another exemplary embodiment of the present application;
[0087] Figure 7 is a flowchart of a data processing method provided by another exemplary embodiment of the present application;
[0088] Figure 8 It is a structural schematic diagram of a data processing device provided by an exemplary embodiment of the present application;
[0089] Fig. 9 is a structural schematic diagram of a data processing device provided by another exemplary embodiment of the present application;
[0090] Fig.10 It is a structural diagram of a computer device provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0091] 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.
[0092] First, the relevant technical terms involved in the embodiments of the present application are explained.
[0093] 1. Data system:
[0094] A data system refers to a system that can provide data services; data services may include but are not limited to: data writing, data query, data analysis and other services. Data systems can be divided into stateless data systems and stateful data systems. A stateless data system refers to a data system that is mainly used to process stateless tasks; while a stateful data system refers to a data system that is mainly used to process stateful tasks.
[0095] 2. Stateful tasks and stateless tasks:
[0096] A stateful task (i.e., a stateful data task) generally refers to a task whose processing needs to rely on certain data or parameters in the data system. Such a task is called a stateful task. Correspondingly, a stateless task (i.e., a stateless data task) generally refers to a task that carries the data or parameters required for processing. The processing of the task can be directly implemented based on the data or parameters carried in the task without relying on other data or parameters in the data system. Such a task is called a stateless task. It can be understood that stateful data systems are mainly used to process stateful tasks, but stateful data systems can also include stateless tasks. Similarly, stateless data systems are mainly used to process stateless tasks, but stateless data systems can also include stateful tasks.
[0097] 3. Node
[0098] The data system may include multiple nodes. In one implementation, a node in the data system may refer to a service program, which is used to process data tasks in the data system. The service program may be deployed and run in a device. If one such service program can be deployed in a device, then the device may include one node; if multiple such service programs can be deployed in a device, then the device may include multiple nodes. The devices here may include, but are not limited to: terminal devices, servers, etc.
[0099] The types of nodes in a data system may include data nodes and service nodes. The so-called data node generally refers to a node used to process conventional data tasks in a data system; the conventional data tasks here refer to the data tasks that mainly need to be processed in the data system; for example: conventional data tasks in a stateful data system include stateful tasks, which may include but are not limited to tasks such as data writing, data analysis, and data query. The so-called service node generally refers to a node used to manage metadata information in a data system. The metadata information here may include but is not limited to: identity metadata, index metadata, etc. Schematically, the identity metadata may include the index to which the written document belongs, the type of document, etc. Index metadata may, for example, include the name of each field of the index, etc. The above-mentioned nodes (including data nodes and service nodes) are generally distributed in one or more clusters of the data system. A cluster may include one or more data nodes, and may also include one or more service nodes. It should be noted that the data system in the embodiment of the present application may also be provided with one or more independent nodes (Independent Node) specifically used to process special data tasks in the data system, and this independent node may not exist in any cluster of the data system. The special data tasks here refer to a small number of tasks that need to be processed in the data system, usually tasks other than regular data tasks; for example, special data tasks in a stateful data system may include stateless tasks; for another example: special data tasks in a stateless data system may include stateful tasks.
[0100] To process regular data tasks in a data system, the data system needs to have processing logic for the regular data system. Then, a data node in the data system can be understood as a service program that integrates the processing logic of regular data tasks. Similarly, to process special data tasks in a data system, the data system needs to have processing logic for the special data task. In a feasible implementation, the processing logic of the special data task can be integrated in the data node. At this time, the data node has both the processing capabilities of regular data tasks and the processing capabilities of special data tasks; for example, a data node in a stateful data system can process both stateful tasks and stateless tasks. In another feasible implementation, the processing logic of the special data task can also be integrated separately in an independent node, so that the independent node has the processing capabilities of special data tasks; for example, an independent node in a stateful data system can be dedicated to processing stateless tasks.
[0101] Based on the above description, it can be known that the nodes used to process data tasks in the data system include data nodes and independent nodes; therefore, unless otherwise specified, the nodes mentioned in the subsequent embodiments of this application refer to data nodes and independent nodes. The node has processing resources, and processing resources refer to resources used to process data tasks; schematically, processing resources can be, for example, CPU (central processing unit) resources. The load of a node refers to the total amount of tasks that the node currently needs to process. The node consumes processing resources when processing data tasks, so the load of the node can reflect the processing capacity of the node to a certain extent; and the processing capacity of the node can determine the overall service capacity of the data system to a certain extent.
[0102] 4. Cluster
[0103] A data system can contain multiple clusters. A cluster refers to a collection of nodes. Each cluster can integrate one or more data nodes. Usually, each cluster in a data system is relatively independent and is responsible for processing data tasks within its own cluster. For an example, see Figure 1 The schematic diagram of the architecture of a data system shown in the figure; the data system includes cluster 101, cluster 102 and cluster 103, each of which contains multiple data nodes (DataNode), such as data node-1, data node-2...data node-N; each cluster is relatively independent, and the nodes in the cluster are responsible for processing the data tasks in their respective clusters. In the data system of this embodiment, one or more independent nodes for processing special data tasks can also be set up, and the independent node may not belong to any cluster in the data system and can exist independently. Schematically, as shown in FIG. Figure 1 The independent nodes shown, namely, the independent node-1, the independent node-2, ..., the independent node-N, do not belong to the cluster 101, the cluster 102, and the cluster 103 in the data system.
[0104] The following is a brief introduction to common data systems.
[0105] Common data systems include but are not limited to: log retrieval system, data storage and analysis system, ElasticSearch (ES for short), ClickHouse, etc. Among them:
[0106] The log retrieval system is a data system used to store various logs (such as system logs, application logs, security logs, etc.) and analyze various logs. The data storage and analysis system is a data system used to store and analyze data.
[0107] ElasticSearch is a distributed data system built on Lucene (a Java-based full-text search engine). ES contains multiple ES clusters (ElasticSearch Cluster), each ES cluster consists of multiple nodes. Nodes can store data and participate in the indexing and search services of the ES cluster.
[0108] ClickHouse is a relational database for column-oriented storage that allows you to create tables and databases, load data, and run queries at runtime without reconfiguring and restarting the server. It supports linear expansion, simplicity, convenience, high reliability, and fault tolerance.
[0109] Data writing tasks are usually more important data tasks in data systems. Taking ES as an example, the following describes in detail the processing process of the data system for data writing tasks.
[0110] ES provides a logical concept index (Index) to the outside world. Each Index consists of multiple shards, each shard consists of multiple independent file fragments (segments), and each segment is a complete and independent Lucene index. Among them, a shard is a container for data. Data is stored in a shard, and the shard is distributed to each node in ES. A shard can contain a primary shard and one or more replica shards. The number of primary shards is specified when creating an index. The primary shard can be used to write data information corresponding to the Index. The replica shard can be used to back up the data information written to the primary shard after the data information is successfully written to the primary shard. The primary shard and the replica shard are located in different nodes of ES. When the primary shard cannot be used, the replica shard corresponding to the primary shard can be upgraded to the primary shard. The processing of data writing tasks in ES can include three stages: (1) Index creation stage: triggered by the business system connected to ES calling the Restful interface in ES. For example, the business system can call the Restful interface in ES to send a bulk write request to the nodes in the ES cluster, thereby triggering the batch data writing process. During the data writing process, the nodes in ES can first write the data information to be written into the index cache structure in the memory. At this time, the data information is invisible, that is, index query is not supported; the processing process in this stage consumes more processing resources. (2) Refresh stage: The nodes in ES update the data information in the index cache structure regularly (such as 1s, the regular interval can be configured by the user). Specifically, the data information in the index cache structure in the memory is generated one by one. File segments are handed over to the file system, and a new memory index interface is generated at the same time. The file system here is the method and data structure used in the operating system to identify files in the storage device (commonly a disk, but also a solid-state drive, or a partition in the storage device), that is, the method of organizing files on the storage device; it is the software organization in the operating system responsible for managing and storing files. The Refresh phase makes the data information in the index creation phase visible, that is, supports index query. (3) Merge phase: The nodes in ES merge small segments into large segments, or merge them into one file.
[0111] As a stateful data system, ES's regular data tasks are stateful tasks. Taking the stateful data writing task as an example, the data information requested to be written by the data writing task can include a single document or batches of documents. The following is a detailed description of the processing flow of the data writing task in ES; Figure 2 As shown, the processing flow may include:
[0112] 1. Processing flow on the coordination node side:
[0113] The business system calls the Restful interface in ES to send a data write request to the data system, and the coordination node refers to the node in the data system that receives the data write request. Here, the business system refers to a system connected to the data system for requesting the data system to provide services. The business system may include but is not limited to: data information collection system, access control processing system, etc. The coordination node performs the following steps in response to the received data write request: s11, parameter check: Check the data write request received from the business system; the parameter check includes integrity check and compliance check. The integrity check is used to check whether the parameters in the data write request are complete, that is, to check whether the parameters required for processing are missing; for example: the data write request should contain the data information to be written. If the integrity check confirms that the data write request does not contain this data information, it is determined that the data write request check has not passed, and the data write request can be rejected. The response can be fed back to the business system. The rejection response notification can carry the reason for the rejection response. Compliance check is used to check whether the data write request complies with the request specification, including: checking whether the data write request is initiated by a legitimate business system. The so-called legitimate business system refers to a business system that has been connected to the data system and has the authority to call the Restful interface to initiate a request. If the data write request is initiated by an illegal business system, it is confirmed to be non-compliant. In addition, compliance check is also used to check whether the format of the data write request complies with the format specification of ES. If the format of the data write request does not comply with the format specification, it is confirmed to be non-compliant. If the compliance check confirms that the data write request is non-compliant, the data write request can be rejected and a rejection response notification can be fed back to the business system. The rejection response notification can carry the reason for the rejection response. s12. Processing pipeline: After the parameter check passes, the coordination node needs to perform data preprocessing (ingest) on the data write request. Data preprocessing is implemented by defining pipelines and processors. Pipeline is a definition of a series of processors (i.e., processors), and processors are executed in the order of declaration. If the pipeline parameter is specified in the data write request (such as an Index request or a Bulk request), the corresponding pipeline is used for processing first. If the coordination node does not have the preprocessing qualification, the request will be randomly forwarded to other nodes that have the preprocessing qualification. s13. Automatic index creation: If the data system is configured to allow automatic index creation, in one implementation, it is usually configured to allow automatic index creation by default, then the coordination node calculates the index related to the data write request. The related index may be one or more, for example: if a request is made to write a single document, then the index may be one; if a request is made to write batches of documents, then the index may be one or more.The coordination node determines which of the calculated related indexes do not exist in the data system yet, and then creates these non-existent indexes. If the creation of some indexes fails, the documents corresponding to the indexes that failed to be created in the data write request will be marked as failed, and the documents corresponding to other successfully created indexes in the data write request will be written normally. If all the calculated related indexes already exist in the data system, then all documents in the data write request can be written directly. s14. Automatically generate document identification (id): Since there may be an index creation operation in the previous step, it is necessary to first obtain the new cluster state in ES, which contains the newly created index. Then traverse the cluster state to obtain the metadata corresponding to the newly created index, including mapping metadata information, routing, and the document id corresponding to the index, etc. If the document id does not exist, a UUID (universally unique identifier) is generated as the document id. s15. Merge requests: If there are multiple data write requests, and the documents required to be written by the multiple data write requests belong to the same shard, then these multiple data write requests can be reorganized into shard-based requests; for example, if 10 data write requests require 10 documents to be written to the same shard, then these 10 data write requests can be merged into 1 shard-based data write request. s16. Parallel forwarding: Encapsulate the data write request located in a certain shard as a BulkShardRequest request (data write task), and then forward it to the primary shard node where the shard is located for execution. s17. The coordination node determines whether the reply information of all data write requests returned by the primary shard node has been received, and executes step s18 when it is determined that the reply information of all data write requests has been received. s18. Process the reply information returned by the primary shard node. After the reply information returned by the primary shard node is processed, it means that the data write task is completed, and then step s19 can be executed. s19. The coordination node can perform reply processing to the business system to inform the business system of the request result.
[0114] 2. Processing flow on the primary shard node side:
[0115] The primary shard node (i.e., the node where the shard is located) processes the data writing task forwarded by the coordination node. The processing steps may include: s21, parameter check: After the primary shard node receives the BulkShardRequest request sent by the coordination node, it needs to verify the BulkShardRequest request; the verification here mainly detects whether the shard to be written belongs to the primary shard node, whether the document ID meets the specifications of the data system, whether the index corresponding to the shard is in a closed state (the so-called closed state means that the document is not allowed to be written), etc. If the parameter check passes, that is, the shard to be written belongs to the primary shard node, the document ID meets the specifications of the data system, and the index corresponding to the shard is in an open state (the so-called open state means that the document is allowed to be written). s22, determine whether to delay execution. Determine whether the BulkShardRequest request needs to be delayed. For example, when the primary shard node is overloaded or other tasks are being processed, the BulkShardRequest request may need to be delayed. At this time, step s23 can be executed. s23. Put the BulkShardRequest request into the queue; if the primary shard node has a low load or no other tasks are being processed, determine that the BulkShardRequest request does not need to be delayed, and execute step s24. s24. Determine whether the primary shard has been migrated: If the primary shard has been migrated, you can execute step s25. s25. Forward the BulkShardRequest request to the migrated node for processing; if the primary shard has not been migrated, execute step s26. s26. Check write consistency: Before formally writing the document in the BulkShardRequest request, it is necessary to detect the shard involved in the write processing of the document in the BulkShardRequest request. The detection here mainly includes: determining whether the shard involved is in an active state, and determining whether the number of active shards is greater than or equal to the quantity threshold. When the number of active shards is less than a quantity threshold (the quantity threshold can be set based on experience, and the quantity threshold can be set to 1, 3, etc.), the document writing process is not performed. When the number of active shards is greater than or equal to the quantity threshold, the document can be written. The active shard refers to an available shard that can write a document. The active shard can include one or more of the primary shard and the secondary shard.Indicatively, when the shard involved in the write process of the document in the BulkShardRequest request includes the primary shard, the number of shards involved is greater than or equal to the quantity threshold 1, and the primary shard is in an active state, the write process of the document in the BulkShardRequest request can be executed at this time. s27. Sequentially write each: The data writing process includes the process of document writing (or Lucene writing, writing Lucene) and the process of log (translog) writing. The order of the two is to execute document writing (i.e. Lucene writing) first, and then execute translog writing. The reason for setting this sequential execution is that Lucene (a full-text retrieval engine) will check the document to be written when writing. If the check fails, it may cause the failure of the document writing operation. Translog is used to record document writing operations; if the translog writing operation is executed first, then when the document writing operation fails, the written translog needs to be rolled back, so the above sequential execution is set to avoid unnecessary rollback operations. The data writing process can include the above-mentioned index creation phase, refresh phase and merge phase. s28. Parallel forwarding: After the primary shard node completes the data writing task, it will forward the sequentially written documents and log information to the secondary shard node in parallel. s29. Reply to the coordination node: When receiving feedback from the secondary shard node, the primary shard node can send a reply message to the coordination node, which is used to indicate that the data writing task has been completed.
[0116] 3. Processing flow on the secondary shard node side:
[0117] The secondary sharding node is used to back up the primary sharding node. A primary sharding node can contain one or more secondary sharding nodes. After the secondary sharding node receives the documents and log information forwarded by the primary sharding node, the processing flow it executes includes: s31. Write each one in sequence: The secondary sharding node writes the document and log information. The writing process is similar to the writing process of the primary sharding node and will not be repeated here. s32. Reply to the primary sharding node: When the secondary sharding node completes writing the document and log information, it can return feedback information to the primary sharding node. The feedback information is used to indicate that the data writing task has been completed.
[0118] It is understandable that each step in the above data writing task (such as parameter checking, automatic index creation, and sequential writing of each record) can represent a subtask in the data writing task. For example, in an embodiment of the present application, step s27 (i.e., sequential writing of each record) in the primary sharding node can be used as a data writing subtask, then steps s11-s16 processed by the coordination node and steps s21-s26 processed by the primary sharding node can be used as the pre-processing of the data writing subtask, and steps s28-s29, steps s31-s32, and steps s17-s19 located after step s27 processed by the primary sharding node can be used as the post-processing of the data writing subtask.
[0119] Data systems usually have some mechanisms to ensure service capabilities. These mechanisms may include:
[0120] (1) Queue mechanism: Requests that do not need to be processed temporarily in the data system are placed in the corresponding request queue.
[0121] (2) Horizontal expansion mechanism: The nodes in the data system can be expanded to alleviate the load pressure of the data system.
[0122] (3) Over-allocation resource mechanism: This over-allocation resource mechanism provides a cluster size that is larger than the normal demand load to cope with sudden traffic increases.
[0123] The above mechanisms all focus on optimizing a single cluster in the data system, but for the data system as a whole, this optimization has certain limitations: the queue mechanism can alleviate traffic surges, but for the sake of system stability, the queue is generally not very large, and requests exceeding the queue will be discarded, resulting in data not being stored or processed in time. Although the horizontal expansion mechanism can alleviate some of the load, due to its state, if there are many indexes in the cluster, it takes hours and has scale restrictions, resulting in a long load balancing time within the cluster. Over-allocation of resources can solve the scenario of traffic surges to a certain extent, but the cluster is in a low-load state most of the time, and the cost is relatively high. There is no solution for large-scale data writes that exceed the capabilities of the existing cluster.
[0124] Based on this, the present application proposes a data processing scheme, which improves the mechanism of the data system from the perspective of global load balancing of the data system and enhances the overall service capability of the data system. In the data processing scheme provided in the embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained after processing from the second node for post-processing, and the processing result of the stateful task can be obtained. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, but also ensures that the pending tasks can be processed in time, and can also ensure the global load balancing of the data system to a certain extent; in addition, by converting the stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to cope with the problem of load overload.
[0125] Next, the data system provided in the embodiment of the present application is introduced in detail.
[0126] See also Figure 1 , Figure 1 A schematic diagram of the architecture of a data system provided for an exemplary embodiment of the present application. The data system may include multiple nodes and a global load service device 104. The nodes in the data system may include data nodes and independent nodes. The data nodes may be distributed in one or more clusters in the data system, each cluster is relatively independent, and the number of nodes included in each cluster may be the same or different. Independent nodes may be independently set in the data system and do not belong to any cluster. For example, Figure 1 The data system shown includes three clusters, namely cluster 101, cluster 102 and cluster 103, each of which may include multiple data nodes. Multiple independent nodes (such as independent node-1, independent node-2...independent node-N) are set outside the three clusters. It should be understood that the embodiment of the present application does not limit the number of clusters in the data system, the number of data nodes in the cluster, and the number of independent nodes outside the cluster.
[0127] The embodiment of the present application introduces two roles, client (delegating end) and worker (executing end), in the data system. The two roles are introduced below:
[0128] ①client: It can refer to a module integrated in the data node. The client is responsible for requesting to maintain its own node list, which can contain one or more candidate nodes. The candidate nodes are determined based on the global load balancing of the data system. The candidate nodes in the node list can be data nodes or independent nodes. The client is responsible for encapsulating stateful tasks into stateless tasks when the data node is overloaded, and sending task processing requests to the worker selected from the node list (that is, the candidate node selected in the node list), requesting the worker to process the stateless task. It can be seen that the client is the source of load transfer.
[0129] ②Worker: It can refer to a module in a data node or an independent node. The worker is responsible for responding to the task processing request sent by the client and processing the transferred stateless tasks. It can be seen that the worker is the target end of the load transfer.
[0130] ③Any node in the data system can act as a client, and use any other node in the data system (such as other data nodes or independent nodes) as its own worker. When the node is overloaded, the task will be transferred to the worker for processing. At the same time, any node in the data system (such as data nodes or independent nodes) can also act as a worker, and use any other node in the data system (such as data nodes or independent nodes) as its own client, and process the tasks transferred by the client.
[0131] The embodiment of the present application also introduces a global load service (Global Load Service, GLS) device in the data system; the global load service device can be set in one or more nodes, or the global load service device can be an independent service device set in the data system, or the global load service device can be a service cluster device composed of multiple service devices set in the data system. Each node in the data system must report its own node information and load information to the global load service device in real time or regularly, and accept the unified management of the global load service device. The global load service device is also used to allocate a personalized node list (or worker list) to the client based on the principle of global balance of the data system.
[0132] The above-mentioned global load service device 104 can be a terminal device or a server. The terminal device involved in this application can be a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart TV, a smart watch, a vehicle-mounted device, a wearable device, etc., but is not limited to this. The server can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (Content Delivery Network, CDN), and big data and artificial intelligence platforms. The so-called cloud computing refers to the delivery and use mode of IT infrastructure, which refers to obtaining the required resources through the network in an on-demand and easily scalable manner; broad cloud computing refers to the delivery and use mode of services, which refers to obtaining the required services through the network in an on-demand and easily scalable manner. This service can be related to IT and software, the Internet, or other services. Cloud computing is the product of the integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing. With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the promotion of search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Different from the previous parallel and distributed computing, the emergence of cloud computing will promote revolutionary changes in the entire Internet model and enterprise management model from a conceptual perspective. The so-called cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system that can bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide data storage and business access functions to the outside world through cluster applications, grid technology, and distributed storage file systems. At present, the storage method of the storage system is: create a logical volume, when creating a logical volume, allocate physical storage space for each logical volume, the physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume.That is, the data is stored on the file system. The file system divides the data into many parts, each part is an object. The object contains not only data but also additional information such as data identification (ID, ID entity). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object. When the client requests to access the data, the file system can allow the client to access the data based on the storage location information of each object.
[0133] Figure 1 The working principle of the data system shown generally includes: the global load service device 104 can allocate a node list to each node as a client based on the principle of global load balancing, and the candidate nodes in the node list corresponding to each node can be the same or different, and the candidate nodes can be data nodes or independent nodes. When a certain node acts as a client, the candidate nodes in the node list allocated to the node can all act as workers to execute the tasks sent by the node. When the business system 105 sends a load processing request to a certain node (such as the first node) in the data system, the first node obtains a stateful task from the load processing request and determines whether the load of this node is overloaded; when it is determined that the load of this node is overloaded, the first node can act as a client, and then convert the stateful task in the first node into a stateless task, and select the second node as a worker from the node list maintained by itself, and then transfer the stateless task to the second node. The second node can process the stateless task to obtain processing information, and return the processing information to the first node, so that the first node can directly post-process the processing information, thereby completing the execution of the stateful task.
[0134] Through the above working principle, the data system of the embodiment of the present application can solve the problem of node overload, so as to achieve: fast load transfer and improve the upper limit of cluster capacity, and then solve the following problems: (1) Solve the problem of sudden increase in write traffic. In the operation of the data system, there will generally be a scenario of sudden increase in traffic. If the write capacity after the sudden increase in traffic exceeds the cluster capacity, then the write will be backlogged. At this time, the data processing solution of the embodiment of the present application can be used to transfer the write task, solve the sudden increase in write traffic, and reduce the cluster writing pressure. (2) Solve the problem of ultra-large-scale data writing. A single business system can only access a single cluster. If the data write volume of the business system exceeds the capacity of the existing cluster, the cluster will not be able to provide normal services. At this time, the data processing solution of the embodiment of the present application can be used to convert the data write task to the nodes in other clusters for processing, reducing the writing pressure of a single cluster. (3) Solve the problem of ultra-large-scale data analysis pulses. Occasional ultra-large-scale data analysis generally involves fewer queries, but each may last for tens of seconds, requiring a large amount of CPU load resources. If the write volume is also large at this time, it will squeeze the load resources available for analysis, causing analysis timeouts. The data processing solution of the embodiment of the present application can convert data writing tasks to other nodes in the data system for processing, thereby reducing the pressure on load resources available for analysis.
[0135] Next, the data processing method provided in the embodiment of the present application is described in detail.
[0136] See also Figure 3 , Figure 3 A flow chart of a data processing method provided in an embodiment of the present application. The data processing method is applied to the above-mentioned data system, and the data system includes multiple nodes. The data processing method can be executed by a first node, and the first node can be any node among the multiple nodes. The data processing method can include the following steps S301-S304:
[0137] S301: When the load of the first node is overloaded, a second node is selected from the data system, where the second node refers to any node in the data system except the first node. The second node is determined based on the principle of global load balancing of the data system.
[0138] Illustratively, the data system may include a stateful system. The nodes in the data system may include data nodes, independent nodes, or both data nodes and independent nodes. The data nodes may be distributed in one or more clusters in the data system, and the independent nodes are independently arranged in the data system, that is, the independent nodes are independent of one or more clusters in the data system. In one embodiment, the first node may be a data node, and the second node may be a data node or an independent node. When the first node is a data node and the second node is a data node, the first node and the second node may be nodes in the same cluster or nodes in different clusters. When the first node is overloaded, the first node may act as a client, and the second node selected from the data system may act as a worker.
[0139] The load overload of the first node may include at least one of the following: ① The current load of the first node is greater than or equal to the load threshold (the load threshold can be set according to the demand), and the current load of the first node refers to the load being processed by the first node; for example, the current load of the first node includes 100 tasks, and the load threshold is 50 tasks, then when the current load of the first node is greater than 50 tasks, the load of the first node is considered to be overloaded. ② The resources consumed by processing stateful tasks exceed the available resources of the first node. For example, the stateful task is a data writing task, and the memory resources consumed by the data writing task (such as the memory resources of 10 megabytes) exceed the available memory resources of the first node (5 megabytes), then the load of the first node can be considered to be overloaded. For another example, the stateful task is a data writing task, and the CPU resources consumed by the data writing task exceed the available CPU resources of the first node, then the load of the first node can be considered to be overloaded. ③ When the first node processes the stateful task, it will affect the processing process of the current task in the first node; here, the current task in the first node refers to the task being processed in the first node. For example, the stateful task is a data writing task, and the current task in the first node is a data query task. At this time, since the first node needs to consume resources when processing the data writing task, and the consumption of these resources may affect the normal progress of the data query task, then it is considered that the data writing task affects the processing process of the current task in the first node, and the load of the first node is determined to be overloaded.
[0140] In one embodiment, a global load service device is provided in the data system, and the global load service device can manage the node information and load information of each node in the data system. The node information may include, for example, a node identifier, an identifier of a cluster where the node is located, and the like. The load information may include the current amount of tasks to be processed, currently available resources, and the like. The first node may request the global load service device to allocate a node list and maintain the allocated node list, and the node list may include one or more candidate nodes, which may be data nodes or independent nodes in the data system. The first node may select a second node from the node list according to a preset rule; the selection process of the second node will be described in detail in subsequent embodiments.
[0141] S302: Convert the stateful task to be processed in the first node into a stateless task.
[0142] There are usually subtasks that consume more resources in the stateful tasks to be processed. For example, a stateful data writing task includes a data writing subtask, and the data writing subtask may include two parts: writing lucene and writing logs (translong). The resources (such as CPU resources) consumed by the data writing subtask are usually more (such as exceeding the resource threshold, which can be determined based on empirical values or according to the general processing capabilities of the node), and the data writing subtask is relatively independent in the data writing task; therefore, the embodiments of the present application can extract and encapsulate this type of subtask into a stateless task.
[0143] S303: Send a task processing request to the second node, where the task processing request carries the stateless task, and the task processing request is used to request the second node to process the stateless task and return processing information.
[0144] In a specific implementation, a task processing request may be generated based on the stateless task, and the task processing request may be sent to the second node based on the communication connection between the first node and the second node. The processing information may refer to information obtained after the second node processes the stateless task.
[0145] In one embodiment, after sending a task processing request to the second node, the second node can give feedback to the task processing request sent by the first node according to its own load: if the second node is in an idle state or the current load of the second node is less than the load threshold (i.e., its own load is low), the current load of the second node refers to the load being processed by the second node; at this time, the second node can process the stateless task in the task processing request and return the processing information of the stateless task to the first node within a preset reply time (which can be flexibly set according to actual needs, for example, the preset reply time is 5 minutes, 30 seconds, etc.), thereby triggering the first node to perform subsequent step S304. If the current load of the second node is greater than or equal to the load threshold (i.e., its own load is too high), at this time, the second node can return a rejection processing information to the first node within the preset reply time or not make any reply to the first node; wherein, the rejection processing information can be used to indicate that the second node refuses to execute the stateless task sent by the first node; in this case, the first node can process the stateful task by itself. In addition, optionally, the first node can add an unavailable mark to the second node in the node list; and, reselect a new second node from the node list.
[0146] S304: Post-process the processing information returned by the second node to obtain a processing result of the stateful task.
[0147] The post-processing may include but is not limited to: saving the processing information returned by the second node, updating the information in the first node based on the processing information returned by the second node, etc. Through the post-processing of the first node, the stateful task to be processed in the first node is processed and the processing result of the stateful task is obtained.
[0148] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0149] The following is a detailed introduction to the process of the first node obtaining the node list mentioned in the embodiment of the present application.
[0150] See also Figure 4 As shown, Figure 4 A flowchart of a first node obtaining a node list is provided for an exemplary embodiment of the present application. First, the flowchart of the first node obtaining a node list includes the following steps: s41: Each node in the data system will periodically (the periodic time can be set according to actual needs, for example, the periodic time is 1 minute, 5 seconds, etc.) report its own node information and load information to the global load service device, and the global load service device receives each node (including Figure 4 s42: The first node may send an allocation request to the global load service device, and the allocation request is used to request the global load service device to allocate an alternative node to the first node. The allocation request may be sent by the first node at any time; schematically, the allocation request may be sent by the first node to the global load service device at startup; or, the allocation request may be sent to the global load service device when the first node detects that the load of the node is overloaded; or, the allocation request may be sent to the global load service device when the first node needs to use the global load service. The global load service device may respond to the allocation request, allocate an alternative node to the first node according to the principle of global load balancing, and then generate a node list based on the allocated alternative nodes, and send the allocated node list to the first node. The number of alternative nodes may be one or more. s43: The first node receives the node list allocated by the global load service device, and the node list contains one or more alternative nodes. Any alternative node refers to any node in the data system except the first node.
[0151] The manner in which the global load service device allocates a node list to the first node based on the principle of global load balancing is as follows: As an implementation method, the allocation request sent by the first node to the global load service device may carry the number of candidate nodes requested for allocation, and the global load service device may allocate candidate nodes to the first node based on the number of candidate nodes and in accordance with the principle of global load balancing. For example, if the number of candidate nodes requested for allocation in the allocation request is 10, then the global load service device may allocate 10 candidate nodes to the first node based on the principle of global load balancing of the data system. As another implementation method, the global load service device may directly allocate candidate nodes to the first node from multiple nodes in accordance with the principle of global load balancing of the data system (for example, only two nodes can be selected from multiple nodes based on the principle of global load balancing of the data system, then the two nodes may be allocated to the first node as its candidate nodes).
[0152] The principles of global load balancing of data systems can include at least one of the following:
[0153] (1) Allocate candidate nodes in order of load from small to large.
[0154] The global load service device can periodically receive the load information reported by each node, and then select nodes as candidate nodes for the first node in the order of the load indicated by the load information of each node from small to large. The candidate node can be one or more of a data node and an independent node. For example, the load of node 1 is 10 tasks to be processed, the load of node 2 is 3 tasks to be processed, and the load of node 3 is 2 tasks to be processed, then node 3 and node 2 can be selected as candidate nodes for the first node in the order of the load from small to large.
[0155] As an implementation method, since multiple data nodes are distributed in multiple clusters, when the selected node is a data node in the cluster, the principle of global load balancing needs to be met: the load of each cluster needs to be as balanced as possible, and the current task of the cluster where the selected data node is located needs to be prioritized to ensure that it can be processed normally. The global load service device can determine the load of the cluster where each node is located based on the node information and load information reported by each node, and then select the data nodes in the cluster as the candidate nodes for the first node in order of the cluster load from small to large.
[0156] (2) Allocate the candidate nodes in order of the network overhead between them and the first node from the least to the most.
[0157] The global load balancing service device can determine the network overhead between the first node and other nodes, and select nodes as candidate nodes for the first node in order of network overhead from least to most. As an implementation method, the network overhead is positively correlated with the distance. The farther the distance between the nodes, the greater the network overhead between the nodes. For example, the distance between the first node and node 1 is greater than the distance between the first node and node 2. At this time, the network overhead between the first node and node 1 is greater than the network overhead between the first node and node 2. Then, node 1 can be selected as a candidate node in order of network overhead from least to most. As another implementation method, the network overhead can be determined based on the consumed bandwidth. The more bandwidth consumed, the greater the network overhead.
[0158] (3) Prioritize assigning nodes that belong to different clusters from the first node as candidate nodes.
[0159] The global load service device can determine the cluster of each node according to the node information reported by each node, and give priority to nodes belonging to different clusters from the first node as candidate nodes. By giving priority to nodes belonging to different clusters from the first node, when the load of the first node is overloaded, the load of the first node can be shared to nodes in other low-load clusters, which can ensure load balancing between clusters, improve resource utilization, and reduce costs.
[0160] It should be understood that the principles of global load balancing of the above-mentioned data system can be flexibly selected for use alone or in combination. For example, when the above-mentioned methods (1) and (2) are combined, a node with a small load and a small network overhead can be selected as an alternative node for the first node. This makes the alternative node more meaningful and, to a certain extent, better solves the problem of load overload and improves the service quality of the data system. For another example, the above-mentioned methods (1) and (3) can also be used in combination, or the above-mentioned (1), (2) and (3) can also be used in combination. The embodiments of the present application do not limit the combination of the principles of global load balancing.
[0161] In a feasible implementation, since the load of the nodes in the data system changes dynamically, the first node may also execute step s44: send an update request to the global load service device according to a period (the period can be set according to actual needs, for example, the period can be 5 seconds, 10 seconds, etc.), and the update request is used to request the global load service device to update the node list of the first node. At this time, the global load service device can reselect an alternative node for the first node based on the principle of global load balancing, and update the node list based on the reselected alternative node to obtain an updated node list; then the global load service device executes step s45: sends the updated node list to the first node, and accordingly, the first node receives the updated node list sent by the global load service device.
[0162] As an implementation method, the global load balancing server can directly allocate a new candidate node to the first node according to the node information and load information recently reported by each node and in accordance with the principle of global load balancing, and generate an updated node list based on the allocated new candidate node. As another implementation method, the update request can include marking information of the candidate node, and the marking information of the candidate node includes an unavailable mark, which is used to indicate that the candidate node is an unavailable node, that is, the candidate node cannot serve as a worker for the first node. At this time, allocating a new candidate node to the first node according to the principle of global load balancing can be: the global load service device can reallocate a new candidate node to the first node according to the principle of global load balancing, and use the new candidate node to replace the candidate node with the unavailable mark in the original node list to obtain an updated node list.
[0163] In one possible implementation, the first node may establish a communication connection with each candidate node in the node list after receiving the node list assigned by the global load service device. In another possible implementation, the first node may select a candidate node in the node list that does not contain an unavailable mark before establishing a communication connection with the selected candidate node. It should be understood that after receiving the updated node list returned by the global load service device, the first node may update the communication connection on the node side based on the updated node list, for example: disconnect the communication connection with the candidate nodes in the original node list, and re-establish a new communication connection with each candidate node in the updated node list.
[0164] It should be noted that each node in the data system can send its own allocation request to the global load service device, so that the global load service device allocates a corresponding node list to each node according to the principle of global load balancing. Among them, the number of candidate nodes in the node list allocated by the global load service device to each node can be the same or different. The specific implementation process of the global load service device allocating a corresponding node list to each node according to the principle of global load balancing can be referred to the specific implementation method of the global load service device allocating a node list to the first node according to the principle of global load balancing, which will not be repeated here.
[0165] In the embodiment of the present application, by setting up a global load service device, it is possible to achieve unified management of the node information and load information of each node in the data system, thereby improving management effectiveness. In addition, the global load service device can allocate a node list to each node based on the principle of global load balancing, so that the resources of each node in the data system can be fully dispatched under the premise of ensuring the global load balancing of the data system, thereby improving the global service capability of the data system and the ability to cope with load overload problems.
[0166] The following is a detailed introduction to the selection process of the second node mentioned in the embodiments of the present application.
[0167] The first node maintains a node list assigned to the first node by the global load service device, and the first node selects the second node from the data system, which may include: selecting a candidate node from the node list according to a preset rule to determine it as the second node. The preset rule includes at least one of the following: sequential selection, random selection, and selection based on the priority of the candidate node; wherein the setting factor of the priority of the candidate node includes at least one of the following: load, network overhead, and cluster. 1) The lower the load of the candidate node, the higher the priority of the candidate node. For example, if the load of candidate node 1 contains 10 tasks to be processed and the load of candidate node 2 contains 30 tasks to be processed, then the priority of candidate node 1 will be higher than the priority of candidate node 2. 2) The less the network overhead between the candidate node and the first node, the higher the priority of the candidate node. 3) If the candidate node and the first node belong to different clusters, the higher the priority of the candidate node. It should be understood that the priority of the candidate node can be determined based on multiple setting factors in the load, network overhead, and cluster. For example, the priority of the candidate node is determined based on the network cost and the load. When the network cost of candidate node 1 is less than that of candidate node 2, and the load of candidate node 1 is less than that of candidate node 2, the priority of candidate node 1 is higher than that of candidate node 2. For another example, the priority of the candidate node is determined based on the network cost and the load. At this time, the weights of each setting factor can be set, such as the weight of the network cost is 0.7, and the weight of the load is 0.3; the priority of the candidate node is set comprehensively by setting the weights; assuming that the network cost of candidate node 1 is less than that of candidate node 2, and the load of candidate node 1 is greater than that of candidate node 2; the network cost and load of candidate node 1 can be weighted and summed, and the network cost and load of candidate node 2 can be weighted and summed respectively. If the weighted sum value corresponding to candidate node 1 is greater than the weighted sum value corresponding to candidate node 2, then the priority of candidate node 1 will be higher than that of candidate node 2.
[0168] The method of selecting a candidate node from the node list according to a preset rule to determine as the second node may include at least one of the following:
[0169] Method 1: The preset rule is sequential selection or random selection.
[0170] Selecting an alternative node from the node list according to a preset rule to determine it as the second node includes: ① traversing the node list, selecting an alternative node from the node list in order or randomly. ② Determining whether the selected alternative node contains an unavailable mark. ③ If the selected alternative node does not contain an unavailable mark, the selected alternative node can be determined as the second node. If the selected alternative node contains an unavailable mark, a new alternative node is selected from the node list again, and steps ② to ③ in method one are continued.
[0171] Method 2: The preset rule is to select based on the priority of the candidate nodes.
[0172] Selecting an alternative node from the node list as the second node according to preset rules includes: ① traversing the node list, and selecting an alternative node from the node list in descending order of priority, that is, selecting an alternative node with the highest priority from the node list each time. ② Determine whether the selected alternative node contains an unavailable mark. ③ If the selected alternative node does not contain an unavailable mark, the selected alternative node can be determined as the second node. If the selected alternative node contains an unavailable mark, a new alternative node is reselected from the node list, and steps ② to ③ in method two are continued. Among them, a polling scheduling algorithm (such as Round Robin algorithm) can be used to traverse the node list.
[0173] Method 3: After selecting candidate nodes that do not contain unavailable marks according to method 1 or method 2, further screening is performed through a preprocessing method.
[0174] Through method one or method two, if the selected candidate node does not contain an unavailable mark, the first node can also perform the following steps to screen and determine the second node: ④ Send a preprocessing request to the selected candidate node. ⑤ If an acceptance response returned by the selected candidate node is received within a preset response time (which can be flexibly set as needed, for example, the preset response time can be set to 2 seconds, 10 seconds, etc.), the selected candidate node is determined as the second node. ⑥ If an acceptance response returned by the selected candidate node is not received within the preset response time, or a rejection response returned by the selected candidate node is received within the preset response time, an unavailable mark is added to the selected candidate node in the node list; and, according to the preset rules, a new candidate node is re-selected from the node list to determine the second node.
[0175] Among them, the pre-processing request is used to indicate that the first node needs to transfer the load, that is, to send the stateless task to be processed. The candidate node can give feedback to the pre-processing request according to its own load situation. Indicatively, if the candidate node is in an idle state or the current load of the candidate node is less than the load threshold (that is, its own load is low), the current load of the candidate node refers to the load that the candidate node is processing. At this time, the candidate node can return an acceptance response to the first node within a preset response time. The acceptance response is used to indicate that the candidate node can process the stateless task that the first node is about to send and accept the load transfer requirement of the first node. After the first node obtains the acceptance response, it can use the selected candidate node as the second node. If the current load of the candidate node is greater than or equal to the load threshold (that is, its own load is too high), at this time, the selected candidate node can return a rejection response to the first node within a preset response time or do not make any response to the first node; wherein, the rejection response is used to indicate that the selected candidate node cannot process the stateless task that the first node is about to send and does not accept the load transfer requirement of the first node.
[0176] To understand the above method 3, please refer to Figure 5 , Figure 5 A flow chart of determining a second node from a node list is provided for an exemplary embodiment of the present application. The flow of determining a second node from a node list may include the following steps: s51: The first node traverses the node list, which contains n candidate nodes (such as n is 10), namely candidate node-1, candidate node-2... candidate node-n. Then select candidate node-1 from the node list according to a preset rule (such as selecting in order). s52: If candidate node-1 does not contain an unavailable mark, the first node sends a pre-processing request to candidate node-1. s53: If the acceptance response returned by candidate node-1 is not received within the preset response time, the first node continues to traverse the node list and reselects candidate node-2 from the candidate nodes that are not selected in the node list according to the preset rules. s54: If candidate node-2 does not contain an unavailable mark, the first node sends a pre-processing request to candidate node-2. s55: If a rejection response returned by candidate node-2 is received within the preset response time, s56 is triggered. s56: The first node continues to traverse the node list and reselects candidate node-3 from the candidate nodes that have not been selected in the node list according to the preset rule. s57: If candidate node-3 does not contain an unavailable mark, a preprocessing request is sent to the second node to candidate node-3. And so on, until the first node successfully selects the second node from the node list.
[0177] In one possible implementation, if the first node has traversed the node list and still has not successfully selected the second node from the node list according to the preset rules, that is, all candidate nodes in the node list may not return an acceptance response within the preset response time or may have returned a rejection response within the preset response time, the first node may handle the stateful task on its own, or the first node may resend an update request to the global load service device and reselect a new second node based on the updated node list returned by the global load service device.
[0178] In the above-mentioned method 3, each time the first node selects a candidate node from the node list, it can send a preprocessing request to the selected candidate node. In addition, the first node can also select multiple candidate nodes from the node list at one time, and send preprocessing requests to multiple candidate nodes at the same time, so as to quickly determine the candidate node that can process the stateless task. For example: when there are multiple candidate nodes that all return an acceptance response, one can be randomly selected from the multiple candidate nodes that return an acceptance response to be determined as the second node; or the first candidate node that returns an acceptance response can be quickly determined as the second node; and so on.
[0179] It should be understood that, assuming that the candidate node selected according to the random selection rule included in the preset rule is marked as unavailable, then in the process of reselecting a new candidate node from the node list according to the preset rule, the new candidate node can continue to be selected from the node list according to the random selection rule. Of course, the new candidate node can also be selected from the node list according to other rules in the preset rule except the random selection rule (such as selection based on the priority of the candidate node), that is, the embodiment of the present application does not impose any limitation on the preset rule.
[0180] As mentioned above, the selection method of the second node (worker) is very flexible. Method 1 or method 2 can be used to directly select an alternative node that does not contain an unavailable mark from the node list to determine the second node; method 3 can also be used to further screen the selected alternative nodes through preprocessing requests to determine the second node; by selecting the second node in a flexible manner, the success rate of woker selection can be guaranteed to a certain extent, and the success rate of load transfer can be guaranteed.
[0181] Below Figure 3 Some contents in the illustrated embodiments are supplemented for introduction.
[0182] In one embodiment, before executing step S301, the first node may further execute the following steps:
[0183] (1) Receive a load processing request from a business system, and obtain a stateful task to be processed in response to the load processing request; wherein the business system may include but is not limited to: a data information collection system, a door access control processing system, etc. (2) Perform pre-processing on the stateful task, for example, the above Figure 2 In the example, the stateful task is a stateful data writing task, and the pre-processing may include but is not limited to: parameter checking, whether to delay execution, judging whether the primary shard has been migrated, etc. (3) Detecting the load information of the first node; if the current load indicated by the load information of the first node is greater than or equal to the load threshold, determining that the load of the first node is overloaded. If the current load indicated by the load information of the first node is less than the load threshold, the first node may directly process the stateful task.
[0184] In one embodiment, the conversion of the stateful task to be processed in the first node into a stateless task in step S302 may include: extracting a target subtask from the stateful task, the target subtask including a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent of other subtasks in the stateful task; and then encapsulating the extracted target subtask into a stateless task. Figure 2 In the write data subtask (for example, the write data subtask can be Figure 2 The subtask corresponding to "write each record sequentially" in the data write task consumes more resources, and the data write subtask is relatively independent of other subtasks (such as detecting write consistency, determining whether the primary shard has been migrated, etc.). At this time, the data write subtask (that is, the target subtask) can be extracted from the data write task and encapsulated as a stateless task.
[0185] In one embodiment, the target subtask is a data writing subtask, and the specific implementation method of the first node encapsulating the extracted target subtask into a stateless task may include: (1) obtaining the data information to be written corresponding to the data writing subtask and the metadata information of the data information; (2) encapsulating the data information and the metadata information of the data information into a stateless task. The data information may be a document, picture, etc. to be written. The data information may be determined according to different business systems. For example, a business system may include a data (such as an experimental log) collection system, and the data information is the experimental log information. For another example, a business system may include an access control system, and the data information may be information about objects entering the access control. The metadata information of the data information is used to define the processing method of the data information to be written. The metadata information of the data information may include the field name, field data type, field index type, etc. of the data information to be written.
[0186] Taking the data system as ElasticSearch as an example, the data writing subtask can include two parts, namely writing to lucene and writing to translog. Among them, when writing data information to lucene, it is necessary to know the data information written to the index index and the metadata information of the data information (such as mapping metadata). Among them, in an embodiment of the present application, the first node can encapsulate the data information to be written and the metadata information required by the data information (such as mapping metadata) as a stateless task.
[0187] In a big data business scenario, the load processing request of the business system can generally be a batch processing request. At this time, the write data subtask is generally a batch write subtask, that is, when the number of data information to be written contained in the write data subtask is multiple, then the granularity of the stateless task in the embodiment of the present application is also the bulk granularity. Of course, the granularity of the stateless task in the embodiment of the present application can be multiple bulk granularities. For example, there are multiple write data subtasks in the first node, and each write data subtask is a batch write subtask. At this time, multiple write data subtasks can be encapsulated into a stateless task. At this time, the data information in each write data subtask and the metadata information corresponding to the data information need to be encapsulated into a stateless task. In addition, the granularity of the stateless task can be a single write granularity, that is, the number of data information to be written contained in the write data subtask is 1.
[0188] In one embodiment, when the stateless task includes data information and metadata information of the data information, the processing information returned by the second node may include one or more file fragments obtained after the data information is written, then in step S304, the first node performs post-processing on the processing information returned by the second node, and the processing result of the stateful task may include: (1) determining the file shard to which the one or more file fragments belong; the file shard may refer to the primary shard on the first node, or the secondary shard corresponding to the primary shard on the first node. (2) obtaining the directory corresponding to the file shard, and writing one or more file fragments into the directory; (3) updating the metadata information of the file shard, and the metadata information of the file shard is used to define the storage and indexing method of each file fragment in the file shard.
[0189] Furthermore, the processing information returned by the second node may also include one or more log information generated during the process of writing the data information. Then in step S304, the first node performs post-processing on the processing information returned by the second node to obtain the processing result of the stateful task, which also includes: (4) adding (append) one or more log information in sequence to the log file corresponding to the stateful task in the first node. Among them, the writing of log information is a sequential append mode, that is to say, the sequential here refers to the order in which the data information is executed during the writing process. When the number of data information is multiple, each data information corresponds to a log information. At this time, the corresponding log information is added to the corresponding log file in the first node of the stateful task according to the writing order of each data information.
[0190] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0191] See also Figure 6 , Figure 6 A flowchart of a data processing method provided for an exemplary embodiment of the present application; the method can be applied to a data system. The data system can include multiple nodes, and the method can be executed by a second node, which can be any node in the data system. The data processing method provided in the embodiment of the present application may include steps S601-S603:
[0192] S601, receiving a task processing request sent by a first node in a data system, the first node being any node in the data system except a second node; the task processing request includes a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded. The second node is determined based on the principle of global load balancing of the data system.
[0193] In one embodiment, before receiving the task processing request sent by the first node in the data system, the second node may receive the pre-processing request sent by the first node, and return an acceptance response to the first node based on the pre-processing request within a preset response time. The task processing request is sent after the first node receives the acceptance response returned by the second node.
[0194] The nodes in the data system may include one or more of data nodes and independent nodes. The data nodes may be distributed in one or more clusters in the data system, and the independent nodes are independently set in the data system. In one embodiment, the first node may be a data node, and the second node may be a data node or an independent node. When the first node is a data node and the second node is a data node, the first node and the second node may belong to the same cluster in the data system, or may belong to different clusters in the data system. A global load service device is provided in the data system, and the global load service device allocates a node list to the first node, and the node list includes one or more candidate nodes; the second node is an alternative node selected by the first node from the node list; the stateless task is obtained by encapsulating the target subtask extracted from the stateful task; the stateful task includes one or more subtasks; the target subtask includes a subtask in the stateful task whose resource consumption is greater than the resource threshold, and the target subtask is relatively independent from other subtasks in the stateful task.
[0195] Among them, the data system includes a stateful data system; the stateful task includes a data writing task, and the target subtask can be a data writing subtask; the stateless task includes the data information to be written corresponding to the data writing subtask and the metadata information of the data information.
[0196] S602: In response to the task processing request, the stateless task is processed to obtain processing information.
[0197] In one embodiment, the stateless task includes the data information to be written and the metadata information of the data information corresponding to the data writing subtask. At this time, step S602 may include: in response to the task processing request, creating a temporary index writing class (i.e., IndexWriter) in the memory of the second node, and calling the temporary index writing class to write the data information based on the metadata information of the data information to obtain one or more file fragments; and then generating processing information based on the one or more file fragments. Through the temporary index writing class, the second node does not need to care about the specific directory information.
[0198] As an implementation method, the second node calls the temporary index write class, and writes the data information based on the metadata information of the data information. The process of obtaining one or more file fragments may include: ① first parse the data information to obtain the document (document) corresponding to the data information; ② call the temporary index write class to write the document into the index cache structure in the RamDisk disk based on the metadata information of the data information; ③ refresh the document in the index cache structure to obtain one or more file fragments.
[0199] In one embodiment, in response to a task processing request, the stateless task is processed to obtain processing information, and further includes: creating a temporary log class in the memory of the second node; in the process of executing write processing based on the data information, calling the temporary log class to generate one or more log information, and generating processing information based on the one or more log information. Specifically, when the number of data information is one or more, the temporary log class can be called to generate log information corresponding to each data information written into the index cache structure, and finally one or more log information can be obtained.
[0200] Among them, the memory of the second node can be a RamDisk disk (i.e., a virtual memory disk). The second node creates a temporary index write class and a temporary log class in the RamDisk disk (i.e., a virtual memory disk) of the second node, and then calls the temporary index write class and the temporary log class to generate one or more file fragments and one or more log information. The RamDisk disk can efficiently generate file fragments and log information, thereby improving the task processing efficiency. The above processing information may include at least one of the following: one or more file fragments, one or more log information.
[0201] S603: Return the processing information to the first node, so that the first node performs post-processing on the processing information to obtain a processing result of the stateful task.
[0202] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0203] For ease of understanding, the present application embodiment provides a specific example to illustrate the data processing method provided in the present application embodiment, see Figure 7 , Figure 7 A flowchart of a data processing method provided for an exemplary embodiment of the present application. The method is applied to a data system, and taking the data system as a system built based on ElasticSearch as an example, the data system includes multiple nodes, and the nodes in the data system may include data nodes and independent nodes. The data nodes are distributed in one or more ES clusters of the data system, and the independent nodes are independent of the ES clusters. In this case, the data processing method includes:
[0204] (1) The first node in an ES cluster receives a batch write request (corresponding to the above-mentioned load processing request) sent by the business system. The batch write request includes a data write task to be processed. The data write task to be processed includes a write data subtask. The write data subtask includes multiple pieces of data information to be written. Then, the first node performs pre-processing on the data write task to be processed.
[0205] (2) After the first node completes the pre-processing of the data writing task, it enters the processing of the data writing subtask in the data writing task. At this time, it is necessary to check the current load of the first node.
[0206] (3) The first node determines whether the current load of the node is greater than or equal to the load threshold. If the first node determines that the current load of the node is greater than or equal to the load threshold, it determines that the load of the first node is overloaded and executes step (5); if the first node determines that the current load of the node is less than the load threshold, it executes step (4).
[0207] (4) If the first node determines that the current load of the node is less than the load threshold, the first node can continue to process the data writing subtask according to the original processing logic (ie, the three stages of the data writing task).
[0208] (5) If the first node determines that the current load of the node is greater than or equal to the load threshold, a data writing subtask is extracted from the data writing task, and the data writing subtask is encapsulated as a stateless task. Specifically: the plurality of data information to be written and the metadata information corresponding to the data information are encapsulated as a stateless task.
[0209] (6) The first node can select a second node (such as a data node) from the data system according to a preset rule. Specifically, the first node maintains a node list. Taking the selection of alternative priorities based on the preset rule as an example, the first node can select the alternative node with the highest priority in the node list according to the priority of the alternative nodes from high to low. If the selected alternative node with the highest priority does not contain an unavailable mark, the first node determines the alternative node with the highest priority as the second node. If the selected alternative node with the highest priority contains an unavailable mark, then according to the priority of the alternative nodes from high to low, continue to select the alternative node with the highest priority from the alternative nodes not selected in the node list. If the selected alternative node with the highest priority does not contain an unavailable mark, then determine the alternative node with the highest priority as the second node, otherwise, according to the priority of the alternative nodes from high to low, continue to select the alternative node with the highest priority from the alternative nodes not selected in the node list until the alternative node is finally successfully selected as the second node. If none of the alternative nodes in the node list can be used as the second node, the data writing subtask can be processed according to the original processing logic (i.e., the three stages of the data writing task).
[0210] After selecting the second node, the first node encapsulates the stateless task into a remote batch processing (RemoteBulkRequest) request (ie, the above-mentioned task processing request), and then sends the RemoteBulkRequest request to the second node; the second node receives the RemoteBulkRequest request sent by the first node.
[0211] (7) After receiving the RemoteBulkRequest request, the second node may create a temporary write index class and a temporary log class in the RamDisk of the second node.
[0212] (8) The second node can call the temporary write index class, based on the metadata information corresponding to the multiple data information to be written, write each data information into the index cache structure in turn, and refresh the data information written into the index cache structure to obtain one or more file fragments.
[0213] (9) When each piece of data information is written into the index cache structure, one or more log information may be generated according to the order in which each piece of data information is written into the index cache structure.
[0214] (10) After completing writing of each of the multiple data information, the second node may generate processing information based on the written one or more file fragments and one or more log information, encapsulate the processing information into a RemoteBulkResponse (remote bulk reply request), and return the RemoteBulkResponse to the first node.
[0215] (11) When the first node receives the RemoteBulkResponse, it obtains the processing information from the RemoteBulkResponse and performs post-processing on the processing information. Specifically, it obtains the file shards to which one or more file fragments belong, and writes the one or more file fragments in the processing information into the directory corresponding to the file shards. Furthermore, the first node may write one or more log information into the log file corresponding to the data writing task.
[0216] (12) After completing the post-processing of the processing information, the first node may return feedback information to the business system, where the feedback information is used to indicate that the writing of the plurality of data information has been completed.
[0217] In actual experiments, under the operation of multiple clusters of ES, the proportion of CPU resources used by the data writing subtask in the data writing task is about 50%, and the data processing method provided in the embodiment of the present application can produce the following beneficial effects: 1) By converting the stateful tasks of the nodes in a certain cluster into stateless tasks and handing them over to the nodes with low load that are not related to the source cluster (i.e. the cluster where the first node is located) for processing, the upper limit of the single cluster capacity is increased to about 2 times of the previous one, which can cope with the writing of larger-scale data. 2) Although the horizontal expansion mechanism can alleviate some of the load, due to the state, the load balancing time within the cluster is relatively long. When there are many resources in the cluster, such as indexes, it takes hours, and the resources within the cluster are limited in scale. The load transfer in the embodiment of the present application (i.e. converting stateful tasks into stateless tasks and handing them over to other nodes for processing) is shorter than the time spent on load balancing by expansion, which can well solve the problems of sudden increase in write traffic and occasional timeout of ultra-large-scale data analysis. 3) The load of a node in a cluster is transferred to nodes in other clusters with lower loads for processing. According to the different peaks of different clusters, multi-cluster load balancing can be achieved, which improves the overall utilization of resources and effectively reduces the overall cost.
[0218] Next, a description is given of the data processing device provided in the embodiment of the present application.
[0219] See also Figure 8 , Figure 8 is a structural diagram of a data processing device provided in an embodiment of the present application. The data processing device may be arranged in a first node of a data system. The first node is any node among a plurality of nodes included in the data system. The data processing device may be a computer program (including program code) in the first node. For example, the data processing device may be an application software in the first node. The data processing device may be used to execute Figure 3 Some or all of the steps in the method embodiment shown. Figure 8 , the data processing device comprises the following units:
[0220] The processing unit 801 is configured to select a second node from the data system when the load of the first node is overloaded, where the second node refers to any node in the data system except the first node; the second node is determined based on the principle of global load balancing of the data system;
[0221] The processing unit 801 is further configured to convert a stateful task to be processed in the first node into a stateless task;
[0222] A sending unit 802 is used to send a task processing request to the second node, wherein the task processing request carries a stateless task, and the task processing request is used to request the second node to process the stateless task and return processing information;
[0223] The processing unit 801 is further used to perform post-processing on the processing information returned by the second node to obtain the processing result of the stateful task.
[0224] In one embodiment, the nodes in the data system include one or more of data nodes and independent nodes, the data nodes are distributed in one or more clusters in the data system, and the independent nodes are independently set in the data system;
[0225] The load overload of the first node includes at least one of the following: the current load of the first node is greater than or equal to the load threshold; the resources consumed to process the stateful task exceed the available resources of the first node; the first node will affect the processing process of the current task in the first node when processing the stateful task.
[0226] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage the node information and load information of each node in the data system; the device also includes a receiving unit 803, wherein:
[0227] The sending unit 802 is further configured to send an allocation request to the global load service device, where the allocation request is used to request the global load service device to allocate a backup node to the first node;
[0228] The receiving unit 803 is used to receive a node list allocated by the global load service device, wherein the node list includes one or more candidate nodes; the candidate node refers to any node in the data system except the first node;
[0229] Among them, the global load service equipment is allocated based on the principle of global load balancing of the data system. The principle of global load balancing of the data system includes at least one of the following: allocating alternative nodes in order of load from small to large; allocating alternative nodes in order of network overhead between the first node from small to large; and giving priority to allocating nodes belonging to different clusters from the first node as alternative nodes.
[0230] In one embodiment, the processing unit 801 is specifically configured to:
[0231] Selecting a candidate node from the node list as the second node according to a preset rule; the preset rule includes at least one of the following: sequential selection, random selection, and selection based on the priority of the candidate node;
[0232] Among them, the setting factors of the priority of the alternative node include at least one of the following: load, network overhead and cluster; the lower the load of the alternative node, the higher the priority of the alternative node; the less the network overhead between the alternative node and the first node, the higher the priority of the alternative node; the alternative node and the first node belong to different clusters, the higher the priority of the alternative node.
[0233] In one embodiment, the preset rule is sequential selection or random selection; the processing unit 801 is specifically used to:
[0234] Traverse the node list and select a candidate node in order or randomly from the node list;
[0235] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0236] In one embodiment, the preset rule is to select the candidate nodes according to their priorities; the processing unit 801 is specifically configured to:
[0237] Traverse the node list and select a candidate node from the node list in descending order of priority;
[0238] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0239] In one embodiment, the processing unit 801 is specifically configured to:
[0240] Sending a preprocessing request to the selected candidate node;
[0241] If an acceptance response returned by the selected candidate node is received within a preset response time, the selected candidate node is determined as the second node;
[0242] If an acceptance response is not received from the second node within the preset response time, or a rejection response is received from the selected alternative node within the preset response time, an unavailable mark is added to the node list for the selected alternative node; and, according to the preset rules, a new alternative node is reselected from the node list to determine the second node.
[0243] In one embodiment, the processing unit 801 is further configured to:
[0244] If the processing information returned by the second node is received within the preset response time, a step of performing post-processing on the processing information returned by the second node to obtain a processing result of the stateful task is performed;
[0245] If the processing information returned by the second node is not received within the preset response time, or if the processing rejection information returned by the second node is received within the preset response time, an unavailable mark is added to the node list; and a new second node is selected from the node list.
[0246] In one embodiment, a stateful task includes one or more subtasks; the processing unit 801 is specifically configured to:
[0247] Extracting a target subtask from a stateful task, the target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent of other subtasks in the stateful task;
[0248] Encapsulate the extracted target subtask into a stateless task.
[0249] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; the processing unit 801 is specifically used to:
[0250] Obtain the data information to be written and the metadata information of the data information corresponding to the data writing subtask, where the metadata information of the data information is used to define the processing method of the data information to be written;
[0251] Encapsulate data information and metadata information of data information into stateless tasks.
[0252] In one embodiment, the processing information returned by the second node includes one or more file fragments obtained after the data information is written; the processing unit 801 is specifically used to:
[0253] Determine the file shard to which one or more file fragments belong;
[0254] Get the directory corresponding to the file segment;
[0255] Write one or more file fragments to a directory, and,
[0256] Update the metadata information of the file shard. The metadata information of the file shard is used to define the storage and indexing method of each file fragment in the file shard.
[0257] In one embodiment, the processing information returned by the second node also includes one or more log information generated during the writing process of the data information; the processing unit 801 is further used to:
[0258] Add one or more log information in sequence to the log file corresponding to the stateful task in the first node.
[0259] In one embodiment, the processing unit 801 is further configured to:
[0260] Responding to the load processing request sent by the business system, obtaining the stateful tasks to be processed;
[0261] Performing pre-processing on the stateful task and detecting load information of the first node; and,
[0262] After post-processing the processing information returned by the second node to obtain the processing result of the stateful task, feedback information is output to the business system.
[0263] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0264] See also Fig. 9 , Fig. 9is a structural diagram of a data processing device provided in an embodiment of the present application. The data processing device may be arranged in a second node of a data system, and the second node is any node among a plurality of nodes included in the data system; the data processing device may be a computer program (including program code) in the second node, for example, the data processing device may be an application software in the second node; the data processing device may be used to execute Figure 6 Some or all of the steps in the method embodiment shown.
[0265] See also Fig. 9 , the data processing device comprises the following units:
[0266] The receiving unit 901 is used to receive a task processing request sent by a first node in the data system, where the first node refers to any node in the data system except the second node; the task processing request includes a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the load of the first node is overloaded; the second node is determined based on the principle of global load balancing of the data system;
[0267] The processing unit 902 is used to process the stateless task in response to the task processing request to obtain processing information;
[0268] The sending unit 903 is used to return the processing information to the first node, so that the first node performs post-processing on the processing information to obtain the processing result of the stateful task.
[0269] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage node information and load information of each node in the data system; based on the principle of global load balancing of the data system, the global load service device allocates a node list to the first node, and the node list includes one or more candidate nodes; the second node is a candidate node selected by the first node from the node list;
[0270] A stateless task is obtained by encapsulating the target subtask extracted from a stateful task;
[0271] A stateful task includes one or more subtasks; a target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent from other subtasks in the stateful task.
[0272] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; the stateless task includes data information to be written corresponding to the data writing subtask and metadata information of the data information;
[0273] The processing unit 902 is specifically configured to:
[0274] In response to the task processing request, creating a temporary index write class in the memory of the second node;
[0275] Call the temporary index writing class to write the data information based on the metadata information of the data information to obtain one or more file fragments;
[0276] Based on the one or more file segments, processing information is generated.
[0277] In one embodiment, the processing unit 902 is further configured to:
[0278] Create a temporary log class in the memory of the second node;
[0279] Based on the process of data information being written, a temporary log class is called to generate one or more log information;
[0280] Generate processing information based on one or more log information.
[0281] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0282] Next, the first node and the second node provided in the embodiment of the present application are described.
[0283] Furthermore, the present application embodiment also provides a schematic diagram of the structure of a computer device. The schematic diagram of the structure of the computer device can be found in Fig.10The computer device may include: a processor 1001, an input device 1002, an output device 1003 and a memory 1004. The processor 1001, the input device 1002, the output device 1003 and the memory 1004 are connected via a bus. The memory 1004 is used to store a computer program, the computer program includes program instructions, and the processor 1001 is used to execute the program instructions stored in the memory 1004.
[0284] In one embodiment, the computer device runs a first node in a data system, where the first node is any node in a plurality of nodes in the data system; in this embodiment, the processor 1001 performs the following operations by running the executable program code in the memory 1004:
[0285] When the load of the first node is overloaded, a second node is selected from the data system, where the second node refers to any node in the data system except the first node; the second node is determined based on the principle of global load balancing of the data system;
[0286] Converting a stateful task to be processed in the first node into a stateless task;
[0287] Sending a task processing request to the second node, the task processing request carrying the stateless task, the task processing request being used to request the second node to process the stateless task and return processing information;
[0288] Post-process the processing information returned by the second node to obtain the processing result of the stateful task.
[0289] In one embodiment, the nodes in the data system include one or more of data nodes and independent nodes, the data nodes are distributed in one or more clusters in the data system, and the independent nodes are independently set in the data system;
[0290] The load overload of the first node includes at least one of: the current load of the first node is greater than or equal to the load threshold; the resources consumed to process the stateful task exceed the available resources of the first node; the processing of the stateful task by the first node will affect the processing process of the current task in the first node.
[0291] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage node information and load information of each node in the data system; the processor 1001 may further perform the following steps:
[0292] Sending an allocation request to a global load service device, where the allocation request is used to request the global load service device to allocate a backup node to the first node;
[0293] Receiving a node list assigned by a global load service device, the node list including one or more candidate nodes; the candidate node refers to any node in the data system except the first node;
[0294] Among them, the global load service equipment is allocated based on the principle of global load balancing of the data system. The principle of global load balancing of the data system includes at least one of the following: allocating alternative nodes in order of load from small to large; allocating alternative nodes in order of network overhead between the first node from small to large; and giving priority to allocating nodes belonging to different clusters from the first node as alternative nodes.
[0295] In one embodiment, when the processor 1001 executes the step of selecting the second node from the data system, the processor 1001 may specifically execute the following steps:
[0296] Selecting a candidate node from the node list as the second node according to a preset rule; the preset rule includes at least one of the following: sequential selection, random selection, and selection based on the priority of the candidate node;
[0297] Among them, the setting factors of the priority of the alternative node include at least one of the following: load, network overhead and cluster; the lower the load of the alternative node, the higher the priority of the alternative node; the less the network overhead between the alternative node and the first node, the higher the priority of the alternative node; the alternative node and the first node belong to different clusters, the higher the priority of the alternative node.
[0298] In one embodiment, the preset rule is sequential selection or random selection; when the processor 1001 executes the step of selecting a candidate node from the node list according to the preset rule to determine as the second node, the processor 1001 may specifically execute the following steps:
[0299] Traverse the node list and select a candidate node in order or randomly from the node list;
[0300] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0301] In one embodiment, the preset rule is to select the candidate node according to its priority; when the processor 1001 executes the step of selecting the candidate node from the node list according to the preset rule to determine it as the second node, the processor 1001 specifically executes the following steps:
[0302] Traverse the node list and select a candidate node from the node list in descending order of priority;
[0303] If the selected candidate node does not include an unavailable mark, the selected candidate node is determined as the second node.
[0304] In one embodiment, when the processor 1001 executes the step of determining the selected candidate node as the second node if the selected candidate node does not include an unavailable mark, the processor 1001 specifically executes the following steps:
[0305] Sending a preprocessing request to the selected candidate node;
[0306] If an acceptance response returned by the selected candidate node is received within a preset response time, the selected candidate node is determined as the second node;
[0307] If an acceptance response is not received from the second node within a preset response time, or a rejection response is received from the selected candidate node within a preset response time, an unavailable mark is added to the node list for the selected candidate node; and,
[0308] A new candidate node is reselected from the node list according to a preset rule to determine the second node.
[0309] In one embodiment, the processor 1001 may further perform the following steps:
[0310] If the processing information returned by the second node is received within the preset response time, a step of performing post-processing on the processing information returned by the second node to obtain a processing result of the stateful task is performed;
[0311] If the processing information returned by the second node is not received within the preset response time, or if the processing rejection information returned by the second node is received within the preset response time, an unavailable mark is added to the node list for the second node; and,
[0312] Reselect a new second node from the node list.
[0313] In one embodiment, a stateful task includes one or more subtasks; the processor 1001 executes the step of converting the stateful task to be processed in the first node into a stateless task, specifically performing the following steps:
[0314] Extracting a target subtask from a stateful task, the target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent of other subtasks in the stateful task;
[0315] Encapsulate the extracted target subtask into a stateless task.
[0316] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; when the processor 1001 executes the step of encapsulating the extracted target subtask into a stateless task, the processor 1001 specifically executes the following steps:
[0317] Obtain the data information to be written and the metadata information of the data information corresponding to the data writing subtask, where the metadata information of the data information is used to define the processing method of the data information to be written;
[0318] Encapsulate data information and metadata information of data information into stateless tasks.
[0319] In one embodiment, the processing information returned by the second node includes one or more file fragments obtained after the data information is written; when the processor 1001 performs post-processing on the processing information returned by the second node to obtain the processing result of the stateful task, the processor 1001 specifically performs the following steps:
[0320] Determine the file shard to which one or more file fragments belong;
[0321] Get the directory corresponding to the file segment;
[0322] Write one or more file fragments to a directory, and,
[0323] Update the metadata information of the file shard. The metadata information of the file shard is used to define the storage and indexing method of each file fragment in the file shard.
[0324] In one embodiment, the processing information returned by the second node also includes one or more log information generated during the writing process of the data information; when the processor 1001 performs post-processing on the processing information returned by the second node to obtain the processing result of the stateful task, it also performs the following steps:
[0325] Add one or more log information in sequence to the log file corresponding to the stateful task in the first node.
[0326] In one embodiment, the processor 1001 further performs the following steps:
[0327] Responding to the load processing request sent by the business system, obtaining the stateful tasks to be processed;
[0328] Performing pre-processing on the stateful task and detecting load information of the first node; and,
[0329] After post-processing the processing information returned by the second node to obtain the processing result of the stateful task, feedback information is output to the business system.
[0330] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0331] In another embodiment, the computer device may run a second node in the data system, where the second node is any node in the plurality of nodes in the data system; in this embodiment, the processor 1001 performs the following operations by running the executable program code in the memory 1004:
[0332] receiving a task processing request sent by a first node in the data system, the first node being any node in the data system except the second node; the task processing request comprising a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded; the second node is determined based on a principle of global load balancing of the data system;
[0333] In response to the task processing request, the stateless task is processed to obtain processing information;
[0334] The processing information is returned to the first node, so that the first node performs post-processing on the processing information to obtain a processing result of the stateful task.
[0335] In one embodiment, a global load service device is provided in the data system, and the global load service device is used to manage node information and load information of each node in the data system; based on the principle of global load balancing of the data system, the global load service device allocates a node list to the first node, and the node list includes one or more candidate nodes; the second node is a candidate node selected by the first node from the node list;
[0336] A stateless task is obtained by encapsulating the target subtask extracted from a stateful task;
[0337] A stateful task includes one or more subtasks; a target subtask includes a subtask whose resource consumption is greater than a resource threshold in the stateful task, and the target subtask is relatively independent from other subtasks in the stateful task.
[0338] In one embodiment, the data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; the stateless task includes data information to be written corresponding to the data writing subtask and metadata information of the data information;
[0339] When the processor 1001 executes the step of processing the stateless task to obtain processing information in response to the task processing request, the processor 1001 specifically executes the following steps:
[0340] In response to the task processing request, creating a temporary index write class in the memory of the second node;
[0341] Call the temporary index writing class to write the data information based on the metadata information of the data information to obtain one or more file fragments;
[0342] Based on the one or more file segments, processing information is generated.
[0343] In one embodiment, when the processor 1001 executes the step of processing the stateless task to obtain processing information in response to the task processing request, the processor 1001 further executes the following steps:
[0344] Create a temporary log class in the memory of the second node;
[0345] Based on the process of data information being written, a temporary log class is called to generate one or more log information;
[0346] Generate processing information based on one or more log information.
[0347] In an embodiment of the present application, when the first node in the data system is overloaded, the stateful task to be processed in the first node can be converted into a stateless task, and the stateless task can be transferred to the second node in the data system for processing, and the second node is determined based on the principle of global load balancing of the data system; the first node obtains the processing information obtained from the second node after processing, and performs post-processing to obtain the processing result of the stateful task. In the above scheme, based on the principle of global load balancing, the second node is selected to process the pending tasks in the first node on behalf of the first node, which not only solves the problem that the first node is overloaded and cannot provide normal services, and ensures that the pending tasks can be processed in time, but also ensures the global load balancing of the data system to a certain extent; in addition, by converting stateful tasks into stateless tasks, the state interaction between the first node and the second node can be reduced, the load of the first node and the second node can be reduced, and the global load balancing of the data system can be further ensured, which is conducive to improving the global service capability of the data system and the ability to respond to load overload problems.
[0348] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program, and the computer program includes program instructions. When the processor executes the above program instructions, it can execute the above Figure 3 and Figure 6 The method in the corresponding embodiment, therefore, will not be repeated here. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, the program instructions can be deployed on a computer device, or executed on multiple computer devices located in one location, or, executed on multiple computer devices distributed in multiple locations and interconnected by a communication network.
[0349] According to one aspect of the present application, a computer program product is provided, the computer program product comprising a computer program, the computer program being stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium, and the processor executes the computer program, so that the computer device can perform the above Figure 3 and Figure 6 The method in the corresponding embodiment will therefore not be described in detail here.
[0350] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: The method is applied to a data system, the data system includes a plurality of nodes; the method is executed by a first node, the first node is any node in the data system; the method includes: When the first node is overloaded, a second node is selected from the data system, where the second node refers to any node in the data system except the first node; the second node is determined based on the principle of global load balancing of the data system; Converting the stateful tasks to be processed in the first node into stateless tasks; Sending a task processing request to the second node, wherein the task processing request carries the stateless task, and the task processing request is used to request the second node to process the stateless task and return processing information; Post-process the processing information returned by the second node to obtain a processing result of the stateful task.
2. The method according to claim 1, characterized in that The nodes in the data system include one or more of data nodes and independent nodes; the data nodes are distributed in one or more clusters in the data system, and the independent nodes are independently set in the data system; The load overload of the first node includes at least one of the following: the current load of the first node is greater than or equal to the load threshold; the resources consumed to process the stateful task exceed the available resources of the first node; the processing of the stateful task by the first node will affect the processing process of the current task in the first node.
3. The method according to claim 1, characterized in that The data system is provided with a global load service device, and the global load service device is used to manage the node information and load information of each node in the data system; the method further includes: Sending an allocation request to the global load service device, wherein the allocation request is used to request the global load service device to allocate a backup node for the first node; receiving a node list allocated by the global load service device, wherein the node list includes one or more candidate nodes; the candidate node refers to any node in the data system except the first node; Among them, the global load service device is allocated based on the principle of global load balancing of the data system, and the principle of global load balancing of the data system includes at least one of the following: allocating alternative nodes in order of load from small to large; allocating alternative nodes in order of network overhead between the first node and the first node from small to large; giving priority to allocating nodes belonging to different clusters from the first node as alternative nodes.
4. The method according to claim 3, characterized in that The selecting a second node from the data system comprises: Traversing the node list, and selecting a candidate node from the node list according to a preset rule; If the selected candidate node does not include an unavailable mark, determining the selected candidate node as the second node; Among them, the preset rules include at least one of the following: sequential selection, random selection and selection based on the priority of the alternative node; the setting factors of the priority of the alternative node include at least one of the following: load, network overhead and cluster; the lower the load of the alternative node, the higher the priority of the alternative node; the less the network overhead between the alternative node and the first node, the higher the priority of the alternative node; the alternative node and the first node belong to different clusters, the higher the priority of the alternative node.
5. The method according to claim 4, characterized in that If the selected candidate node does not include an unavailable mark, determining the selected candidate node as the second node includes: Sending a preprocessing request to the selected candidate node; If an acceptance response returned by the selected candidate node is received within a preset response time, the selected candidate node is determined as the second node; If an acceptance response returned by the second node is not received within a preset response time, or a rejection response returned by the selected candidate node is received within the preset response time, then an unavailable mark is added to the selected candidate node in the node list; and, A new candidate node is reselected from the node list according to a preset rule to determine the second node.
6. The method according to claim 3, characterized in that The method further comprises: If the processing information returned by the second node is received within the preset response time, a step of performing post-processing on the processing information returned by the second node to obtain the processing result of the stateful task is performed; If the processing information returned by the second node is not received within the preset response time, or if the processing rejection information returned by the second node is received within the preset response time, then an unavailable mark is added to the second node in the node list; and, A new second node is selected again from the node list.
7. The method according to claim 1, characterized in that The stateful task includes one or more subtasks; and converting the stateful task to be processed in the first node into a stateless task includes: Extracting a target subtask from the stateful task, wherein the target subtask includes a subtask in the stateful task whose resource consumption is greater than a resource threshold, and the target subtask is relatively independent from other subtasks in the stateful task; The extracted target subtask is encapsulated as a stateless task.
8. The method according to claim 7, characterized in that The data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; and encapsulating the extracted target subtask into a stateless task includes: Acquire the data information to be written and metadata information of the data information corresponding to the data writing subtask, where the metadata information of the data information is used to define a processing method of the data information to be written; The data information and metadata information of the data information are encapsulated as the stateless task.
9. The method according to claim 8, characterized in that The processing information returned by the second node includes one or more file fragments obtained after the data information is written; The post-processing of the processing information returned by the second node to obtain the processing result of the stateful task includes: Determining the file shards to which the one or more file fragments belong; Obtain the directory corresponding to the file segment; writing the one or more file segments into the directory, and, The metadata information of the file slice is updated, where the metadata information of the file slice is used to define the storage and indexing method of each file fragment in the file slice.
10. The method according to claim 9, characterized in that The processing information returned by the second node also includes one or more log information generated during the writing process of the data information; The post-processing of the processing information returned by the second node to obtain the processing result of the stateful task also includes: The one or more log information are added in sequence to the log file corresponding to the stateful task in the first node.
11. The method according to claim 1, characterized in that The method further comprises: Responding to the load processing request sent by the business system, obtaining the stateful tasks to be processed; performing pre-processing on the stateful task and detecting load information of the first node; and, After post-processing the processing information returned by the second node to obtain the processing result of the stateful task, feedback information is output to the business system.
12. A data processing method, characterized in that: The method is applied to a data system, the data system includes a plurality of nodes; the method is executed by a second node, the second node is any node in the data system; the method includes: receiving a task processing request sent by a first node in the data system, wherein the first node refers to any node in the data system except the second node; the task processing request includes a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded; the second node is determined based on the principle of global load balancing of the data system; In response to the task processing request, processing the stateless task to obtain processing information; The processing information is returned to the first node, so that the first node performs post-processing on the processing information to obtain a processing result of the stateful task.
13. The method according to claim 12, characterized in that A global load service device is provided in the data system, and the global load service device is used to manage the node information and load information of each node in the data system; the global load service device allocates a node list to the first node based on the principle of global load balancing of the data system, and the node list includes one or more candidate nodes; The second node is a candidate node selected by the first node from the node list; The stateless task is obtained by encapsulating the target subtask extracted from the stateful task; The stateful task includes one or more subtasks; The target subtask includes a subtask in the stateful task whose resource consumption is greater than a resource threshold, and the target subtask is relatively independent from other subtasks in the stateful task.
14. The method according to claim 13, characterized in that The data system includes a stateful data system; the stateful task is a data writing task, and the target subtask is a data writing subtask; the stateless task includes the data information to be written corresponding to the data writing subtask and the metadata information of the data information; The step of processing the stateless task in response to the task processing request to obtain processing information includes: In response to the task processing request, creating a temporary index write class in the memory of the second node; Calling the temporary index writing class to write the data information based on the metadata information of the data information to obtain one or more file fragments; The processing information is generated based on the one or more file segments.
15. The method according to claim 14, characterized in that The step of processing the stateless task in response to the task processing request to obtain processing information further includes: Creating a temporary log class in the memory of the second node; Based on the process of writing the data information, calling the temporary log class to generate one or more log information; The processing information is generated based on one or more log information.
16. A data processing device, characterized in that: The device is arranged in a first node, and the first node is any node among a plurality of nodes included in the data system; the device comprises: a processing unit, configured to select a second node from the data system when the first node is overloaded, wherein the second node refers to any node in the data system except the first node; the second node is determined based on a principle of global load balancing of the data system; The processing unit is further used to convert the stateful task to be processed in the first node into a stateless task; a sending unit, configured to send a task processing request to the second node, wherein the task processing request carries the stateless task, and the task processing request is used to request the second node to process the stateless task and return processing information; The processing unit is further used to perform post-processing on the processing information returned by the second node to obtain the processing result of the stateful task.
17. A data processing device, characterized in that: The device is arranged in a second node, and the second node is any one of a plurality of nodes included in the data system; the device comprises: A receiving unit, configured to receive a task processing request sent by a first node in the data system, wherein the first node refers to any node in the data system except the second node; the task processing request includes a stateless task; the stateless task is obtained by converting a stateful task to be processed in the first node when the first node is overloaded; the second node is determined based on the principle of global load balancing of the data system; a processing unit, configured to process the stateless task in response to the task processing request to obtain processing information; A sending unit is used to return the processing information to the first node, so that the first node performs post-processing on the processing information to obtain a processing result of the stateful task.
18. A computer device, characterized in that: include: a processor suitable for executing a computer program; A computer-readable storage medium, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by the processor, the data processing method according to any one of claims 1 to 15 is executed.
19. A computer-readable storage medium, characterized in that: The computer storage medium stores a computer program, and when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 15 is executed.
20. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the data processing method according to any one of claims 1 to 15 is implemented.
