A task scheduling method, device, equipment and medium

By requesting the instance registration list in a distributed system and determining priority based on the IP address, the system complexity and uncertainty problems caused by increasing the scheduling center server are solved, and the task scheduling is simplified and reliable.

CN114020435BActive Publication Date: 2025-07-18CHINA CONSTRUCTION BANK
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111317594.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-09
Publication Date
2025-07-18
Estimated Expiration
2041-11-09

AI Technical Summary

Technical Problem

Adding a dispatch center server in a distributed system increases the complexity and uncertainty of the system and increases the probability of errors occurring at runtime.

Method used

The target electronic device requests the instance registration list from the registration center server, determines priority based on the IP address of the online application instance, and decides whether to perform tasks, avoiding the addition of the dispatch center server in the distributed system.

Benefits of technology

It reduces the complexity and uncertainty of distributed systems and reduces the probability of task execution errors.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114020435B_ABST
    Figure CN114020435B_ABST
Patent Text Reader

Abstract

A task scheduling method, device, equipment and medium provided by the present application. In the present application, a target electronic device deployed with an online application instance obtains an instance registration list of each online application instance corresponding to the function of the online application instance from a registration center server, and then determines the priority of each online application instance according to the IP address of each online application instance carried in the registration list, and determines whether the target electronic device executes the to-be-executed task according to the priority, realizing that when performing task scheduling, there is no need to add a scheduling center server in a distributed system, reducing the complexity and uncertainty of the distributed system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of distributed task scheduling, and particularly to a task scheduling method, apparatus, device and medium. Background Art

[0002] In the online scenario of a distributed system, there are at least two online application instances with the same function. Sometimes, tasks need to be executed regularly in the online scenario. At this time, each online application instance will execute this task. However, due to the repeated execution of the same task, the execution result of this task may be incorrect, resulting in the failure of task execution. Therefore, in the prior art, a scheduling center server is added to the distributed system, so that when executing a task, only one online application instance is selected to execute this task, avoiding the repeated execution of the task.

[0003] However, adding a scheduling center server to the distributed system is equivalent to expanding the overall architecture of the distributed system. And in order for each electronic device deployed with an online application instance to communicate with this scheduling center server, interfaces will be added, resulting in an increase in the complexity and uncertainty of the distributed system. At the same time, it also increases the probability of errors occurring during the operation of this distributed system, affecting the user experience. Summary of the Invention

[0004] This application provides a task scheduling method, apparatus, device and medium, which are used to solve the problems that adding a scheduling center server to the distributed system increases the complexity and uncertainty of the distributed system and increases the probability of errors occurring during operation.

[0005] This application provides a task scheduling method, and the method includes:

[0006] If a task to be executed is recognized, the target electronic device sends a request to obtain an instance registration list to the registration center server, where the request carries the function of the online application instance deployed in the target electronic device;

[0007] Receive the instance registration list sent by the registration center server, which contains each online application instance corresponding to the function of the online application instance;

[0008] According to the IP address of each online application instance carried in the instance registration list, determine the priority of each online application instance in the instance registration list;

[0009] According to the priority of each online application instance, determine whether the target electronic device executes the task to be executed.

[0010] Further, determining the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list includes:

[0011] Sort the IP addresses according to the IP addresses corresponding to the online application instances in the instance registration list;

[0012] Determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0013] Further, determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0014] If the number of to-be-executed tasks does not exceed a preset quantity threshold, determine whether the priority of the target electronic device is the highest priority;

[0015] If so, determine that the target electronic device executes the to-be-executed task.

[0016] Further, the method further includes:

[0017] If the priority of the target electronic device is not the highest priority, determine that the target electronic device does not execute the to-be-executed task.

[0018] Further, determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0019] If the number of to-be-executed tasks exceeds the quantity threshold, calculate the hash value of the name of each to-be-executed task; calculate the modulus value of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus value corresponds to the priority order corresponding to the priority of the target electronic device. If so, determine that the target electronic device executes the to-be-executed task.

[0020] Further, the method further includes:

[0021] If the modulus value does not correspond to the priority order corresponding to the priority of the target electronic device, determine that the target electronic device does not execute the to-be-executed task.

[0022] This application also provides a task scheduling device, and the device includes:

[0023] A sending module, configured to, if a to-be-executed task is recognized, the target electronic device sends a request for obtaining an instance registration list to a registration center server, where the request carries the functions of the online application instances deployed in the target electronic device;

[0024] A receiving module, configured to receive an instance registration list of each online application instance corresponding to the function of the online application instance sent by the registration center server;

[0025] A determining module, configured to determine the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list;

[0026] An execution module, configured to determine whether the target electronic device executes the to-be-executed task according to the priority of each online application instance.

[0027] Further, the determining module is specifically configured to sort the IP addresses corresponding to the online application instances in the instance registration list; and determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0028] Further, the execution module is specifically configured to, if the number of to-be-executed tasks does not exceed a preset number threshold, determine whether the priority of the target electronic device is the highest priority; if so, determine that the target electronic device executes the to-be-executed task.

[0029] Further, the execution module is further configured to, if the priority of the target electronic device is not the highest priority, determine that the target electronic device does not execute the to-be-executed task.

[0030] Further, the execution module is specifically configured to, if the number of to-be-executed tasks exceeds the number threshold, calculate the hash value of the name of each to-be-executed task; calculate the modulus of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus corresponds to the priority order corresponding to the priority of the target electronic device; if so, determine that the target electronic device executes the to-be-executed task.

[0031] Further, the execution module is further configured to, if the modulus does not correspond to the priority order corresponding to the priority of the target electronic device, determine that the target electronic device does not execute the to-be-executed task.

[0032] This application further provides an electronic device, which at least includes a processor and a memory, and the processor is configured to implement the steps of the task scheduling method described in any one of the above when executing a computer program stored in the memory.

[0033] This application further provides a computer-readable storage medium, which stores a computer program, and the computer program implements the steps of the task scheduling method described in any one of the above when executed by a processor.

[0034] A task scheduling method, apparatus, device, and medium provided by this application. If a to-be-executed task is recognized, the target electronic device sends a request to the registration center server to obtain an instance registration list, where the request carries the functions of the online application instances deployed in the target electronic device. The target electronic device receives the instance registration list of each online application instance corresponding to the functions of the online application instances sent by the registration center server. According to the IP address of each online application instance carried in the instance registration list, the priority of each online application instance in the instance registration list is determined. According to the priority of each online application instance, it is determined whether the target electronic device executes the to-be-executed task. In this application, the target electronic device deployed with online application instances obtains the instance registration list of each online application instance corresponding to the functions of the online application instances from the registration center server, then determines the priority of each online application instance according to the IP address of each online application instance carried in the registration list, and determines whether the target electronic device executes the to-be-executed task according to the priority, achieving that when performing task scheduling, there is no need to add a scheduling center server in the distributed system, reducing the complexity and uncertainty of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] To more clearly illustrate the technical solutions of this application, the following will briefly introduce the drawings required for use in the description of the embodiments. Obviously, the following drawings are only some embodiments of this application. For those of ordinary skill in the art, other drawings can be obtained according to these drawings without creative efforts.

[0036] Figure 1 It is a schematic diagram of a task scheduling process provided by an embodiment of this application;

[0037] Figure 2 It is a schematic flowchart of a task scheduling method provided by some embodiments of this application;

[0038] Figure 3a It is a schematic diagram of the process for the registration center server to save the IP address, identification information, and functions of online application instances provided by some embodiments of this application;

[0039] Figure 3b It is a schematic diagram of the process for the registration center server to send broadcast information to the saved online application instances provided by some embodiments of this application;

[0040] Figure 4 It is a schematic structural diagram of the task scheduling apparatus provided by this application;

[0041] Figure 5 It is a schematic structural diagram of an electronic device provided by this application. Detailed implementation manners

[0042] In order to make the objectives, technical solutions, and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0043] In the present application, if a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the function of the online application instance deployed in the target electronic device is carried in the request, receives the instance registration list including each online application instance corresponding to the function of the online application instance sent by the registration center server, determines the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list, and determines whether the target electronic device executes the task to be executed according to the priority of each online application instance.

[0044] In order to avoid adding a scheduling center server in a distributed system and reduce the complexity and uncertainty of the distributed system, the present application provides a task scheduling method, device, equipment, and medium.

[0045] Embodiment 1:

[0046] Figure 1 A schematic diagram of a task scheduling process provided for some embodiments of the present application, the process including:

[0047] S101: If a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the function of the online application instance deployed in the target electronic device is carried in the request.

[0048] A task scheduling method provided by the present application is applied to an electronic device, which is located in a distributed system and is deployed with an online application instance.

[0049] In this application, a distributed system can perform at least two functions, where each function corresponds to at least two online application instances, and each online application instance is deployed on a different electronic device. In this application, the distributed system also includes a registration center server, which stores the IP addresses, identification information, and functions of all the running online application instances in the distributed system. For each online application instance accessing the distributed system, the electronic device where the online application instance is located sends the identification information, IP address, and function of the online application instance to the registration center server. After receiving the identification information, IP address, and function sent by the electronic device, the registration center server stores them in a corresponding manner. Among them, in this application, the IP address of the online application instance is the IP address of the electronic device where the online application instance is located.

[0050] And the registration center server sends broadcast information to the electronic devices corresponding to the stored online application instances at regular intervals, and receives the response information sent by the electronic devices where each online application instance is located. For the online application instances that do not send response information, it is considered that the online application instances are offline, and the information corresponding to the offline online application instances stored is deleted. That is, in this application, the online application instances stored in the registration center server are all in a working state.

[0051] In this application, the same tasks and the execution time corresponding to each task are pre-configured for the online application instances with the same function. In addition, in the distributed system, for a task, only one online application instance needs to complete the task. Therefore, when the target electronic device with an online application instance deployed recognizes that there is a task to be executed, it is necessary to determine whether the target electronic device executes the task to be executed.

[0052] To determine whether the target electronic device executes the task to be executed, in this application, if the target electronic device recognizes that there is a task to be executed, it sends a request to obtain the instance registration list to the registration center server, and the request carries the function of the online application instances deployed in the target electronic device. Specifically, in this application, when the target electronic device recognizes that there is a task to be executed with the execution time being the current time among the pre-stored tasks, it sends a request to obtain the instance registration list to the registration center server in the distributed system where the target electronic device is located.

[0053] S102: Receive the instance registration list of each online application instance corresponding to the function of the online application instance sent by the registration center server.

[0054] In this application, after the target electronic device sends a request to obtain an instance registration list to the registration center server in the distributed system where it is located, since the request carries the functions of the online application instances deployed in the target electronic device, based on this, the registration center server will identify each online application instance corresponding to the function according to the function, and send an instance registration list containing the identified online application instances to the target electronic device, where the instance registration list includes the online application instances deployed in the target electronic device.

[0055] S103: Determine the priority of each online application instance in the instance registration list according to the IP address carried by each online application instance in the instance registration list.

[0056] In this application, after the target electronic device receives the instance registration list sent by the registration center server, in order to determine whether the target electronic device executes the to-be-executed task, it can determine the priority of the online application instances deployed in the target electronic device, and then determine whether the target electronic device executes the to-be-executed task according to the priority.

[0057] Among them, in this application, the priority of each online application instance in the received instance registration list can be determined, and then the priority of the online application instances deployed in the target electronic device can be determined. Specifically, the instance registration list carries the IP address corresponding to each online application instance, and the target electronic device also pre-saves a method for determining the priority of the online application instance according to the IP address. Based on this, the target electronic device can determine the priority of each online application instance in the instance registration list according to the IP address carried by each online application instance in the instance registration list.

[0058] S104: Determine whether the target electronic device executes the to-be-executed task according to the priority of each online application instance.

[0059] In this application, after determining the priority of each online application instance in the instance registration list, it can be determined whether the target electronic device executes the to-be-executed task based on the priority of each online application instance.

[0060] Specifically, the priority corresponding to the online application instance that executes the to-be-executed task can be pre-saved in each electronic device, where the priorities saved in each electronic device are the same. Generally, the priority corresponding to the online application instance that executes the to-be-executed task pre-saved in each electronic device is the highest priority.

[0061] After the target electronic device determines the priority of each online application instance in the instance registration list, it determines the priority corresponding to the online application instance deployed in the target electronic device, and determines whether the priority is the priority corresponding to the online application instance for executing the to-be-executed task pre-saved. If so, it determines that the target electronic device executes the to-be-executed task; if not, it determines that the target electronic device does not execute the to-be-executed task.

[0062] In this application, the target electronic device deployed with online application instances obtains the instance registration list of each online application instance corresponding to the function of the online application instance from the registration center server, and then determines the priority of each online application instance according to the IP address of each online application instance carried in the registration list, and determines whether the target electronic device executes the to-be-executed task according to the priority, realizing that when performing task scheduling, there is no need to add a scheduling center server in the distributed system, reducing the complexity and uncertainty of the distributed system.

[0063] Embodiment 2:

[0064] In order to determine the priority of each online application instance in the instance registration list, on the basis of the above embodiment, in this application, determining the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list includes:

[0065] Sort the numerical values of the IP addresses according to the IP address corresponding to the online application instance in the instance registration list;

[0066] Determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0067] In order to determine the priority of each online application instance in the instance registration list, in this application, the IP address corresponding to each online application instance carried in the instance registration list can be determined, and the IP address can be sorted according to the numerical value. Specifically, it can be sorted from largest to smallest according to the numerical value of the IP address, or it can be sorted from smallest to largest according to the numerical value of the IP address. The specific sorting rule can be pre-saved in the target electronic device and will not be limited here.

[0068] After determining the sorting result corresponding to the numerical size of the IP address, based on the sorting result, determine the sorting position of each online application instance in the sorting result, and determine the priority of each online application instance according to the sorting position.

[0069] Specifically, in the present application, when determining the priority of each online application instance according to the sorting position corresponding to the sorting result of each online application instance in the IP address, the higher the sorting position, the higher the priority of the online application instance, where the highest priority is level 0.

[0070] Figure 2 FIG. 4 is a schematic flowchart of a task scheduling method provided in some embodiments of the present application, and the process includes:

[0071] S201: If a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server.

[0072] S202: Receive the instance registration list of each online application instance corresponding to the function of the online application instance sent by the registration center server.

[0073] S203: Determine the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list.

[0074] S204: Determine whether the priority of the online application instance deployed in the target electronic device is the highest priority.

[0075] S205: If the priority of the online application instance deployed in the target electronic device is the highest priority, determine that the target electronic device executes the task to be executed.

[0076] Embodiment 3:

[0077] In order to determine whether the target electronic device executes the task to be executed, on the basis of the above embodiments, in the present application, determining whether the target electronic device executes the task to be executed according to the priority of each online application instance includes:

[0078] If the number of tasks to be executed does not exceed a preset number threshold, determine whether the priority of the target electronic device is the highest priority;

[0079] If so, determine that the target electronic device executes the task to be executed.

[0080] Since in the present application, only the priority of one online application instance for executing the task to be executed is saved in the target electronic device, generally, the priority corresponding to the online application instance for executing the task to be executed is the highest priority. However, when the number of tasks to be executed at the same time is too large, if all the tasks to be executed are executed by the electronic device where the online application instance corresponding to the highest priority is located, it will cause an excessive load on the electronic device and increase the time consumed for executing the task to be executed.

[0081] Therefore, in order to prevent an excessive number of tasks to be executed at the same time from being executed by the electronic device where the online application instance with the highest priority is located, in this application, a quantity threshold is preset. Only when the quantity of tasks to be executed at the current moment does not exceed this quantity threshold, will the electronic device where the online application instance corresponding to the highest priority be used to execute the task to be executed.

[0082] Specifically, in this application, after determining the priority corresponding to each online application instance in the instance registration list, determine the quantity of tasks to be executed at the current moment. If this quantity does not exceed the preset quantity threshold, then determine whether the priority of the online application instance deployed in the target electronic device is the highest priority. If so, determine that the target electronic device executes the task to be executed.

[0083] In order to determine whether the target electronic device executes the task to be executed, based on the above embodiments, in this application, the method further includes:

[0084] If the priority of the target electronic device is not the highest priority, then determine that the target electronic device does not execute the task to be executed.

[0085] In this application, if after determining the priority corresponding to each online application instance in the instance registration list, it is determined that the quantity of tasks to be executed at the current moment does not exceed the preset quantity threshold, but the priority of the online application instance deployed in the target electronic device is not the highest priority, then determine that the target electronic device does not execute the task to be executed.

[0086] Embodiment 4:

[0087] In order to determine whether the target electronic device executes the task to be executed, based on the above embodiments, in this application, determining whether the target electronic device executes the task to be executed according to the priority of each online application instance includes:

[0088] If the quantity of tasks to be executed exceeds the quantity threshold, then for each task to be executed, calculate the hash value of the name of the task to be executed; calculate the modulus value of the hash value and the quantity of online application instances in the instance registration list, and determine whether the modulus value corresponds to the priority order corresponding to the priority of the target electronic device. If so, determine that the target electronic device executes the task to be executed.

[0089] To avoid having too many tasks to be executed at the same time being executed by the electronic device with the highest priority and reduce the load pressure on the electronic device corresponding to the highest priority, in this application, if the number of tasks to be executed at the current moment exceeds a preset number threshold, the hash value of the name of each task to be executed is calculated, and the modulus value of the hash value of the name of each task to be executed and the number of online application instances in the instance registration list is calculated. For each hash value, if the modulus value of the hash value and the number of online application instances in the instance registration list corresponds to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device executes the task to be executed corresponding to the hash value.

[0090] Specifically, in this application, if the number of current tasks to be executed exceeds the preset number threshold, the hash value of the name of each task to be executed is calculated, and the modulus value of each hash value and the number of online application instances in the instance registration list is calculated. That is, for each hash value, divide the hash value by the number of online application instances in the instance registration list, and determine the remainder as the modulus value of the hash value and the number of online application instances in the instance registration list. If the modulus value corresponds to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device executes the task to be executed corresponding to the hash value.

[0091] To determine whether the target electronic device executes the task to be executed, based on the above embodiments, in this application, the method further includes:

[0092] If the modulus value does not correspond to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device does not execute the task to be executed.

[0093] In this application, if the number of tasks to be executed at the current moment exceeds the preset number threshold, the hash value of the name of each task to be executed is calculated, and the modulus value of each hash value and the number of online application instances in the instance registration list is calculated. That is, for each hash value, divide the hash value by the number of online application instances in the instance registration list, and determine the remainder as the modulus value of the hash value and the number of online application instances in the instance registration list. If the modulus value does not correspond to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device does not execute the task to be executed corresponding to the hash value.

[0094] Figure 3a It is a schematic diagram of the process for the registration center server provided in some embodiments of this application to save the IP address, identification information, and functions of online application instances. As shown in this Figure 3aAs described above, the distributed system includes three online application instances, namely, online application instance one, online application instance two, and online application instance three. After online application instance one accesses the distributed system where the registration center server is located, the electronic device where online application instance one is located sends the IP address, identification information, and functions corresponding to online application instance one to the registration center server; after online application instance two accesses the distributed system where the registration center server is located, the electronic device where online application instance two is located sends the IP address, identification information, and functions corresponding to online application instance two to the registration center server; after online application instance three accesses the distributed system where the registration center server is located, the electronic device where online application instance three is located sends the IP address, identification information, and functions corresponding to online application instance three to the registration center server.

[0095] Figure 3b It is a schematic diagram of the process in which the registration center server in some embodiments of the present application sends broadcast information to the saved online application instances. As shown in Figure 3b this figure, after the registration center server sends broadcast information to the electronic devices corresponding to the saved online application instances, it receives the response information sent by online application instance two and online application instance three, and does not receive the response information sent by online application instance one. Then it is considered that online application instance one is offline, and the information corresponding to online application instance one saved is deleted.

[0096] Embodiment 5:

[0097] Figure 4 It is a schematic diagram of the structure of the task scheduling device provided by the present application. As shown in Figure 4 this figure, the device includes:

[0098] A sending module 401, configured to, if a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the request carries the functions of the online application instances deployed in the target electronic device;

[0099] A receiving module 402, configured to receive the instance registration list of each online application instance corresponding to the functions of the online application instances sent by the registration center server;

[0100] A determining module 403, configured to determine the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list;

[0101] An execution module 404, configured to determine whether the target electronic device executes the task to be executed according to the priority of each online application instance.

[0102] In a possible implementation manner, the determining module 403 is specifically configured to sort the IP addresses corresponding to the online application instances in the instance registration list, and determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0103] In a possible implementation manner, the execution module 404 is specifically configured to, if the number of tasks to be executed does not exceed a preset quantity threshold, determine whether the priority of the target electronic device is the highest priority; if so, determine that the target electronic device executes the task to be executed.

[0104] In a possible implementation manner, the execution module 404 is further configured to, if the priority of the target electronic device is not the highest priority, determine that the target electronic device does not execute the task to be executed.

[0105] In a possible implementation manner, the execution module 404 is specifically configured to, if the number of tasks to be executed exceeds the quantity threshold, calculate the hash value of the name of each task to be executed; calculate the modulus of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus corresponds to the priority order corresponding to the priority of the target electronic device; if so, determine that the target electronic device executes the task to be executed.

[0106] In a possible implementation manner, the execution module 404 is further configured to, if the modulus does not correspond to the priority order corresponding to the priority of the target electronic device, determine that the target electronic device does not execute the task to be executed.

[0107] Embodiment 6:

[0108] Figure 5 A schematic structural diagram of an electronic device provided by the present application. On the basis of the above embodiments, the present application further provides an electronic device, as Figure 5 shown, including: a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504;

[0109] A computer program is stored in the memory 503. When the program is executed by the processor 501, the processor 501 is caused to execute the following steps:

[0110] If a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the request carries the functions of the online application instances deployed in the target electronic device;

[0111] Receive the instance registration list of each online application instance corresponding to the function of the online application instance sent by the registration center server;

[0112] Determine the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list;

[0113] Determine whether the target electronic device executes the to-be-executed task according to the priority of each online application instance.

[0114] In a possible implementation manner, the determining the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list includes:

[0115] Sort the IP addresses according to the IP addresses of the online application instances corresponding in the instance registration list;

[0116] Determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0117] In a possible implementation manner, the determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0118] If the number of to-be-executed tasks does not exceed a preset number threshold, determine whether the priority of the target electronic device is the highest priority;

[0119] If so, determine that the target electronic device executes the to-be-executed task.

[0120] In a possible implementation manner, the method further includes:

[0121] If the priority of the target electronic device is not the highest priority, determine that the target electronic device does not execute the to-be-executed task.

[0122] In a possible implementation manner, the determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0123] If the number of to-be-executed tasks exceeds the number threshold, calculate the hash value of the name of each to-be-executed task; calculate the modulus value of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus value corresponds to the priority order corresponding to the priority of the target electronic device. If so, determine that the target electronic device executes the to-be-executed task.

[0124] In a possible implementation manner, the method further includes:

[0125] If the modulus value does not correspond to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device does not execute the to-be-executed task.

[0126] Since the principle of problem-solving of the above-mentioned electronic device is similar to the task scheduling method, the implementation of the above-mentioned electronic device can refer to the above-mentioned embodiments, and the repeated parts will not be elaborated.

[0127] The communication bus mentioned in the above-mentioned electronic device may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The communication interface 502 is used for communication between the above-mentioned electronic device and other devices. The memory may include a Random Access Memory (RAM), and may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the foregoing processor. The above-mentioned processor may be a general-purpose processor, including a central processing unit, a network processor (NP), etc.; it may also be a Digital Signal Processing (DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0128] Embodiment 7:

[0129] Based on the above embodiments, the present application further provides a computer-readable storage medium, in which a computer program executable by a processor is stored. When the program runs on the processor, the processor is caused to execute the following steps:

[0130] If a to-be-executed task is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the function of the online application instance deployed in the target electronic device is carried in the request;

[0131] Receive the instance registration list of each online application instance corresponding to the function of the online application instance sent by the registration center server;

[0132] Determine the priority of each online application instance in the instance registration list according to the IP address carried in the instance registration list;

[0133] Determine whether the target electronic device executes the to-be-executed task according to the priority of each online application instance.

[0134] In a possible implementation manner, the determining the priority of each online application instance in the instance registration list according to the IP address carried in the instance registration list includes:

[0135] Sort the IP addresses according to the IP addresses corresponding to the online application instances in the instance registration list;

[0136] Determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

[0137] In a possible implementation manner, the determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0138] If the number of to-be-executed tasks does not exceed a preset number threshold, determine whether the priority of the target electronic device is the highest priority;

[0139] If so, determine that the target electronic device executes the to-be-executed task.

[0140] In a possible implementation manner, the method further includes:

[0141] If the priority of the target electronic device is not the highest priority, determine that the target electronic device does not execute the to-be-executed task.

[0142] In a possible implementation manner, the determining whether the target electronic device executes the to-be-executed task according to the priority of each online application instance includes:

[0143] If the number of to-be-executed tasks exceeds the number threshold, for each to-be-executed task, calculate the hash value of the name of the to-be-executed task; calculate the modulus of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus corresponds to the priority order corresponding to the priority of the target electronic device. If so, determine that the target electronic device executes the to-be-executed task.

[0144] In a possible implementation manner, the method further includes:

[0145] If the modulus value does not correspond to the priority order corresponding to the priority of the target electronic device, it is determined that the target electronic device does not execute the to-be-executed task.

[0146] Since the principle of problem-solving of the computer-readable medium provided above is similar to the task scheduling method, after the processor executes the computer program in the computer-readable medium, the implemented steps can refer to the above embodiments, and the repeated parts will not be elaborated.

[0147] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can adopt 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.

[0148] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination 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, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0149] 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 work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including instruction means, and the instruction means implements the functions specified in one Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate 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 Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.

[0151] Obviously, those skilled in the art can make various changes and modifications to this application without departing from the spirit and scope of this application. Thus, if these modifications and variations of this application fall within the scope of the claims of this application and their equivalent technologies, this application is also intended to include these modifications and variations.

Claims

1. A task scheduling method, characterized in that, The method includes: If a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the function of the online application instance deployed in the target electronic device is carried in the request; Receiving the instance registration list including each online application instance corresponding to the function of the online application instance sent by the registration center server; Determining the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list; Determining whether the target electronic device executes the task to be executed according to the priority of each online application instance; Among them, the determining whether the target electronic device executes the task to be executed according to the priority of each online application instance includes: If the number of tasks to be executed exceeds a quantity threshold, for each task to be executed, calculate the hash value of the name of the task to be executed; calculate the modulus value of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus value corresponds to the priority order corresponding to the priority of the online application instance deployed in the target electronic device. If so, determine that the target electronic device executes the task to be executed.

2. The method according to claim 1, characterized in that The determining the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list includes: Sorting the IP addresses according to the IP addresses of the online application instances in the instance registration list; Determining the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

3. The method according to claim 1, wherein The determining whether the target electronic device executes the task to be executed according to the priority of each online application instance includes: If the number of tasks to be executed does not exceed a preset quantity threshold, determine whether the priority of the online application instance deployed in the target electronic device is the highest priority; If so, determine that the target electronic device executes the task to be executed.

4. The method according to claim 3, characterized in that, The method further includes: If the priority of the online application instance deployed in the target electronic device is not the highest priority, determine that the target electronic device does not execute the task to be executed.

5. The method according to claim 1, characterized in that The method further includes: If the modulus value does not correspond to the priority order corresponding to the priority of the online application instance deployed in the target electronic device, determine that the target electronic device does not execute the task to be executed.

6. A task scheduling device, characterized in that, The apparatus includes: A sending module, configured to, if a task to be executed is recognized, the target electronic device sends a request for obtaining an instance registration list to the registration center server, where the function of the online application instance deployed in the target electronic device is carried in the request; A receiving module, configured to receive the instance registration list including each online application instance corresponding to the function of the online application instance sent by the registration center server; A determining module, configured to determine the priority of each online application instance in the instance registration list according to the IP address of each online application instance carried in the instance registration list; An execution module, configured to determine whether the target electronic device executes the to-be-executed task according to the priority of each online application instance; Among them, the execution module is specifically configured to: if the number of to-be-executed tasks exceeds a quantity threshold, calculate the hash value of the name of each to-be-executed task; calculate the modulus of the hash value and the number of online application instances in the instance registration list, and determine whether the modulus corresponds to the priority order corresponding to the priority of the online application instances deployed in the target electronic device. If so, determine that the target electronic device executes the to-be-executed task.

7. The device according to claim 6, wherein The determination module is specifically configured to: sort the IP addresses corresponding to the online application instances in the instance registration list; determine the priority of each online application instance according to the sorting position of each online application instance in the sorting result.

8. The device according to claim 6, characterized in that, The execution module is specifically configured to: if the number of to-be-executed tasks does not exceed a preset quantity threshold, determine whether the priority of the online application instances deployed in the target electronic device is the highest priority; If so, determine that the target electronic device executes the to-be-executed task.

9. The device according to claim 8, characterized in that, The execution module is further configured to: if the priority of the online application instances deployed in the target electronic device is not the highest priority, determine that the target electronic device does not execute the to-be-executed task.

10. The device according to claim 6, characterized in that, The execution module is further configured to: if the modulus does not correspond to the priority order corresponding to the priority of the target electronic device, determine that the target electronic device does not execute the to-be-executed task.

11. An electronic device, characterized in that, The electronic device at least includes a processor and a memory. The processor is configured to implement the steps of the task scheduling method according to any one of claims 1-5 when executing a computer program stored in the memory.

12. A computer-readable storage medium, characterized in that, It stores a computer program, and when the computer program is executed by the processor, it implements the steps of the task scheduling method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Micro-service instance processing method and device, computer equipment and storage medium

    CN111800462A