Load balancing method, device and computer equipment for batch tasks
By introducing intermediate servers, load balancing of batch tasks is achieved, service blockage and downtime caused by unbalanced load of batch tasks in the existing technology is solved, and the efficiency and stability of system task execution are improved.
Patent Information
- Application Number
- CN202111348867.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-15
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2041-11-15
AI Technical Summary
The existing technology cannot achieve load balancing of batch tasks, resulting in service blockage or downtime, affecting the security and stability of the business.
By introducing an intermediate server between the scheduling server and the application server, registration and scheduling between the intermediate server, scheduling server and application server are realized, and appropriate target application servers are filtered out in the application server to perform load tasks according to the preset scheduling strategy.
Load balancing in the task dimension is realized, ensuring consistent performance of each server, reducing the busy server caused by peak traffic, improving interface stability and availability, making full use of cluster resources, and reducing resource waste.
Smart Images

Figure CN114048033B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computing technology, and in particular to a load balancing method, device and computer equipment for running batch tasks. Background Art
[0002] There are many scenarios in existing projects that require the scheduled execution of certain special tasks or batch data. Generally, it is necessary to set up scheduled tasks and perform specific operations at the execution time set by the scheduled tasks.
[0003] At present, the solution adopted for batch tasks is to use the quartz framework, a timed scheduling framework, to implement scheduled task scheduling, and use the method of direct application connection scheduling service. However, due to the scheduling characteristics of the quartz framework, it is impossible to meet the balanced distribution of tasks for all machines in the same cluster. It can only randomly select a server for execution based on the registered heartbeat time. If the server is in a relatively busy state at this time, it may cause service congestion or even downtime, affecting the security and stability of the business. At the same time, if the business execution process and batch running are on the same server, it will affect the normal functional application, which is unacceptable for server operation. Summary of the invention
[0004] In view of this, the present application provides a load balancing method, device and computer equipment for running batch tasks, which can solve the current technical problem that load balancing control cannot be achieved for running batch tasks, which easily leads to service congestion or even downtime, affecting the security and stability of the business.
[0005] According to one aspect of the present application, a load balancing method for running batch tasks is provided, the method comprising:
[0006] Obtaining first configuration information of the intermediate server and second configuration information of the application server;
[0007] Registering the intermediate server in the scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and sending a scheduling service instruction to the intermediate server according to the first registration information;
[0008] Based on the second configuration information, the application server is registered in the intermediate server so that the second registration information of the application server is stored on the intermediate server. After receiving the scheduling service instruction, the target application server that meets the preset scheduling strategy is screened out from the application servers according to the second registration information, and the target application server is used to execute the load task that matches the scheduling service instruction.
[0009] According to another aspect of the present application, a load balancing device for running batch tasks is provided, the device comprising:
[0010] An acquisition module, used to acquire first configuration information of the intermediate server and second configuration information of the application server;
[0011] A first scheduling module, configured to register the intermediate server in a scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and send a scheduling service instruction to the intermediate server according to the first registration information;
[0012] The second scheduling module is used to register the application server in the intermediate server based on the second configuration information, so that the second registration information of the application server is stored on the intermediate server, and after receiving the scheduling service instruction, the target application server that meets the preset scheduling strategy is screened out from the application servers according to the second registration information, and the target application server is used to execute the load task matching the scheduling service instruction.
[0013] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the load balancing method for running batch tasks described above is implemented.
[0014] According to another aspect of the present application, a control device for a game account is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, and the processor implements the load balancing method for running batch tasks when executing the program.
[0015] By means of the above technical scheme, the present application provides a load balancing method, device and computer equipment for running batch tasks, which can first obtain the first configuration information of the intermediate server and the second configuration information of the application server, and register the intermediate server in the scheduling server based on the first configuration information, and store the first registration information of the intermediate server in the scheduling server, and register the application server in the intermediate server based on the second configuration information, and store the second registration information of the application server in the intermediate server; further, the scheduling service instruction can be sent to the intermediate server according to the first registration information, and after receiving the scheduling service instruction, the intermediate server screens out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and uses the target application server to execute the load task matching the scheduling service instruction. Through the technical scheme in the present application, through a third-party intermediate server, the application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the third-party intermediate server. The advantage of this is that decoupling is achieved, and the application server no longer cares about the scheduling server problem. Everything is solved by the intermediate server, which can improve the efficiency and stability of the system in executing tasks. Moreover, by implementing load balancing scheduling of application servers according to preset scheduling strategies through intermediate servers, load balancing in the task dimension can be achieved, ensuring that the performance of each server is at the same level, reducing server busyness caused by traffic peaks, thereby improving interface stability and availability, and making full use of application server cluster resources and reducing resource waste.
[0016] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0018] Figure 1 A flow chart of a load balancing method for running batch tasks provided in an embodiment of the present application is shown;
[0019] Figure 2 A flow chart of another load balancing method for running batch tasks provided in an embodiment of the present application is shown;
[0020] Figure 3 A structural schematic diagram of a load balancing device for running batch tasks provided in an embodiment of the present application is shown;
[0021] Figure 4 A structural schematic diagram of another load balancing device for running batch tasks provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0022] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0023] In order to solve the technical problem that the current batch task cannot achieve load balancing control, which easily leads to service blocking or even downtime, affecting the security and stability of the business, this application provides a load balancing method for batch tasks, such as Figure 1 As shown, the method includes:
[0024] 101. Obtain first configuration information of an intermediate server and second configuration information of an application server.
[0025] Among them, the intermediate server is a third-party server created between the application server and the scheduling server. The application server can be specifically a business execution server for executing load tasks, and the scheduling server can be specifically a server for scheduling the regular execution of certain specific tasks or batch tasks. The application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the intermediate server; the first configuration information may include: IP address, storage, processor, hard disk, system bus, service group, job scheduling time configuration, scheduling service type, etc.; the second configuration information may include IP address, storage, processor, hard disk, system bus, service group, job scheduling time configuration, load mode, scheduling strategy configuration, etc.
[0026] In the existing implementation scheme, when the batch task is load distributed, each scheduling server is directly connected to the application server (clientA). However, due to the characteristics of the quartz framework scheduling, it is impossible to meet the balanced distribution of tasks for all machines in the same cluster. It can only randomly select an application server for execution according to the registered heartbeat time. If the application server is in a relatively busy state at this time, it may cause service blocking or even downtime, affecting the security and stability of the business. At the same time, if the business execution process and the batch are on the same application server, it will affect the normal functional application, which is unacceptable. And if there are two scheduling servers such as quartz and other components now, you have to consider the compatibility scheme when accessing, and each service (groupA, groupB...) must be compatible in this way, and the code is relatively redundant. In this regard, in this application, an intermediate server can be created between the scheduling server and the application server, and the intermediate server can realize the docking with the scheduling server and the application server respectively, so as to realize the decoupling of the scheduling server and the application server, and can realize the balanced control of the load flow, and ensure the orderly and normal operation of each server.
[0027] The execution subject of this application can be a load balancing control system for running batch tasks. In the system, application servers and scheduling servers can be configured, and an intermediate server can be created between the application server and the scheduling server. The application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the intermediate server. Through the technical solution in this application, it can be ensured that the application server is always in a stable and reliable state, that is, only a third-party server (intermediate server) needs to be referenced, and the application server does not need to worry about compatibility issues. It only needs to make the intermediate server compatible once; in addition, after the introduction of the intermediate server, the intermediate server finds the most suitable application server from each application server according to the scheduling strategy, which can effectively avoid the scheduling service directly connecting to the application server. By randomly selecting an application server for execution, the pressure and performance of the current application server are ignored, resulting in high consumption of the application server, affecting normal functional applications.
[0028] 102. Register the intermediate server in the scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and sends a scheduling service instruction to the intermediate server according to the first registration information.
[0029] The first registration information includes, but is not limited to, information such as service grouping, job scheduling time configuration, and scheduling service type.
[0030] For this embodiment, after obtaining the first configuration information of the intermediate server, the intermediate server can be first registered in the scheduling server based on the first configuration information to create a scheduling relationship between the scheduling server and the intermediate server. Specifically, the intermediate server can introduce the client package provided by the scheduling server, and execute the registration service in the client package when it is started. By obtaining some first configuration information of the current intermediate server, and then sending it to the scheduling server through an http request, the scheduling server will record and store this information, thereby realizing the registration of the intermediate server. It should be noted that the same intermediate server can be registered in multiple scheduling servers at the same time, and can be used to receive scheduling service instructions from multiple scheduling servers, and then respond to the execution of scheduling based on the sending time of the scheduling service instructions, so as to ensure the orderly progress of scheduling; in order to ensure the simultaneous execution of scheduling services, multiple intermediate servers can be registered on the same scheduling server at the same time, which can be used to send scheduling service instructions to at least one intermediate server, so that the intermediate server can respond to the execution of scheduling service instructions in a timely manner and send load tasks to the application server.
[0031] 103. Register the application server in the intermediate server based on the second configuration information so that the second registration information of the application server is stored on the intermediate server, and after receiving the scheduling service instruction, screen out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and use the target application server to execute the load task that matches the scheduling service instruction.
[0032] The second registration information includes but is not limited to service grouping, IP, job scheduling time configuration, load mode and other information.
[0033] Corresponding to step 102 of the embodiment, after obtaining the second configuration information, the application server can be further registered in the intermediate server based on the second configuration information to create a scheduling relationship between the intermediate server and the application server. Specifically, the application server can introduce the client package provided by the intermediate server, and execute the registration service in the client package when it is started. By obtaining some second configuration information of the current application server, and then sending it to the intermediate server through an http request, the intermediate server will record and store this information, thereby realizing the registration of the application server. In addition, the application server can also configure the job through the annotations and implementation interfaces provided by the client package, and can select the scheduling strategy for each load task, such as balancing strategy, weight strategy, random strategy, CPU performance optimal strategy, memory optimal strategy, etc. It should be noted that the same application server can be registered in multiple intermediate servers according to different scheduling strategies, and can be used to receive and execute scheduling tasks issued by different intermediate servers.
[0034] For the present application, after the intermediate server is registered in the scheduling server through step 102 of the embodiment, and the application server is registered in the intermediate server through the steps of this embodiment, the intermediate server can further receive the scheduling service instructions issued by the scheduling server, and screen out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and use the target application server to execute the load task that matches the scheduling service instructions.
[0035] The load balancing method for running batch tasks provided in this embodiment can first obtain the first configuration information of the intermediate server and the second configuration information of the application server, and register the intermediate server in the scheduling server based on the first configuration information, and store the first registration information of the intermediate server in the scheduling server, and register the application server in the intermediate server based on the second configuration information, and store the second registration information of the application server in the intermediate server; further, a scheduling service instruction can be sent to the intermediate server according to the first registration information, and after receiving the scheduling service instruction, the intermediate server screens out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and uses the target application server to execute the load task matching the scheduling service instruction. Through the technical solution in this application, through a third-party intermediate server, the application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the third-party intermediate server. The advantage of this is that decoupling is achieved, and the application server no longer cares about the scheduling server problem. Everything is solved by the intermediate server, which can improve the efficiency and stability of the system in executing tasks. Moreover, by implementing load balancing scheduling of application servers according to preset scheduling strategies through intermediate servers, load balancing in the task dimension can be achieved, ensuring that the performance of each server is at the same level, reducing server busyness caused by traffic peaks, thereby improving interface stability and availability, and making full use of application server cluster resources and reducing resource waste.
[0036] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the implementation of this embodiment, this embodiment also provides another load balancing for running batch tasks, such as Figure 2 As shown, the method includes:
[0037] 201. Obtain first configuration information of an intermediate server and second configuration information of an application server.
[0038] 202. Register the intermediate server in the scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and sends a scheduling service instruction to the intermediate server according to the first registration information.
[0039] For this embodiment, the intermediate server will register with the scheduling server when it is started. After the registration is completed, the scheduling server will return a unique code identification code to the intermediate server. A random number generator can be used to generate a random number, bind the corresponding IP, and use it to identify the identity information. This identification code can be mainly used for the heartbeat registration mechanism. Specifically, when the intermediate server introduces the client package, it will execute the registration service in the client package at startup, obtain the first registration information of the current intermediate server, and then send it to the scheduling server through an http request. The scheduling server will record and store this information, thereby realizing the registration of the intermediate server. After the registration is completed, a unique code identification code will also be returned to the intermediate server. After the intermediate server obtains the code, it will poll the scheduling server to send heartbeats and server CPU and memory information.
[0040] In order to ensure the stability of load operation, multiple intermediate servers can be registered for the same scheduling server at the same time, and intermediate servers that perform the same scheduling service type can be uniformly stored in an intermediate server cluster. Accordingly, when generating a unique code identification code, a random number generator can be used to generate a random number, bind the corresponding IP address, and use it to confirm the identity of the intermediate server. Otherwise, because there may be many intermediate servers in the intermediate server cluster, it is impossible to know which intermediate server is sending heartbeats and which intermediate servers are abnormal and do not send heartbeats without distinguishing them, so that the abnormal intermediate servers can be automatically eliminated according to the heartbeat to avoid scheduling notifications to intermediate servers that have already experienced abnormalities, resulting in unreal scheduling.
[0041] 203. Register the application server in the intermediate server based on the second configuration information, so that the intermediate server stores second registration information of the application server.
[0042] For this embodiment, in a specific application scenario, the application server will register with the intermediate server when it is started. After the registration is completed, the intermediate server will return a unique code to the application server. A random number generator can be used to generate a random number, bind the corresponding IP address, and use it to identify the identity information. This identification code can be mainly used for the heartbeat registration mechanism. Specifically, when the application server introduces the client package, it will execute the registration service in the client package when it is started. By obtaining some second registration information of the current application server and then sending it to the intermediate server through an http request, the intermediate server will record and store this information, thereby realizing the registration of the application server. Furthermore, by determining the scheduling service type of the application server, the application servers with the same scheduling service type can be divided into the same application server cluster, and each application server in the application server cluster is registered with the same intermediate server. For example, if there are 1, 2, and 3 application servers under the application server cluster groupA, then when these three application servers are started, they will register the following information with the intermediate server respectively {"group":"A","ip":"1.1.1.1"...}, {"group":"A","ip":"1.1.1.2"...}, {"group":"A","ip":"1.1.1.3"...}. After registration is completed, the intermediate server will return a unique code to the application server. After obtaining the code, the application server will poll the intermediate server to send heartbeats and server cpu and memory information.
[0043] In order to ensure the stability of load operation, multiple application servers can be registered at the same time for the same intermediate server, and the application servers that execute the scheduling tasks under the same scheduling strategy can be uniformly stored in an application server cluster. Among them, when generating a unique code identification code, a random number can be generated, bound to the corresponding IP, and used to confirm the identity of the application server. Otherwise, because there may be many application servers in the cluster, if you don't distinguish them, you can't know which application server is sending heartbeats, and which application servers are abnormal and don't send heartbeats, so that the abnormal application servers can be automatically removed according to the heartbeat, avoiding scheduling notifications to application servers that have already had abnormalities, resulting in unreal scheduling.
[0044] 204. After receiving the scheduling service instruction, determine a target application server cluster matching the scheduling service type according to the second registration information, and extract working status data of each application server in the target application server cluster.
[0045] The scheduling service instruction at least carries the scheduling service type.
[0046] For this embodiment, a scheduled task under the relevant scheduling service type can be configured in the scheduling server, and a corresponding matching target intermediate server cluster is selected according to the scheduling service type of the scheduled task, and an adapted intermediate server is screened out in the target intermediate server cluster, and then a scheduling service instruction is periodically sent to the intermediate server at a timing period (such as 5s). After receiving the scheduling service instruction, the intermediate server can extract the scheduling service type according to the scheduling service instruction, and determine the target application server cluster matching the scheduling service type according to the second registration information. The target application server cluster contains at least one application server. When the target application server cluster contains one application server, the application server can be determined as the target application server; when the target application server cluster contains multiple application servers, the working status data of each application server in the target application server cluster can be further extracted, and the embodiment step 205 is executed according to the working status data, and the application server with the highest matching degree is selected from the multiple application servers as the target application server. For example, if the matching target application server cluster groupA is determined according to the scheduling request, a target application server will be selected in groupA to issue the load task.
[0047] 205. Filter out a target application server from the application servers according to the working status data and the scheduling policy configured in the target application server cluster.
[0048] For this embodiment, specifically, according to the scheduling strategy configured in the target application server cluster, the weight ratio of each application server in the target application server cluster can be calculated, the application server with the largest application weight can be selected, its IP can be obtained, and the notification can be forwarded to the application server through the HTTP protocol, the client package interface can be triggered, and the relevant business code can be called to notify the application server to execute the scheduled task matching the scheduling request.
[0049] As an optional method, the working status data may include an attribute cumulative value, and the attribute cumulative value is used to indicate the cumulative number of times the load task is executed within the first preset time period, and the scheduling strategy includes a balancing strategy; accordingly, step 205 of the embodiment may specifically include: obtaining the attribute cumulative value of each application server in the target application server cluster; determining the application server with the smallest corresponding attribute cumulative value as the target application server. In this way, it can be ensured that each application server can receive an equal amount of service requests, which is suitable for scheduled tasks with a single task or similar resource consumption.
[0050] As another optional method, the working status data includes the service proportion, and the scheduling strategy includes the proportion strategy; accordingly, the embodiment step 205 may specifically include: determining the maximum service volume of the target application server cluster within the second preset time period, and the maximum service proportion of each application server; calculating the maximum service times of each application server according to the maximum service volume and the maximum service proportion; randomly generating an application server scheduling queue that is less than or equal to the maximum service volume according to the maximum service times; determining the first application server in the application server scheduling queue at the current moment as the target application server, and removing it from the application server scheduling queue. For example, the maximum service volume is 100, and each application server generates an application server scheduling queue of length 100 according to the maximum service proportion. For example, if application server A accounts for 20%, then application server code A accounts for 20, which is randomly distributed in the application server scheduling queue. Each time there is a scheduled task, the first application server is selected from the beginning as the target application server and removed from the application server scheduling queue.
[0051] As another optional method, the working status data includes the CPU usage rate and / or the memory space occupancy rate, and the scheduling strategy includes the server performance optimization strategy; the server performance optimization strategy refers to selecting the application server with the lowest CPU usage rate (memory usage rate) in the current time period according to the CPU and memory conditions uploaded by each application server, and sending a timing message to make it execute the corresponding load task. Accordingly, step 205 of the embodiment may specifically include: receiving the CPU usage rate and / or memory space occupancy rate uploaded by each application server in the target application server cluster; determining the application server with the lowest corresponding CPU usage rate and / or memory space occupancy rate as the target application server.
[0052] It should be noted that the working status data and scheduling strategies may also include other forms, which may lead to different specific implementation methods for screening out the target application server with the highest selection probability among the application servers based on the working status data and the scheduling strategy configured by the target application server cluster. All of these should fall within the scope of protection of this application and will not be listed here in detail.
[0053] 206. Determine a load task that matches the scheduling service instruction, and load the load task into a target application server for execution.
[0054] In specific application scenarios, for newly added intermediate servers, the scheduling server will automatically register them with the intermediate server cluster, and compare whether there are any intermediate servers that have been deleted or have abnormal heartbeats, so as to automatically delete the intermediate servers. Specifically, each intermediate server will periodically send heartbeats, such as once every 30 seconds, and will update the latest sending time when sending. The scheduling server will determine the time when all intermediate servers have recently sent heartbeats every 10 seconds, and then take measures to remove intermediate servers that have not sent heartbeats for more than the threshold. Similarly, for newly added application servers, the intermediate server will automatically register them with the application server cluster, and compare whether there are any application servers that have been deleted or have abnormal heartbeats, so as to automatically delete the application servers. Specifically, each application server will periodically upload a heartbeat, such as once every 30 seconds, and the latest upload time will be updated during the upload. The intermediate server will determine the time when all application servers have recently uploaded a heartbeat every 10 seconds, and then take removal measures for application servers that have exceeded the threshold and have not uploaded a heartbeat. For example, for group A above, if it is stipulated that a heartbeat is uploaded every 30 seconds, if application server 1 has not updated the heartbeat time for more than 1 minute, then we will remove application 1 from group A, and subsequent group A tasks will only be called between application servers 2 and 3 until application server 1 re-registers or uploads a heartbeat. Accordingly, as a preferred implementation, the steps of the embodiment may also include: using the scheduling server to receive the first heartbeat information uploaded by the intermediate server, determining the abnormal intermediate server based on the first heartbeat information, and deleting the first registration information of the abnormal intermediate server; using the intermediate server to receive the second heartbeat information uploaded by the application server, determining the abnormal application server based on the second heartbeat information, and deleting the second registration information of the abnormal application server.
[0055] By means of the load balancing method for running batch tasks, the first configuration information of the intermediate server and the second configuration information of the application server can be obtained first, and the intermediate server can be registered in the scheduling server based on the first configuration information, and the first registration information of the intermediate server is stored in the scheduling server, and the application server can be registered in the intermediate server based on the second configuration information, and the second registration information of the application server is stored in the intermediate server; further, a scheduling service instruction can be sent to the intermediate server according to the first registration information, and after receiving the scheduling service instruction, the intermediate server screens out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and uses the target application server to execute the load task matching the scheduling service instruction. Through the technical solution in the present application, through a third-party intermediate server, the application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the third-party intermediate server. The advantage of this is that decoupling is achieved, and the application server no longer cares about the scheduling server problem. Everything is solved by the intermediate server, which can improve the efficiency and stability of the system in executing tasks. Moreover, by implementing load balancing scheduling of application servers according to preset scheduling strategies through intermediate servers, load balancing in the task dimension can be achieved, ensuring that the performance of each server is at the same level, reducing server busyness caused by traffic peaks, thereby improving interface stability and availability, and making full use of application server cluster resources and reducing resource waste.
[0056] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the embodiment of the present application provides a load balancing device for running batch tasks, such as Figure 3 As shown, the device includes: an acquisition module 31, a first scheduling module 32, and a second scheduling module 33;
[0057] An acquisition module 31, which can be used to acquire first configuration information of the intermediate server and second configuration information of the application server;
[0058] A first scheduling module 32, which can be used to register the intermediate server in the scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and send a scheduling service instruction to the intermediate server according to the first registration information;
[0059] The second scheduling module 33 can be used to register the application server in the intermediate server based on the second configuration information, so that the second registration information of the application server is stored on the intermediate server, and after receiving the scheduling service instruction, the target application server that meets the preset scheduling strategy is screened out from the application server according to the second registration information, and the target application server is used to execute the load task matching the scheduling service instruction.
[0060] Among them, the scheduling request carries a scheduling service type. In a specific application scenario, when a target application server that meets a preset scheduling policy is screened out from the application server according to the second registration information, the second scheduling module 33 can be specifically used to determine a target application server cluster that matches the scheduling service type according to the second registration information, and extract the working status data of each application server in the target application server cluster; and screen out the target application server from the application server according to the working status data and the scheduling policy configured for the target application server cluster.
[0061] In a specific application scenario, the working status data may include an attribute cumulative value, which is used to indicate the cumulative number of times the load task is executed within a first preset time period. The scheduling strategy may include a balancing strategy. Accordingly, when the target application server is screened out from the application servers according to the working status data and the scheduling strategy configured in the target application server cluster, the second scheduling module 33 can be specifically used to obtain the attribute cumulative value of each application server in the target application server cluster; and determine the application server with the smallest corresponding attribute cumulative value as the target application server.
[0062] In a specific application scenario, the working status data may include a service proportion, and the scheduling strategy may include a proportion strategy; accordingly, when the target application server is screened out from the application servers according to the working status data and the scheduling strategy configured for the target application server cluster, the second scheduling module 33 can be specifically used to determine the maximum total service volume of the target application server cluster within a second preset time period, and the maximum service proportion of each application server; calculate the maximum service times of each application server according to the maximum service volume and the maximum service proportion; randomly generate an application server scheduling queue that is less than or equal to the maximum service volume according to the maximum service times; determine the first application server in the application server scheduling queue at the current moment as the target application server, and remove it from the application server scheduling queue.
[0063] In a specific application scenario, the working status data may include the CPU usage rate and / or the memory space occupancy rate, and the scheduling strategy may include the server performance optimization strategy; accordingly, when the target application server is screened out from the application servers according to the working status data and the scheduling strategy configured in the target application server cluster, the second scheduling module 33 may be specifically used to receive the CPU usage rate and / or the memory space occupancy rate uploaded by each application server in the target application server cluster; and determine the application server with the smallest corresponding CPU usage rate and / or memory space occupancy rate as the target application server.
[0064] In a specific application scenario, when using the target application server to execute the load task matching the scheduling service instruction, the second scheduling module 33 can be specifically used to determine the load task matching the scheduling service instruction; and load the load task into the target application server for execution.
[0065] In specific application scenarios, such as Figure 4 As shown, the device further includes: a first determination module 34 and a second determination module 35;
[0066] A first determination module 34, which may be used to receive the first heartbeat information uploaded by the intermediate server using the scheduling server, determine the abnormal intermediate server according to the first heartbeat information, and delete the first registration information of the abnormal intermediate server;
[0067] The second determination module 35 may be used to receive the second heartbeat information uploaded by the application server using the intermediate server, determine the abnormal application server according to the second heartbeat information, and delete the second registration information of the abnormal application server.
[0068] It should be noted that for other corresponding descriptions of the functional units involved in the load balancing device for running batch tasks provided in this embodiment, please refer to Figure 1 to Figure 2 The corresponding description will not be repeated here.
[0069] Based on the above Figure 1 to Figure 2 The method shown in the embodiment, accordingly, also provides a storage medium, which can be volatile or non-volatile, and stores computer-readable instructions, which are executed by the processor to implement the above-mentioned Figure 1 to Figure 2 The load balancing method for running batch tasks is shown.
[0070] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0071] Based on the above Figure 1 to Figure 2 The method shown and Figure 3 , Figure 4 In order to achieve the above-mentioned purpose, the present embodiment further provides a computer device, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 to Figure 2 The load balancing method for running batch tasks is shown.
[0072] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0073] Those skilled in the art will appreciate that the computer device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0074] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned computer device and supports the operation of information processing programs and other software and / or programs. The network communication module is used to realize communication between the components inside the storage medium, and communication with other hardware and software in the information processing entity device.
[0075] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware.
[0076] By applying the technical solution of the present application, compared with the current existing technology, the present application can first obtain the first configuration information of the intermediate server and the second configuration information of the application server, and register the intermediate server in the scheduling server based on the first configuration information, and store the first registration information of the intermediate server in the scheduling server, and register the application server in the intermediate server based on the second configuration information, and store the second registration information of the application server in the intermediate server; further, the scheduling service instruction can be sent to the intermediate server according to the first registration information, and after receiving the scheduling service instruction, the intermediate server screens out the target application server that meets the preset scheduling strategy in the application server according to the second registration information, and uses the target application server to execute the load task matching the scheduling service instruction. Through the technical solution in the present application, through the third-party intermediate server, the application server only needs to interact with the intermediate server, and the relationship between the intermediate server and the scheduling server is maintained by the intermediate server. The communication between the application server and the scheduling server is completely controlled by the third-party intermediate server. The advantage of this is that decoupling is achieved, and the application server no longer cares about the scheduling server problem. Everything is solved by the intermediate server, which can improve the efficiency and stability of the system execution task. Moreover, by implementing load balancing scheduling of application servers according to preset scheduling strategies through intermediate servers, load balancing in the task dimension can be achieved, ensuring that the performance of each server is at the same level, reducing server busyness caused by traffic peaks, thereby improving interface stability and availability, and making full use of application server cluster resources and reducing resource waste.
[0077] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0078] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A load balancing method for running batch tasks, characterized in that: include: Obtaining first configuration information of the intermediate server and second configuration information of the application server; Registering the intermediate server in the scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and sending a scheduling service instruction to the intermediate server according to the first registration information; Registering the application server in the intermediate server based on the second configuration information, so that the intermediate server stores the second registration information of the application server, and after receiving the scheduling service instruction, screening out a target application server that meets the scheduling policy from the application servers according to the second registration information, and using the target application server to execute the load task matching the scheduling service instruction; The scheduling request carries a scheduling service type; The step of selecting a target application server that meets a scheduling policy from among the application servers according to the second registration information includes: Determine, according to the second registration information, a target application server cluster matching the scheduling service type, and extract working status data of each application server in the target application server cluster; Filtering out a target application server from the application servers according to the working status data and a scheduling policy configured for the target application server cluster; The working status data includes an attribute cumulative value, the attribute cumulative value is used to represent the cumulative number of times the load task is executed within a first preset time period, and the scheduling strategy includes a balancing strategy; The step of selecting a target application server from the application servers according to the working status data and the scheduling policy configured by the target application server cluster includes: Obtaining the cumulative value of the attributes of each application server in the target application server cluster; Determine the application server with the smallest attribute cumulative value as the target application server; The working status data includes a service weight, and the scheduling strategy includes a weight strategy; The step of selecting a target application server from the application servers according to the working status data and the scheduling policy configured by the target application server cluster includes: Determine the maximum total service volume of the target application server cluster within a second preset time period, and the maximum service proportion of each application server; Calculate the maximum service times of each of the application servers according to the maximum service total amount and the maximum service proportion; Randomly generate an application server scheduling queue that is less than or equal to the maximum service total amount according to the maximum service number; The first application server in the application server scheduling queue at the current moment is determined as the target application server, and is removed from the application server scheduling queue.
2. The method according to claim 1, characterized in that: The working status data includes the CPU usage rate and / or the memory space occupancy rate, and the scheduling strategy includes the server performance optimization strategy; The step of selecting a target application server from the application servers according to the working status data and the scheduling policy configured by the target application server cluster includes: Receiving CPU usage and / or memory space occupancy uploaded by each application server in the target application server cluster; The application server corresponding to the smallest CPU usage rate and / or the smallest memory space occupancy rate is determined as the target application server.
3. The method according to claim 1, characterized in that: The using the target application server to execute the load task matching the scheduling service instruction includes: Determining a load task matching the dispatch service instruction; The load task is loaded into the target application server for execution.
4. The method according to claim 1, characterized in that: The method further comprises: Using the scheduling server to receive the first heartbeat information uploaded by the intermediate server, determining the abnormal intermediate server according to the first heartbeat information, and deleting the first registration information of the abnormal intermediate server; The second heartbeat information uploaded by the application server is received by using an intermediate server, an abnormal application server is determined according to the second heartbeat information, and the second registration information of the abnormal application server is deleted.
5. A load balancing device for running batch tasks, characterized in that: include: An acquisition module, used to acquire first configuration information of the intermediate server and second configuration information of the application server; A first scheduling module, configured to register the intermediate server in a scheduling server based on the first configuration information, so that the scheduling server stores the first registration information of the intermediate server, and send a scheduling service instruction to the intermediate server according to the first registration information; A second scheduling module is used to register the application server in the intermediate server based on the second configuration information, so that the intermediate server stores the second registration information of the application server, and after receiving the scheduling service instruction, screen out a target application server that meets the scheduling policy from the application servers according to the second registration information, and use the target application server to execute the load task matching the scheduling service instruction; The scheduling request carries a scheduling service type; The second scheduling module is specifically used to determine a target application server cluster matching the scheduling service type according to the second registration information, and extract working status data of each application server in the target application server cluster; Filtering out a target application server from the application servers according to the working status data and a scheduling policy configured for the target application server cluster; The working status data includes an attribute cumulative value, the attribute cumulative value is used to represent the cumulative number of times the load task is executed within a first preset time period, and the scheduling strategy includes a balancing strategy; The second scheduling module is used to obtain the attribute cumulative value of each application server in the target application server cluster; and determine the application server corresponding to the smallest attribute cumulative value as the target application server; The working status data includes a service weight, and the scheduling strategy includes a weight strategy; The second scheduling module is used to determine the maximum service volume of the target application server cluster within a second preset time period, and the maximum service proportion of each application server; and calculate the maximum service times of each application server according to the maximum service volume and the maximum service proportion; Randomly generate an application server scheduling queue that is less than or equal to the maximum service total amount according to the maximum service number; The first application server in the application server scheduling queue at the current moment is determined as the target application server, and is removed from the application server scheduling queue.
6. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the load balancing method for running batch tasks described in any one of claims 1 to 4 is implemented.
7. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the load balancing method for running batch tasks described in any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Batch data scheduling method and system
CN102012840A
Dispatch server, load balancing method, system, and readable storage medium
CN109062739A