A business execution method, apparatus, device, and readable storage medium
Through intermediate devices, it serves as a bridge between the client and multiple distributed service execution clusters, determines the target cluster and forwards service execution requests, solving the problem that a single cluster is difficult to support high concurrent services, achieving atomicity and consistency of service execution, reducing client configuration complexity and improving service execution efficiency.
Patent Information
- Application Number
- CN202411068684.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2044-08-05
AI Technical Summary
In big data processing scenarios, a single distributed service execution cluster is difficult to support a large number of highly concurrent services, and the client needs to configure complex business execution logic and session management mechanisms to ensure the correct execution of multiple sub-services.
Through intermediate devices, communication with the client and multiple distributed service execution clusters is determined, and service execution requests are forwarded, and the correspondence between the target identifier and the cluster is stored, ensuring that multiple sub-services of the same service are executed by the same target cluster.
It realizes the atomicity and consistency of business execution, reduces the configuration complexity and business execution costs of clients, and improves business execution efficiency and stability.
Smart Images

Figure CN119030987B_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and particularly to a service execution method, apparatus, device, and readable storage medium. Background Art
[0002] With the rapid development of computer technology and the explosive growth of data, in big data processing scenarios, currently a distributed service execution cluster can be adopted to meet the demand for large-scale data processing, improving the processing capacity and concurrent query ability.
[0003] In the prior art, a user can send a service execution request to a distributed service execution cluster through a client. The master node in the cluster generates corresponding data processing tasks and decomposes them into multiple subtasks. The master node distributes each subtask to multiple worker nodes in the cluster for parallel execution, thereby improving the service execution efficiency.
[0004] However, with the growth in the number of data sources and the increasing requirement for response speed, the computing resources of only one distributed service execution cluster are difficult to support a large number of services. Therefore, multiple distributed service execution clusters can be adopted to jointly process a large number of highly concurrent services from users to ensure the execution efficiency and stability of the services.
[0005] However, in practical applications, a complete service may need to sequentially execute multiple sub-services, and the execution of these multiple sub-services usually has atomicity, that is, the execution of multiple sub-services included in one service cannot be separated. In this case, if the client directly communicates with multiple distributed service execution clusters, the client needs to configure complex service execution logic and session management mechanisms to ensure that multiple sub-services of the same service can be correctly forwarded to the same distributed service execution cluster. Once the service volume increases, it will impose an extremely heavy burden on the client and even affect the normal operation of the service.
[0006] Based on this, this specification provides a service execution method. Summary of the Invention
[0007] This specification provides a service execution method, apparatus, device, and readable storage medium to partially solve the above problems existing in the prior art.
[0008] This specification adopts the following technical solutions:
[0009] This specification provides a service execution method, which is applied to an intermediate device. The intermediate device is respectively communicatively connected to a client and multiple distributed service execution clusters. The method includes:
[0010] In response to the first service execution request sent by the client, determine a target cluster from each distributed service execution cluster, and forward the first service execution request to the target cluster, so that the target cluster generates and returns a target identifier in response to the first service execution request, and executes the first to-be-executed task corresponding to the first service execution request;
[0011] Receive the target identifier sent by the target cluster, store the corresponding relationship between the target identifier and the target cluster, and send the target identifier to the client;
[0012] In response to the second service execution request sent by the client, according to the target identifier carried in the second service execution request, find the target cluster corresponding to the target identifier from the stored corresponding relationship, and forward the second service execution request to the target cluster, so that the target cluster executes the second to-be-executed task corresponding to the second service execution request;
[0013] Wherein, the first to-be-executed task and the second to-be-executed task belong to the same target service.
[0014] Optionally, the determining a target cluster from each distributed service execution cluster specifically includes:
[0015] Obtain the loads corresponding to each distributed service execution cluster respectively;
[0016] According to the loads corresponding to each distributed service execution cluster respectively, determine the distributed service execution cluster with the smallest load as the target cluster.
[0017] Optionally, the obtaining the loads corresponding to each distributed service execution cluster respectively specifically includes:
[0018] Predetermine a load acquisition period;
[0019] When the load acquisition period is reached, generate a load query request, and send the load query request to each master node of each distributed service execution cluster respectively;
[0020] Receive the loads corresponding to each distributed service execution cluster respectively returned by each master node of each distributed service execution cluster, wherein the load of the distributed service execution cluster includes the load of the master node in the distributed service execution cluster and the loads of multiple worker nodes in the distributed service execution cluster.
[0021] Optionally, after sending the target identifier to the client and before responding to the second service execution request sent by the client, the method further includes:
[0022] Iterative execution: Receive the current result query address sent by the target cluster, send the current result query address to the client, and receive the current result query request sent by the client, where the current result query request is generated by the client according to the current result query address and the target identifier; According to the target identifier carried in the current result query request, find the target cluster corresponding to the target identifier from the stored corresponding relationship, forward the current result query request to the target cluster, receive the current task execution result and the next result query address returned by the target cluster, and the current task execution result is obtained by the target cluster according to the current result query address; Send the current task execution result and the next result query address to the client until the next result query address is an empty address.
[0023] Optionally, the data sources corresponding to the multiple distributed service execution clusters are different from each other;
[0024] Responding to the first service execution request sent by the client, determining a target cluster from each distributed service execution cluster specifically includes:
[0025] Pre-obtain the identifiers of the data sources corresponding to each distributed service execution cluster respectively;
[0026] Responding to the first service execution request sent by the client, determine the specified identifier carried in the first service execution request, where the specified identifier is used to indicate the data source used to execute the first to-be-executed task corresponding to the first service execution request;
[0027] Use the distributed service execution cluster in which the identifier of the corresponding data source is the same as the specified identifier among the distributed service execution clusters as the target cluster.
[0028] Optionally, the multiple distributed service execution clusters respectively correspond to multiple data sources, where at least two of the multiple distributed service execution clusters correspond to the same data source;
[0029] Responding to the first service execution request sent by the client, determining a target cluster from each distributed service execution cluster specifically includes:
[0030] Pre-obtain the identifiers of the data sources corresponding to each distributed service execution cluster respectively, divide several distributed service execution clusters with the same identifier of the corresponding data source into the same cluster group to obtain each cluster group, and determine the identifiers of the data sources corresponding to each cluster group according to the identifiers of the data sources corresponding to the several distributed service execution clusters included in each cluster group;
[0031] Pre-acquire the loads corresponding to each of the distributed service execution clusters respectively;
[0032] In response to a first service execution request sent by the client, determine a specified identifier carried in the first service execution request, where the specified identifier is used to indicate a data source to be used for executing a first to-be-executed task corresponding to the first service execution request;
[0033] According to the specified identifier and the identifiers of the data sources corresponding to each cluster group, determine a target cluster group corresponding to the specified identifier from each cluster group;
[0034] According to the loads corresponding to several distributed service execution clusters included in the target cluster group, determine the distributed service execution cluster with the smallest load in the target cluster as the target cluster.
[0035] Optionally, the method further includes:
[0036] Acquire the real-time loads corresponding to each of the distributed service execution clusters respectively;
[0037] If the real-time loads corresponding to each of the distributed service execution clusters are all greater than a load threshold, determine a new distributed service execution cluster, and establish a communication connection between the intermediate device and the new distributed service execution cluster; the new distributed service execution cluster is a distributed service execution cluster that has not executed tasks.
[0038] This specification provides a service execution device, which is applied to an intermediate device. The intermediate device is respectively communicatively connected to a client and multiple distributed service execution clusters. The device includes:
[0039] A target cluster determination module, configured to, in response to a first service execution request sent by the client, determine a target cluster from each distributed service execution cluster, and forward the first service execution request to the target cluster, so that the target cluster generates and returns a target identifier in response to the first service execution request, and executes a first to-be-executed task corresponding to the first service execution request;
[0040] A forwarding module, configured to receive the target identifier sent by the target cluster, store the corresponding relationship between the target identifier and the target cluster, and send the target identifier to the client;
[0041] A search module, configured to, in response to a second service execution request sent by the client, search, according to a target identifier carried in the second service execution request, for a target cluster corresponding to the target identifier from the stored corresponding relationship, and forward the second service execution request to the target cluster, so that the target cluster executes a second task to be executed corresponding to the second service execution request; wherein, the first task to be executed and the second task to be executed belong to the same target service.
[0042] This specification provides a computer-readable storage medium storing a computer program, which when executed by a processor implements the above-mentioned service execution method.
[0043] This specification provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the above-mentioned service execution method when executing the program.
[0044] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0045] In the service execution method provided in this specification, an intermediate device determines a target cluster in response to a first service execution request sent by a client, forwards the first service execution request to the target cluster so that it executes a corresponding first task to be executed, receives a target identifier returned by the target cluster, stores the corresponding relationship between the target identifier and the target cluster, sends the target identifier to the client, and in response to a second service execution request sent by the client, determines the target cluster according to the target identifier carried in the second service execution request, and forwards the second service execution request to the target cluster so that it executes a corresponding second task to be executed, where the first task to be executed and the second task to be executed belong to the same target service. It can be seen that by storing the corresponding relationship between the identifier of the target cluster and the target identifier, multiple service execution requests belonging to the same service can be forwarded to the same target cluster, so that multiple tasks in the same service are completed by the same target cluster, ensuring the atomicity and consistency of service execution. Moreover, the intermediate device enables the client to communicate with each distributed service execution cluster directly, reducing the configuration complexity of the client and the service execution cost, thereby improving the service execution efficiency and stability. Description of the Drawings
[0046] The drawings described herein are used to provide a further understanding of this specification, form a part of this specification, and the illustrative embodiments and descriptions thereof of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the attached
[0047] In the figure:
[0048] Figure 1It is a schematic diagram of the architecture of a service execution system in this specification;
[0049] Figure 2 It is a schematic diagram of the interaction process of a service execution method in this specification;
[0050] Figure 3 It is a schematic diagram of the interaction process of a service execution method in this specification;
[0051] Figure 4 It is a schematic diagram of a service execution device provided in this specification;
[0052] Figure 5 It is provided in this specification corresponding to Figure 2 Schematic diagram of the electronic device. Specific embodiments
[0053] To make the purpose, technical solutions and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative work belong to the scope of protection of this specification.
[0054] In addition, it should be noted that all actions of obtaining signals, information or data in this specification are carried out on the premise of complying with the corresponding data protection regulations and policies of the place where it is located and obtaining the authorization given by the owner of the corresponding device.
[0055] It should be noted that, without conflict, the features in the following embodiments and implementation manners can be combined with each other.
[0056] The following will describe in detail the technical solutions provided by each embodiment of this specification in conjunction with the drawings.
[0057] Figure 1The following is a schematic architecture diagram of a service execution system provided in this specification. The service execution system includes a client, an intermediate device, and multiple distributed service execution clusters. Among them, the client is used to generate a service execution request or a result query request in response to a user's operation, and is directly communicatively connected to the intermediate device. The client can be various types of mobile terminals or fixed terminals such as smartphones, tablets, laptops, and desktop computers. The intermediate device can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. It is used to forward the requests sent by the client to the distributed service execution clusters, and forward the information or data returned by the distributed service execution clusters to the client. The intermediate device is communicatively connected to the client and also to each distributed service execution cluster. The communication connection method can be any existing type of method, such as through wireless communication links such as Bluetooth, Wi-Fi, near-field communication, and cellular mobile communication networks, or through wired communication links. This specification does not limit this.
[0058] Based on the interaction among the client, the intermediate device, and the distributed service execution clusters in the service execution system provided in this specification, it is possible to forward multiple service execution requests belonging to the same service to the same target cluster, so that multiple tasks in the same service are completed by the same target cluster, ensuring the atomicity and consistency of service execution. Moreover, the intermediate device enables the client to not need to directly communicate with each distributed service execution cluster, reducing the configuration complexity of the client and the service execution cost, thereby improving the service execution efficiency and stability.
[0059] Figure 2 The following is a schematic interaction process diagram of a service execution method provided in this specification. This service execution method can be implemented relying on Figure 1 the service execution system shown. During the execution of this method, the parties interacting are the client, the intermediate device, and multiple distributed service execution clusters included in the service execution system.
[0060] S100: The client sends a first service execution request to the intermediate device.
[0061] The client can generate a first service execution request in response to a user's input. For example, if the service that the user needs to execute is a database query service, the user's input can be a corresponding SQL query statement, and the client can generate a first service execution request based on this SQL query statement. Of course, it can also be for other types of statements such as adding, deleting, and modifying in the database.
[0062] In addition, according to the actual service scenario and the user's needs, the first service execution request can also carry task requirements for other types of data processing tasks. This specification does not limit this.
[0063] It should be noted that in this specification, both the first service execution request and the second service execution request are used to request the distributed service execution cluster to execute the corresponding tasks to be executed, and there is no difference in their functions. The use of "first" and "second" for distinction is because in the service scenario to which the service execution method provided in this specification applies, a service that a user needs to execute contains multiple subdivided sub-services. The first service execution request actually corresponds to the first sub-service that the user requests to execute in this service, and the second service execution request corresponds to the non-first sub-service that the user requests to execute in this service.
[0064] S102: The intermediate device determines a target cluster from each distributed service execution cluster in response to the first service execution request sent by the client.
[0065] In this specification, as an intermediary for communication between the client and each distributed service execution cluster, the intermediate device can perform multiple functions. For example, as a security boundary, it provides security policies such as authentication, authorization, and encrypted communication for the client and the distributed service execution cluster. For example, only legitimate service execution requests and result query requests can reach the distributed service execution cluster to protect data security. The intermediate device can also provide protocol conversion services when the communication protocols used by the client and each distributed service execution cluster are inconsistent, so that the client does not have to directly handle various protocols, thereby simplifying the development and maintenance work of the client. In addition, the intermediate device can record all requests, information, and traffic entering and leaving the intermediate device, and perform detailed monitoring and troubleshooting to improve service execution efficiency and ensure security and compliance during the service execution process.
[0066] In addition to the above functions, in the service execution method provided in this specification, the most important function of the intermediate device is to forward or route the first service execution request sent by the client (that is, the request corresponding to the first sub-service to be executed among the multiple sub-services included in a service) to the distributed service execution cluster that is most suitable for executing the first task to be executed corresponding to the first service execution request.
[0067] For example, in the case where the target service to which the first service execution request belongs needs to use a specific data source to execute, the first service execution request may carry the identifier of the data source required to execute the corresponding first task to be executed. Based on the identifier of the data source, the intermediate device can find the distributed service execution cluster connected to the data source as the target cluster, and forward the first service execution request to the corresponding target cluster to execute the corresponding task based on the specific data source.
[0068] For another example, the intermediate device can also select the distributed service execution cluster with a shorter response time as the target cluster according to the load conditions corresponding to each distributed service execution cluster, so as to improve the speed and efficiency of service execution.
[0069] Or, in a cross-region service scenario where each distributed service execution cluster is deployed in a different region, the intermediate device can select a cluster with a smaller communication overhead and a lower network latency based on the geographical location of the client according to the principle of minimum communication overhead.
[0070] Of course, the target cluster can also be selected for other reasons. For example, the cluster has the specific functions required by the target service, the cluster conforms to the business logic required by the target service, the historical execution efficiency of the cluster is the best, etc. The intermediate device can select one or more existing selection methods according to the actual service scenario to determine the most suitable distributed service execution cluster for executing the first to-be-executed task corresponding to the first service execution request. The present specification does not limit the type and quantity of specific selection methods.
[0071] S104: Forward the first service execution request to the target cluster.
[0072] After determining the target cluster, the intermediate device can forward the first service execution request to the master node of the target cluster, so that the master node analyzes the first to-be-executed task to be executed in response to the first service execution request, splits it, and distributes it to multiple worker nodes for execution respectively.
[0073] S106: The target cluster generates a target identifier in response to the first service execution request and executes the first to-be-executed task corresponding to the first service execution request.
[0074] In this specification, a distributed service execution cluster usually consists of a master node and multiple worker nodes. Among them, the master node is used to communicate with the intermediate device to receive or send information. The master node can also monitor the running status of each worker node. Each worker node maintains a connection and reports the status of the worker node regularly. After determining the task to be executed, the master node splits the task to be executed according to the number and status of the worker nodes, and distributes each sub-task obtained by the split to each worker node. The worker node will connect to the data source through a connector and be responsible for executing the sub-task issued by the master node based on the data source. After that, the task execution result obtained by the worker node executing the sub-task will be returned to the master node, and the master node aggregates the task execution results returned by each worker node for query.
[0075] Accordingly, the master node in the target cluster will execute the above process in response to the first service execution request. At the same time, the master node will also generate a target identifier (such as QueryId) corresponding to the first task to be executed corresponding to the first service execution request, and return the target identifier to the client through the intermediate device. The client can then obtain the task execution result corresponding to the first task to be executed based on the target identifier. Of course, the target identifier generated by the master node of the target cluster can also correspond to the target service corresponding to the first service execution request. In this way, when the target identifier is returned to the client through the intermediate device, the client can generate a second service execution request based on the target identifier when requesting to execute other tasks included in the target service next time, so that the intermediate device can route the second service execution request belonging to the same target service as the first service execution request to the same target cluster to ensure the atomicity of the target service execution.
[0076] In addition, the master node of the target cluster can also determine the task result query address of the first task to be executed and return the task result query address to the client through the intermediate device as well, so that the client can generate a result query request based on the result query address and obtain the task execution result from the master node of the target cluster through the intermediate device.
[0077] S108: Return the target identifier to the intermediate device.
[0078] S110: The intermediate device receives the target identifier sent by the target cluster and stores the corresponding relationship between the target identifier and the target cluster.
[0079] To ensure that the intermediate device will forward service execution requests and result query requests belonging to the same target service to the same target cluster, the intermediate device will record the corresponding relationship between the target identifier and the target cluster and store it in the form of key-value pairs. In this way, as long as the intermediate device parses whether there is a target identifier in the request sent by the client and queries based on the target identifier, it can determine which distributed service execution cluster to forward the request to.
[0080] For example, if the queryid returned by the target cluster cluster2 is "aaaaa" and the queryid returned by the target cluster cluster3 is "bbbbb", the intermediate device can use the queryid as the key and the identifier of the target cluster as the value to store the corresponding relationship between the target identifier and the target cluster. An optional implementation is as follows:
[0081] K V aaaaa cluster2 bbbbb cluster3
[0082] When the intermediate device receives other requests carrying the target identifier "aaaaa", it will query the target cluster cluster2 based on the target identifier "aaaaa" and will not find the cluster cluster3. As a result, the intermediate device will forward the request to the target cluster cluster2 instead of the cluster cluster3.
[0083] In addition, in this specification, since the intermediate device will process high-concurrency service requests simultaneously, in practice, there will be many corresponding relationships between target identifiers and target clusters stored. To relieve the storage pressure and improve the service execution efficiency, the corresponding relationships between target identifiers and target clusters can be deleted regularly, that is, the corresponding relationships between target identifiers and target clusters are only stored at the intermediate device for a certain period of time. This period can be determined according to specific service scenarios, and this specification does not limit it.
[0084] S112: Send the target identifier to the client.
[0085] S114: The client sends a second service execution request to the intermediate device.
[0086] As mentioned above, the second service execution request is similar to the first service execution request, both of which are used to request the execution of tasks to be executed. Moreover, the second task to be executed corresponding to the second service execution request and the first task to be executed corresponding to the first service execution request belong to the same target service. Since in the service scenarios applicable to this specification, multiple tasks belonging to the same target service need to be executed by the same cluster, therefore, when the client generates the second service execution request, in addition to generating it based on the task requirements of the second task to be executed input by the user, it also needs to combine the target identifier so that the intermediate device can forward the second service execution request to the target cluster that received the first service execution request.
[0087] In addition, this specification does not limit whether the task types of the second task to be executed corresponding to the second service execution request and the first task to be executed corresponding to the first service execution request are the same. They can be the same or different.
[0088] S116: In response to the second service execution request sent by the client, the intermediate device searches for the target cluster corresponding to the target identifier from the stored corresponding relationships according to the target identifier carried by the second service execution request.
[0089] Specifically, after receiving the second service execution request sent by the client, the intermediate device uses the target identifier carried in the second service execution request as the key to look up the corresponding value from the stored key-value pairs (the corresponding relationship between each target identifier and the target cluster), that is, to look up the target cluster corresponding to the target identifier, so as to determine to forward the second service execution request to the target cluster corresponding to the target identifier, so as to achieve the effect that each task to be executed under the same target service is executed by the same distributed service execution cluster.
[0090] S118: Forward the second service execution request to the target cluster.
[0091] S120: The target cluster executes the second task to be executed corresponding to the second service execution request. Wherein, the first task to be executed and the second task to be executed belong to the same target service.
[0092] In the service execution method provided in this specification, the intermediate device determines the target cluster in response to the first service execution request sent by the client, forwards the first service execution request to the target cluster so that it executes the corresponding first task to be executed, receives the target identifier returned by the target cluster, stores the corresponding relationship between the target identifier and the target cluster, sends the target identifier to the client, and in response to the second service execution request sent by the client, determines the target cluster according to the target identifier carried in the second service execution request, and forwards the second service execution request to the target cluster so that it executes the corresponding second task to be executed, where the first task to be executed and the second task to be executed belong to the same target service. It can be seen that by storing the corresponding relationship between the identifier of the target cluster and the target identifier, multiple service execution requests belonging to the same service can be forwarded to the same target cluster, so that multiple tasks in the same service are completed by the same target cluster, ensuring the atomicity and consistency of service execution. Moreover, the intermediate device enables the client to communicate directly with each distributed service execution cluster, reducing the configuration complexity and service execution cost of the client, thereby improving the service execution efficiency and stability.
[0093] In one or more embodiments of this specification, Figure 2 When the intermediate device determines the target cluster in step S102 shown, a load balancing scheme can be given. According to indicators such as the current load and response time of each distributed service execution cluster, the first service execution request of the client is assigned to the cluster that is most suitable for processing the request, effectively avoiding overload of a certain cluster and improving the service processing ability and stability of the overall system. Specifically, it can be implemented based on the following implementation methods:
[0094] The first step: Obtain the load corresponding to each distributed service execution cluster respectively.
[0095] Specifically, to determine that the intermediate device can send load query requests to each distributed service execution cluster respectively, each distributed service execution cluster can respond to the load query request and return its own load to the intermediate device. Among them, the load of the distributed service execution cluster can be characterized by the proportion of the hardware resources occupied by the master node in the cluster, such as CPU utilization rate, memory usage rate, etc., or can be identified by the length of the task queue at the master node, or can be characterized by the number of tasks processed by the cluster per unit time. Of course, any existing type of load metric can also be used to determine it, and this specification does not limit it.
[0096] Step 2: Determine the distributed service execution cluster with the smallest load as the target cluster according to the loads respectively corresponding to the distributed service execution clusters.
[0097] In short, the load corresponding to the distributed service execution cluster can characterize the computing resource usage of the cluster, as well as the pressure and stability of task execution, thus indicating the ability of the cluster to further undertake task execution. The heavier the load corresponding to the distributed service execution cluster respectively, the lower the ability of the cluster to further undertake task execution. On the contrary, the lighter the load corresponding to the distributed service execution cluster respectively, the higher the ability of the cluster to further undertake task execution.
[0098] Based on this, in this specification, based on the principle of load balancing, tasks are forwarded to the distributed service cluster with the smallest load. Thus, specifically, according to the loads respectively corresponding to the distributed service execution clusters,
[0099] Among them, in the above-mentioned first step, when the intermediate device pre-obtains the loads respectively corresponding to the distributed service execution clusters, the intermediate device can make the task of obtaining the loads of each cluster as a timing task, and obtain the real-time loads of each cluster every once in a while to monitor the business execution pressure of each cluster, so as to improve the accuracy of business allocation and further improve the effect of load balancing.
[0100] Specifically:
[0101] First, determine the load acquisition period in advance.
[0102] In this specification, the load acquisition period is a time metric used to indicate how often to obtain the loads of each distributed service execution cluster. This load acquisition period can be a fixed value set manually according to the actual business scenario and prior experience, or a variable value that can be flexibly adjusted. This specification does not limit the specific duration of the load acquisition period.
[0103] Secondly, when the load acquisition period is reached, generate a load query request and send the load query request to each master node of each distributed service execution cluster respectively.
[0104] Specifically, obtaining the loads of each distributed service execution cluster is regarded as a timing task. Whenever the load acquisition period is reached, the intermediate device generates a load query request, which is used to query the load of the distributed service execution cluster that receives the load query request.
[0105] After that, the intermediate device receives the loads corresponding to each distributed service execution cluster respectively returned by the respective master nodes of each distributed service execution cluster. Among them, the load of the distributed service execution cluster includes the load of the master node in the distributed service execution cluster and the loads of multiple worker nodes in the distributed service execution cluster.
[0106] The intermediate device stores the loads returned by the master nodes of each distributed service execution cluster in its own cache and marks the identifier of the distributed service execution cluster for each load. That is to say, the loads of each distributed service execution cluster stored by the intermediate device are updated whenever the real-time loads returned by the master nodes of each distributed service execution cluster are received. During each load acquisition period, if the intermediate device receives a first service execution request sent by the client, the intermediate device determines the target cluster according to the loads of each distributed service execution cluster currently stored by the intermediate device.
[0107] For example, the load acquisition period is T. At time t, the intermediate device generates a load query request to query the loads corresponding to each distributed service execution cluster. Then, the actual time when the intermediate device generates the next load query request is t + T. If within the period from time t to time t + T, the intermediate device receives a first service execution request sent by the client, the target cluster can be determined according to the loads of each distributed service execution cluster obtained by the load query request sent at time t.
[0108] In addition, in this specification, the load of the distributed service execution cluster can not only represent the load of the master node in the cluster, but also represent the loads of each worker node in the cluster, so as to fully and objectively reflect the task processing ability of the cluster. In this specification, the load of the master node is generally determined according to the quantity and size of the tasks to be executed queued on the master node, and the load of the worker node is generally determined according to the quantity and size of the tasks that have been assigned to the worker node for execution.
[0109] Of course, within the period from time t to time t + T, the loads of each distributed service execution cluster will change. Therefore, in one or more embodiments of this specification, in order to improve the accuracy, the intermediate device can generate a load query request in response to the first service execution request sent by the client and send the load query request to each distributed service execution cluster respectively, so as to obtain the current loads of each distributed service execution cluster when the intermediate device receives the first service execution request.
[0110] In one or more embodiments of this specification, the target service executed by the client may include multiple tasks to be executed. Generally, after the service execution request (which may be the first service execution request or the second service execution request) is sent to the target cluster through the Figure 2 intermediate device shown, the tasks to be executed corresponding to the service execution request can queue up for execution at the master node of the target cluster. After that, when it is the turn of the tasks to be executed corresponding to the service execution request, the master node in the target cluster can allocate tasks based on the tasks to be executed corresponding to the service execution request, so that each worker node in the target cluster can execute the allocated tasks in parallel. The master node will receive the task execution results from different worker nodes at different times. Based on this situation, the master node will temporarily store the received task execution results in its own cache and determine the result query address. At least part of the task execution results corresponding to the task to be executed are stored in the cache corresponding to each result query address. The result query address is sent to the client through the intermediate device. The client can send a result query request based on the result query address to obtain the task execution results. In practice, since the computing capabilities of different worker nodes are different, and accordingly the speeds at which different worker nodes execute tasks are different, the above process may need to be looped multiple times before the client can obtain all the task execution results corresponding to the task to be executed. Based on the above process, this specification provides an optional embodiment to loop the result query so that the client can obtain all the task execution results corresponding to the task to be executed by requesting the result query multiple times, as Figure 3 shown, the specific interaction process is as follows:
[0111] S200: The target cluster sends the current result query address to the intermediate device.
[0112] Specifically, the current result query address may be the storage address allocated by the master node of the target cluster for the task execution results. After each worker node in the target cluster finishes executing the allocated task, it will return the corresponding task execution result to the master node, and the master node can store the received task execution results in the cache corresponding to this current result query address.
[0113] Thus, the target cluster sends the current result query address to the client through the intermediate device, and the client can determine where at least part of the task execution results it needs to obtain are stored based on the current result query address.
[0114] S202: The intermediate device forwards the received current result query address to the client.
[0115] S204: The client receives the current result query address and generates a current result query request based on the current result query address and the target identifier.
[0116] In the current result query request, the current result query address is used to indicate a specific location in the cache of the master node where at least part of the task execution results are stored, and the target identifier is used to indicate that the intermediate device forwards the current result query request to the target cluster that executes the first to-be-executed task or the second to-be-executed task included in the target service.
[0117] S206: The client sends the current result query request to the intermediate device.
[0118] In this specification, the timing for the client to perform task result query can be before sending the second service execution request or after sending the second service execution request.
[0119] S208: The intermediate device receives the current result query request sent by the client, and based on the target identifier carried in the current result query request, queries the target cluster corresponding to the target identifier from the stored corresponding relationship.
[0120] In this step, the intermediate device looks up the corresponding target cluster based on the target identifier, which is similar to the previous step S116 and will not be elaborated here.
[0121] S210: Forward the current result query request to the target cluster.
[0122] S212: The target cluster queries the current task execution result according to the current result query address carried in the current result query request, and determines the next result query address.
[0123] Among them, the next result query address is used to indicate the address where the task execution result requested by the client next time is stored.
[0124] S214: Return the current task execution result and the next result query address to the intermediate device.
[0125] S216: The intermediate device forwards the current task execution result and the next result query address to the client. Return to execution step S204 until the next result query address is an empty address.
[0126] Generally, since the speeds at which each working node in the distributed service execution cluster executes the assigned tasks are different, and the timings at which each working node feeds back the task execution results to the master node are also different, therefore, the task execution results stored in the storage address indicated by the result query address returned by the target cluster each time are at least part of the task execution results corresponding to all the task execution results of the to-be-executed tasks. Therefore, for a to-be-executed task (such as an SQL statement) included in the target service requested by the client, the client needs to send multiple result query requests to obtain the complete task execution result. Therefore, the above Figure 3The solution shown needs to be repeated for multiple times to achieve the effect that the client can obtain the complete task execution results. The stopping condition of the loop iteration is that the next result query address returned by the target cluster is an empty address, that is, all the task execution results corresponding to the pending tasks requested by the client have been returned.
[0127] Above Figure 3 The solution shown can be used to query the task execution result of the first task to be executed corresponding to the first business execution request, and can also be used to query the task execution result of the second task to be executed corresponding to the second business execution request. The query process of the two is similar, and both can refer to the above Figure 3 The scheme shown will not be repeated in this manual.
[0128] based on Figure 3 In the scheme shown, the task execution of the target cluster and the task result query initiated by the client can be performed asynchronously. That is, after the target cluster obtains the execution result of the task to be executed, it stores it in the cache corresponding to a certain address and executes other tasks to be executed. There is no need to send the task execution result to the intermediate device before executing other tasks, nor is it necessary to wait until the client queries the task execution result before executing other tasks. This realizes the asynchrony of task execution result query and task execution, and improves the efficiency of business execution.
[0129] In one or more embodiments of the present specification, the data sources connected to different distributed business execution clusters may be the same, different, or partially the same and partially different. In this case, the intermediate device may record the identifiers of the data sources corresponding to each distributed business execution cluster and synchronize them with the client. In this way, the user can generate a first business execution request carrying the identifier of the corresponding data source according to the data source required for the business to be executed, so that the intermediate device can determine the target cluster based on the identifier of the data source carried in the first business execution request. Specifically, it can be divided into the following three situations:
[0130] The first case: multiple distributed service execution clusters in communication with the intermediate device all correspond to the same data source. In this case, the intermediate device can select a target cluster based on the load balancing principle and the loads corresponding to each distributed service execution cluster.
[0131] The second situation: the data sources corresponding to the multiple distributed service execution clusters connected to the middleware are different. In this case, the middleware can use the following scheme to determine the target cluster:
[0132] Step 1: Obtain in advance the identifiers of the data sources corresponding to each distributed business execution cluster.
[0133] Similar to the intermediate device storing the correspondence between the target identifier and the target cluster, the intermediate device can also store, in the form of key-value pairs, the correspondence between each distributed service execution cluster and the identifiers of the data sources connected to each distributed service execution cluster. In this way, using the identifier of the data source connected to the distributed service execution cluster as the key and the identifier of the distributed service execution cluster as the value, the distributed service execution cluster that can be connected to the data source can be found according to the identifier of the data source.
[0134] Step 2: In response to the first service execution request sent by the client, determine the specified identifier carried in the first service execution request, where the specified identifier is used to indicate the data source to be used for executing the first to-be-executed task corresponding to the first service execution request.
[0135] In practical applications, users can execute corresponding target services based on specific data sources according to specific service scenarios and their own service requirements. In this case, the data sources corresponding to each distributed service execution cluster are different from each other, which requires the intermediate device to forward the service execution request corresponding to the target service to the distributed service execution cluster corresponding to the specific data source according to the identifier of the data source required for the target service.
[0136] Therefore, the client can use the identifier of the data source required for the target service to which the first service execution request belongs as the specified identifier and put the specified identifier into the first service execution request. In this way, when the intermediate device receives the first service execution request, it will parse and obtain the specified identifier from the first service execution request.
[0137] Step 3: Use the distributed service execution cluster in which the identifier of the corresponding data source is the same as the specified identifier among the distributed service execution clusters as the target cluster.
[0138] Furthermore, the intermediate device determines whether there is an identifier of a data source that is the same as the specified identifier among the identifiers of the data sources corresponding to each distributed service execution cluster obtained in the first step based on the instruction identifier. If there is, use the data source that is the same as the specified identifier as the data source required for executing the target service to which the first service execution request belongs. Then, determine the distributed service execution cluster corresponding to it according to the found identifier of the data source, and this distributed service execution cluster is the target cluster determined in this step.
[0139] The third case: multiple data sources corresponding to multiple distributed service execution clusters communicatively connected to the intermediate device, where at least two of the multiple distributed service execution clusters correspond to the same data source.
[0140] Step 1: Pre-acquire the identifiers of the data sources respectively corresponding to each distributed service execution cluster, divide several distributed service execution clusters with the same identifier of the corresponding data source into the same cluster group to obtain each cluster group, and determine the identifiers of the data sources respectively corresponding to each cluster group according to the identifiers of the data sources corresponding to the several distributed service execution clusters respectively included in each cluster group.
[0141] Specifically, in this case, although each distributed service execution cluster will be connected to a data source, there may be two or more distributed service execution clusters corresponding to the same data source. Based on this, one or more distributed service execution clusters corresponding to the same data source can be classified into a cluster group. When determining the data source used by the target service to which the first service execution request sent by the execution client belongs, the corresponding cluster group can be determined according to the identifier of the data source. In this way, forwarding the first service execution request to any one of the distributed service execution clusters in this cluster group can implement the execution of the first to-be-executed task corresponding to the first service execution request according to the required data source.
[0142] Based on this, in this specification. After dividing several distributed service execution clusters corresponding to the same data source into the same cluster group according to the identifiers of the data sources corresponding to each distributed service execution cluster, actually multiple cluster groups can be obtained. For each cluster group, the identifiers of the data sources corresponding to the distributed service execution clusters included in this cluster group are the same. Therefore, the identifiers of the data sources corresponding to the distributed service execution clusters included in this cluster group can be used as the identifier of the data source corresponding to this cluster group.
[0143] Similarly, the intermediate device can store the identifier of the cluster group and the identifier of the data source corresponding to the cluster group in the form of key-value pairs. Of course, for the convenience of managing the distributed service execution clusters included in each cluster group, the corresponding relationship between the identifier of the cluster group and the identifiers of the distributed service execution clusters included in this cluster group can also be stored.
[0144] Step 2: Pre-acquire the loads respectively corresponding to each distributed service execution cluster.
[0145] This step is the same as the method of acquiring the loads of each distributed service execution cluster described above, and will not be elaborated here.
[0146] Step 3: In response to the first service execution request sent by the client, determine the specified identifier carried in the first service execution request, where the specified identifier is used to indicate the data source used to execute the first to-be-executed task corresponding to the first service execution request.
[0147] This step is similar to the second step in the above second case, and will not be elaborated here.
[0148] Step 4: According to the designated identifier and the identifiers of the data sources corresponding to the cluster groups, determine the target cluster group corresponding to the designated identifier from the cluster groups.
[0149] Specifically, the identifier of the cluster group corresponding to the specified identifier is searched from the key-value pair storing the identifier of the cluster group and the identifier of the data source corresponding to the cluster group with the specified identifier, and the target cluster group is determined according to the identifier of the found cluster group.
[0150] Step 5: According to the loads corresponding to the several distributed service execution clusters included in the target cluster group, determine the distributed service execution cluster with the smallest load in the target cluster as the target cluster.
[0151] Afterwards, based on the load balancing principle, a distributed service execution cluster with the smallest load is determined from among the distributed service execution clusters included in the target cluster group as the target cluster.
[0152] In an optional embodiment of the present specification, the intermediate device can not only communicate with multiple distributed business execution clusters, but can actually communicate with multiple clients, thereby providing distributed business execution cluster docking support for multiple different clients. However, in actual application scenarios, as the number of clients increases and business execution requirements increase, the intermediate device will receive an increasing number of business execution requests, resulting in a high load on each distributed business execution cluster. At this time, the intermediate device can introduce a new distributed business execution cluster to share the load of other distributed business execution clusters. The specific implementation method can be as follows:
[0153] First, the real-time loads corresponding to the distributed service execution clusters are obtained.
[0154] Afterwards, if the real-time loads corresponding to each distributed business execution cluster are greater than the load threshold, a new distributed business execution cluster is determined, and a communication connection is established between the intermediate device and the new distributed business execution cluster; the new distributed business execution cluster is a distributed business execution cluster that has not executed any tasks.
[0155] The load threshold may be a fixed value predetermined based on actual scenarios and prior experience, or may be updated during the execution of a service, which is not limited in this specification.
[0156] When the real-time load is greater than the load threshold, it indicates that the ability of the distributed service execution cluster to further undertake service execution is too low, and tasks should no longer be assigned to this distributed service execution cluster. If all the distributed service execution clusters communicating with the intermediate device have this situation, then each of the currently communicating distributed service execution clusters with the intermediate device cannot increase tasks anymore. Therefore, it is necessary to introduce new distributed service execution clusters that have not executed any tasks.
[0157] Of course, the timing of introducing new distributed service execution clusters can be not only when the load of each current distributed service execution cluster is too high, but also when there are unavailable clusters among the current distributed service execution clusters. At this time, the intermediate device can disconnect the communication connection with the unavailable clusters and establish a communication connection with the new distributed service execution clusters, thereby enhancing the high availability and fault tolerance of the overall system.
[0158] The above is the service execution method provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding service execution device, as Figure 4 shown.
[0159] Figure 4 The following is a schematic diagram of a service execution device provided by this specification, which specifically includes:
[0160] A target cluster determination module 300, configured to determine a target cluster from each distributed service execution cluster in response to a first service execution request sent by the client, and forward the first service execution request to the target cluster, so that the target cluster generates and returns a target identifier in response to the first service execution request, and executes a first to-be-executed task corresponding to the first service execution request;
[0161] A forwarding module 302, configured to receive the target identifier sent by the target cluster, store the correspondence between the target identifier and the target cluster, and send the target identifier to the client;
[0162] A lookup module 304, configured to, in response to a second service execution request sent by the client, look up the target cluster corresponding to the target identifier from the stored correspondence according to the target identifier carried in the second service execution request, and forward the second service execution request to the target cluster, so that the target cluster executes a second to-be-executed task corresponding to the second service execution request; where the first to-be-executed task and the second to-be-executed task belong to the same target service.
[0163] Optionally, the target cluster determination module 300 is specifically configured to obtain the loads corresponding to each distributed service execution cluster; and determine, according to the loads corresponding to each distributed service execution cluster, the distributed service execution cluster with the minimum load as the target cluster.
[0164] Optionally, the target cluster determination module 300 is specifically configured to pre-determine a load acquisition period; when the load acquisition period is reached, generate a load query request, and send the load query request to each master node of each distributed service execution cluster respectively; receive the loads corresponding to each distributed service execution cluster respectively returned by each master node of each distributed service execution cluster, where the load of the distributed service execution cluster includes the load of the master node in the distributed service execution cluster and the loads of multiple worker nodes in the distributed service execution cluster.
[0165] Optionally, the apparatus further includes:
[0166] A query module 306, which is specifically configured to iteratively execute: receive the current result query address sent by the target cluster, send the current result query address to the client, and receive the current result query request sent by the client, where the current result query request is generated by the client according to the current result query address and the target identifier; find, according to the target identifier carried in the current result query request, the target cluster corresponding to the target identifier from the stored corresponding relationship, forward the current result query request to the target cluster, receive the current task execution result and the next result query address returned by the target cluster, where the current task execution result is obtained by the target cluster according to the current result query address; and send the current task execution result and the next result query address to the client until the next result query address is an empty address.
[0167] Optionally, the data sources corresponding to the multiple distributed service execution clusters are different from each other;
[0168] Optionally, the target cluster determination module 300 is specifically configured to pre-obtain the identifiers of the data sources corresponding to each distributed service execution cluster respectively; in response to the first service execution request sent by the client, determine the specified identifier carried in the first service execution request, where the specified identifier is used to indicate the data source adopted for executing the first to-be-executed task corresponding to the first service execution request; and use, as the target cluster, the distributed service execution cluster in which the identifier of the corresponding data source is the same as the specified identifier among the distributed service execution clusters.
[0169] Optionally, the multiple distributed service execution clusters respectively correspond to multiple data sources, where at least two of the multiple distributed service execution clusters correspond to the same data source;
[0170] Optionally, the target cluster determination module 300 is specifically configured to: pre-acquire the identifiers of the data sources respectively corresponding to the distributed service execution clusters, divide several distributed service execution clusters with the same identifier of the corresponding data source into the same cluster group to obtain each cluster group, and determine the identifiers of the data sources respectively corresponding to each cluster group according to the identifiers of the data sources corresponding to the several distributed service execution clusters respectively included in each cluster group; pre-acquire the loads respectively corresponding to the distributed service execution clusters; in response to a first service execution request sent by the client, determine a specified identifier carried in the first service execution request, where the specified identifier is used to indicate the data source used to execute a first to-be-executed task corresponding to the first service execution request; determine a target cluster group corresponding to the specified identifier from each cluster group according to the specified identifier and the identifiers of the data sources respectively corresponding to each cluster group; and determine the distributed service execution cluster with the smallest load in the target cluster group as the target cluster according to the loads corresponding to the several distributed service execution clusters included in the target cluster group.
[0171] Optionally, the apparatus further includes:
[0172] An expansion module 308, specifically configured to obtain the real-time loads respectively corresponding to the distributed service execution clusters; if the real-time loads respectively corresponding to the distributed service execution clusters are all greater than a load threshold, determine a new distributed service execution cluster, and establish a communication connection between the intermediate device and the new distributed service execution cluster; the new distributed service execution cluster is a distributed service execution cluster that has not executed tasks.
[0173] This specification also provides a computer-readable storage medium, which stores a computer program, and the computer program can be used to execute the above Figure 2 shown service execution method.
[0174] This specification also provides Figure 5 a schematic structural diagram of the electronic device shown. As Figure 5 described, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above Figure 2The business execution method shown. Of course, in addition to the software implementation, this specification does not exclude other implementation methods, such as logic devices or the combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, and can also be hardware or logic devices.
[0175] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to circuit structures such as diodes, transistors, switches, etc.) or software improvements (improvements to method flows). However, with the development of technology, many method flow improvements today can be regarded as direct improvements to hardware circuit structures. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement to a method flow cannot be implemented using a hardware entity module. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is an integrated circuit whose logical function is determined by the user programming the device. Designers can program themselves to "integrate" a digital system onto a single PLD, without having to ask a chip manufacturer to design and fabricate a dedicated integrated circuit chip. Moreover, nowadays, instead of manually fabricating integrated circuit chips, this programming is mostly implemented using "logic compiler" software, which is similar to the software compiler used in program development and writing. The original code before compilation also has to be written in a specific programming language, which is called a Hardware Description Language (HDL). There is not just one type of HDL, but many types, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones currently are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also be aware that by simply performing a little logical programming on the method flow using the above-mentioned several hardware description languages and programming it into an integrated circuit, it is easy to obtain the hardware circuit that implements the logical method flow.
[0176] The controller can be implemented in any suitable manner. For example, the controller can take the form of, for example, a microprocessor or a processor and a computer-readable medium storing computer-readable program code (such as software or firmware) executable by the (micro)processor, logic gates, switches, an application specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of the controller include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in the form of pure computer-readable program code, it is entirely possible to logically program the method steps to enable the controller to be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers, and embedded microcontrollers to achieve the same function. Therefore, such a controller can be considered a hardware component, and the devices included therein for implementing various functions can also be regarded as the structures within the hardware component. Or even, the devices for implementing various functions can be regarded as either software modules for implementing the method or the structures within the hardware component.
[0177] The systems, devices, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0178] For the convenience of description, when describing the above devices, they are described separately as various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0179] Those skilled in the art should understand that the embodiments of this specification can be provided as a method, a system, or a computer program product. Therefore, this specification can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this specification can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer-usable program code.
[0180] This specification is described with reference to the flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the specification. It should be understood that each flow and / or block in the flowchart and / or block diagram, and combinations of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions executed by the processor of the computer or other programmable data processing device generate means for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0181] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer-readable memory produce a manufacture including instruction means that implement the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0182] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operational steps are performed on the computer or other programmable device to produce a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more of the flows Figure 1 one or more of the flows and / or blocks Figure 1 or means for implementing the functions specified in one or more of the blocks.
[0183] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0184] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory such as read-only memory (ROM) or flash RAM. The memory is an example of computer-readable media.
[0185] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0186] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0187] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0188] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0189] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the relevant parts, reference can be made to the partial description of the method embodiment.
[0190] The above description is only for the embodiments of this specification and is not intended to limit this specification. For those skilled in the art, various modifications and changes can be made to this specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification shall be included within the scope of the claims of this specification.
Claims
1. A service execution method, characterized in that: The method is applied to an intermediate device, the intermediate device is respectively connected to a client and a plurality of distributed service execution clusters corresponding to a plurality of data sources, wherein at least two distributed service execution clusters correspond to the same data source; the method comprises: Pre-acquire the identifiers of the data sources corresponding to the distributed service execution clusters, and divide several distributed service execution clusters having the same identifiers of the corresponding data sources into the same cluster group, to obtain the cluster groups and the identifiers of the data sources corresponding to the cluster groups; Pre-acquire the loads corresponding to the distributed service execution clusters respectively; In response to a first service execution request sent by the client, determining a designated identifier carried by the first service execution request, wherein the designated identifier is used to indicate a data source used to execute a first to-be-executed task corresponding to the first service execution request; Using the identifiers of the data sources corresponding to the cluster groups, a target cluster group corresponding to the specified identifier is determined from the cluster groups, and a distributed business execution cluster with the smallest load in the target cluster group is determined as a target cluster, and the first business execution request is forwarded to the target cluster, so that the target cluster generates and returns a target identifier in response to the first business execution request, and executes a first to-be-executed task corresponding to the first business execution request; receiving a target identifier sent by the target cluster, storing a corresponding relationship between the target identifier and the target cluster, and sending the target identifier to the client; In response to the second service execution request sent by the client, according to the target identifier carried in the second service execution request, searching for the target cluster corresponding to the target identifier from the stored corresponding relationship, and forwarding the second service execution request to the target cluster, so that the target cluster executes the second task to be executed corresponding to the second service execution request; the second service execution request is generated in combination with the task requirements of the second task to be executed input by the user and the target identifier; The first to-be-executed task and the second to-be-executed task belong to the same target business, and multiple to-be-executed tasks belonging to the same target business need to be executed by the same distributed business execution cluster.
2. The method according to claim 1, characterized in that The obtaining of the loads corresponding to the distributed service execution clusters specifically includes: predetermining a load acquisition cycle; When the load acquisition cycle is reached, a load query request is generated, and the load query request is sent to each master node of each distributed service execution cluster respectively; Receive the loads corresponding to each distributed business execution cluster returned by each master node of each distributed business execution cluster, wherein the load of the distributed business execution cluster includes the load of the master node in the distributed business execution cluster and the load of multiple working nodes in the distributed business execution cluster.
3. The method according to claim 1, characterized in that After sending the target identifier to the client and before responding to the second service execution request sent by the client, the method further includes: Iterative execution: receiving the current result query address sent by the target cluster, sending the current result query address to the client, and receiving the current result query request sent by the client, wherein the current result query request is generated by the client according to the current result query address and the target identifier; according to the target identifier carried in the current result query request, searching for the target cluster corresponding to the target identifier from the stored corresponding relationship, forwarding the current result query request to the target cluster, receiving the current task execution result and the next result query address returned by the target cluster, wherein the current task execution result is obtained by the target cluster according to the current result query address query; sending the current task execution result and the next result query address to the client until the next result query address is an empty address.
4. The method according to claim 1, characterized in that The data sources corresponding to the multiple distributed service execution clusters are different from each other; The step of determining a target cluster from each distributed service execution cluster in response to the first service execution request sent by the client specifically includes: Pre-acquire the identifiers of the data sources corresponding to each distributed business execution cluster; In response to a first service execution request sent by the client, determining a designated identifier carried by the first service execution request, wherein the designated identifier is used to indicate a data source used to execute a first to-be-executed task corresponding to the first service execution request; A distributed service execution cluster whose corresponding data source identifier is the same as the designated identifier among the distributed service execution clusters is used as a target cluster.
5. The method according to claim 1, characterized in that The method further comprises: Obtaining the real-time load corresponding to each of the distributed service execution clusters; If the real-time loads corresponding to the distributed business execution clusters are all greater than the load threshold, a new distributed business execution cluster is determined, and a communication connection is established between the intermediate device and the new distributed business execution cluster; the new distributed business execution cluster is a distributed business execution cluster that has not executed any tasks.
6. A service execution device, characterized in that: The device is applied to an intermediate device, and the intermediate device is respectively connected to a client and a plurality of distributed service execution clusters corresponding to a plurality of data sources, wherein at least two distributed service execution clusters correspond to the same data source; the device comprises: A target cluster determination module is used to pre-acquire the identifiers of the data sources corresponding to each distributed business execution cluster, divide several distributed business execution clusters with the same identifiers of the corresponding data sources into the same cluster group, and obtain the identifiers of each cluster group and the data sources corresponding to each cluster group; pre-acquire the load corresponding to each distributed business execution cluster; in response to the first business execution request sent by the client, determine the designated identifier carried by the first business execution request, wherein the designated identifier is used to indicate the data source used to execute the first task to be executed corresponding to the first business execution request; using the identifiers of the data sources corresponding to each cluster group, determine the target cluster group corresponding to the designated identifier from each cluster group, and determine the distributed business execution cluster with the smallest load in the target cluster group as the target cluster, and forward the first business execution request to the target cluster, so that the target cluster generates and returns the target identifier in response to the first business execution request, and executes the first task to be executed corresponding to the first business execution request; a forwarding module, configured to receive a target identifier sent by the target cluster, store a corresponding relationship between the target identifier and the target cluster, and send the target identifier to the client; A search module is used to respond to a second business execution request sent by the client, search for a target cluster corresponding to the target identifier from the stored correspondence relationship according to a target identifier carried in the second business execution request, and forward the second business execution request to the target cluster so that the target cluster executes the second task to be executed corresponding to the second business execution request; the second business execution request is generated in combination with the task requirements of the second task to be executed input by the user and the target identifier; wherein, the first task to be executed and the second task to be executed belong to the same target business, and multiple tasks to be executed belonging to the same target business need to be executed by the same distributed business execution cluster.
7. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method described in any one of claims 1 to 5 is implemented.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Data processing method and device and electronic equipment
CN113364818A
Task scheduling method and system, computing device, storage medium and program product
CN114296891A
Batch task processing method, device and equipment
CN117076453A