Service scheduling method and device, equipment, storage medium and product
By analyzing service call requests, determining candidate service providers, and selecting target providers based on service scheduling strategies, the problem of insufficient service call performance in complex distributed systems is solved, efficient and flexible service scheduling is achieved, and the overall performance of the system is improved.
Patent Information
- Application Number
- CN202411900958.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-23
- Publication Date
- 2025-04-18
AI Technical Summary
The prior art has shortcomings in dealing with the service call performance of complex distributed systems, especially when the service scale is expanded and the number of requests increases, a single RPC call method cannot meet the system performance requirements and lacks a flexible scheduling strategy.
By obtaining the service call request sent by the service consumer, parsing the request and determining the call service type, determining the candidate service provider based on the service type, obtaining the current service scheduling policy, and selecting the target service provider from the candidate provider according to the policy, executing the service call request and feedbacking the execution result.
It improves the efficiency and response speed of service calls, realizes the efficiency and flexibility of service calls, and improves the overall service call performance of distributed service systems.
Smart Images

Figure CN119847690A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a service scheduling method, device, equipment, storage medium and product. Background Art
[0002] At present, the distributed service scheduling system mainly relies on the registration center to realize the dynamic registration and discovery of services. These registration centers maintain a service list, allowing service providers to register their service information in the list, and service consumers can obtain the address and interface information of the required service from the list. Therefore, in terms of service calling, the existing technology usually adopts RESTful (Representational State Transfer) interface call based on HTTP (HyperText Transfer Protocol) or remote procedure call based on RPC (Remote Procedure Call).
[0003] However, these existing technical solutions still have some shortcomings when dealing with the needs of complex distributed systems. Specifically, in terms of service call performance, as the service scale expands and the number of requests increases, a single RPC call method may not be able to meet the performance requirements of the system. At the same time, facing a large number of service requests, the existing technical solutions also lack flexible scheduling strategies.
[0004] Therefore, as the scale of services expands and the number of service requests increases, how to improve the overall service performance of distributed systems and achieve high efficiency and flexibility in service calls has become a topic that technical personnel in this field urgently need to study. Summary of the invention
[0005] The present invention provides a service scheduling method, device, equipment, storage medium and product to improve the efficiency and flexibility of service calling.
[0006] According to one aspect of the present invention, there is provided a service scheduling method, comprising:
[0007] Obtaining a service call request sent by a service consumer, and parsing the service call request to determine the type of service being called;
[0008] Determining at least one candidate service provider according to the calling service type;
[0009] Acquire a current service scheduling strategy, and select a target service provider from the candidate service providers according to the current service scheduling strategy;
[0010] The service call request is sent to the target service provider, so that the target service provider calls the corresponding service to execute the service call request, and generates and feeds back the service call execution result.
[0011] According to another aspect of the present invention, there is provided a service scheduling device, comprising:
[0012] A service type determination module is used to obtain a service call request sent by a service consumer, and perform request parsing on the service call request to determine the call service type;
[0013] A candidate service provider determination module, configured to determine at least one candidate service provider according to the calling service type;
[0014] A target service provider selection module is used to obtain a current service scheduling strategy and select a target service provider from each of the candidate service providers according to the current service scheduling strategy;
[0015] The service call request sending module is used to send the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, and generate and feedback the service call execution result.
[0016] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0017] at least one processor; and
[0018] a memory communicatively connected to the at least one processor; wherein,
[0019] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the service scheduling method described in any embodiment of the present invention.
[0020] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the service scheduling method described in any embodiment of the present invention when executed.
[0021] According to another aspect of the present invention, a computer program product is provided. The computer program product includes a computer program. When the computer program is executed by a processor, the service scheduling method described in any embodiment of the present invention is implemented.
[0022] The technical solution of the embodiment of the present invention obtains the service call request sent by the service consumer, and parses the service call request to determine the type of service being called; determines at least one candidate service provider based on the type of service being called; obtains the current service scheduling strategy, and selects a target service provider from each candidate service provider based on the current service scheduling strategy; sends the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, and generate and feedback the service call execution result. This technical solution can determine the candidate service provider based on the service call type of the service call request obtained, thereby improving the efficiency and response speed of the service call; further, it can also select the target service provider from the candidate service providers based on the current service scheduling strategy to execute the service call request, thereby achieving high efficiency and flexibility of the service call, and improving the overall service call performance of the distributed service system.
[0023] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0025] Figure 1 is a flow chart of a service scheduling method provided according to Embodiment 1 of the present invention;
[0026] Figure 2 is a flow chart of a service scheduling method provided according to Embodiment 2 of the present invention;
[0027] Figure 3 is a structural diagram of a service scheduling device provided according to Embodiment 3 of the present invention;
[0028] Figure 4 It is a structural diagram of an electronic device for implementing the service scheduling method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Embodiment 1
[0032] Figure 1 A flowchart of a service scheduling method is provided for the first embodiment of the present invention. This embodiment is applicable to the situation where the service scheduling performance of a distributed service scheduling system is insufficient and the scheduling efficiency of scheduled tasks is low. The method can be executed by a service scheduling device, which can be implemented in the form of hardware and / or software, and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0033] S110: Obtain a service call request sent by a service consumer, parse the service call request, and determine the type of service being called.
[0034] Among them, the service consumer can refer to a system role in a distributed system that initiates calls to other services and consumes the resources or functional services provided by them. The specific service consumer can be a client application or another service, which is mainly used to request resources or functional services from the service provider.
[0035] The service call request may be a process for requesting to call a specified service and perform an operation. The service type may refer to the service category of the service requested to be called, which may include order processing service, inventory management service, and user point service. The order processing service may check the inventory of goods and deduct the inventory by calling the inventory management service, and may increase the user's order points by calling the user point service.
[0036] Specifically, when a service consumer initiates a service call request, the service call request is parsed to determine the calling service and corresponding service type of the service call request. For example, when a request for redeeming gifts with points initiated by a user through a terminal application is obtained, the request is parsed and it can be determined that the calling service type of the request is a user points service, which is not specifically limited in this embodiment.
[0037] S120: Determine at least one candidate service provider according to the calling service type.
[0038] Among them, the service provider can be a system role in a distributed system that provides resources or functional services according to the initiated service call request. The resources or functional services provided by the specific service provider can be the same or different. For example, service provider A can provide order processing services and inventory management services, service provider B can provide inventory management services and user points services, and service provider C can provide order processing services, inventory management services, and user points services. This embodiment does not impose specific restrictions on this.
[0039] Specifically, candidate service providers can be selected from various service providers based on the call service type corresponding to the service call request initiated by the service consumer. For example, continuing with the above example, if the call service type initiated by the service consumer is an order processing service, service provider A and service provider C can be determined as candidate service providers.
[0040] S130: Obtain the current service scheduling strategy, and select a target service provider from the candidate service providers according to the current service scheduling strategy.
[0041] Among them, the service scheduling strategy can be a way of allocating calling services based on the service type of the calling service and the service provider, and can include random strategy, polling strategy, minimum active call number strategy, consistent hashing strategy, weighted random strategy and weighted polling strategy, etc.
[0042] Among them, the random strategy can be to randomly select a service provider from the list of all available service providers to handle the service request initiated by the service consumer. Assume that the service provider list is [P1, P2, P3]. When a service request arrives, a service provider can be randomly selected from the list to handle the service request, such as service provider P3. Furthermore, the random strategy can be based on a random number generation algorithm, that is, each time a service call request is received, a new random number will be generated, and then the service provider can be selected and determined based on the random number, which is specifically suitable for scenarios where all service providers have similar performance.
[0043] Among them, the polling strategy can be to assign service requests to service providers in the order of service requests initiated by service consumers. Assuming that the service provider list is [P1, P2, P3], the first service call request initiated by the service consumer can be assigned to P1, the second service call request can be assigned to P2, the third service call request can be assigned to P3, and the fourth service call request can be returned to P1, and so on. Furthermore, the polling strategy can be to maintain a counter to record the current allocation position of the service call request, that is, each time a new service call request arrives, the service provider to be assigned can be determined according to the value of the counter, and then the counter is increased by 1. When the value of the counter exceeds the number of service providers, the counter is reset to 0, which is specifically suitable for scenarios where all service providers have similar performance.
[0044] Among them, the least active call number strategy can be to count the number of service call requests currently being processed by each service provider. Then, when a new service call request arrives, the service provider with the least active call number is selected to process the request. Assume that there are service providers [P1, P2, P3], where service provider P1 currently has 3 service call requests being processed, P2 has 1 service call request being processed, and P3 has 2 service call requests being processed, then the new service call request can be allocated to service provider P2. Specifically, the least active call number strategy can be applicable to scenarios where there are large differences in service providers, and the allocation direction of service call requests can be adjusted in real time, so that service call requests are preferentially allocated to service providers with lighter loads.
[0045] Among them, the consistent hashing strategy can be to first calculate a position on the hash ring for each service provider. The calculation method is usually to perform a hash operation on the unique identifier of the service provider to obtain a hash value, and determine the position of the service provider on the hash ring based on the hash value. Then, when a service request arrives, the key information in the service call request is hashed to obtain the position of the service call request on the hash ring. Then, the service call request is assigned to the service provider closest to the hash ring in the clockwise direction. Assume that there are service providers P1, P2, and P3, and their positions on the hash ring are position 1, position 3, and position 6, respectively. When a new service call request is received, the user ID in the service call request is hashed to obtain the position 4 of the service call request on the hash ring. Then the service call request can be assigned to service provider P2, where P2 is the service provider closest to position 4 in the clockwise direction on the hash ring. Specifically, the consistent hashing strategy is applicable to scenarios in which service providers in distributed systems may change dynamically.
[0046] Among them, the weighted random strategy can be to assign a weight value to each service provider, wherein the weight value indicates the ability or priority of the service provider to process requests relative to other service providers. Furthermore, when a new service call request is received, a random selection can be made according to the weight value of each service provider, and the greater the weight value of a specific service provider, the greater the probability that the service provider will be selected. Assume that there are service providers P1, P2, and P3, where the weight of P1 is 3, the weight of P2 is 1, and the weight of P3 is 4. This means that if 7 selections are made, theoretically P1 will be selected 3 times, P2 will be selected 1 time, and P3 will be selected 4 times. Specifically, the weighted random strategy can be applicable to scenarios where the performance differences of service providers are known and it is desired to allocate service call requests according to the performance differences of service providers, such as assigning higher weights to service providers with high-performance servers to handle more service call requests.
[0047] Among them, the weighted polling strategy can be to set weights for service providers on the basis of the polling strategy. Furthermore, in each polling process, the number of allocated service call requests can be determined according to the weight of the service provider. Assume that there are service providers P1, P2, and P3, and the corresponding weights of each service provider are 2, 3, and 1, respectively. Further, 6 service call requests can be allocated in one round of polling, of which P1 can be allocated to 2 service call requests, P2 can be allocated to 3 service call requests, and P3 can be allocated to 1 service call request. The next round of polling is also allocated according to the same proportion. Specifically, the weighted polling strategy can be applicable to scenarios where service providers have different performance and hope to allocate requests according to the performance ratio. It can make full use of high-performance service providers, while also ensuring the reasonable use of low-performance service providers.
[0048] The current service calling strategy may be a currently adopted method for calling service allocation, which may be specifically set by a technician based on experience.
[0049] Specifically, when determining the candidate service providers according to the service call request initiated by the service consumer, the preset call service allocation method can be obtained, and the target service provider can be determined from the candidate service providers according to the call service allocation method, and the initiated service call request can be allocated to the target service provider. Exemplarily, continuing the above example, if the current service scheduling strategy is a random strategy, the target service provider can be randomly determined from service provider A and service provider C.
[0050] Optionally, if the current service scheduling strategy is a consistent hash call strategy, then according to the current service scheduling strategy, a target service provider is selected from each candidate service provider, including: determining the request key information of the service call request, and performing hash calculation on the request key information to determine the request hash value; determining the target position of the request hash value of the service call request in the hash ring; determining the target service provider based on the reference positions corresponding to each candidate service provider in the hash ring according to the target position of the service call request; wherein, the reference position of the candidate service provider in the hash ring is determined based on the reference hash value of the candidate service provider itself; and the reference hash value of the candidate service provider itself is determined based on its own identification information.
[0051] The key request information may be data information used to uniquely identify the service call request, such as the requested service type, user ID (Identity, etc.).
[0052] Among them, the hash ring can be a data distribution and load balancing technology commonly used in distributed systems. Specifically, the information corresponding to the service provider and the service call request can be hashed, and the calculated hash value can be mapped to a hash value space.
[0053] The identification information may be an identifier used to uniquely distinguish service providers, such as an IP (Internet Protocol) address, a service name, and the like.
[0054] Specifically, when a service call request initiated by a service consumer is obtained, the key request information of the service call request can be determined, and the key request information can be hashed to obtain the request hash value corresponding to the service call request, and then the position of the request hash value in the hash ring can be determined. Then, the target service provider can be determined based on the reference position of the service provider in the hash ring.
[0055] Exemplarily, continuing with the above example, if the service call request initiated by the service consumer is an inventory management service, the candidate service providers can be determined to be service provider B and service provider C. Furthermore, the request hash value of the service call request can be calculated according to the service type of the service call request, and according to the calculated request hash value, it can be determined that the position of the service call request on the hash ring is position 5. Among them, the reference position of service provider B in the hash ring is position 2, and the reference position of service provider C in the hash ring is position 4. The specific reference positions of service provider B and service provider C in the hash ring can be calculated based on the IP addresses of service provider B and service provider C. Therefore, it can be determined that service provider C is the service provider closest to position 5 in the clockwise direction on the hash ring, that is, service provider C can be determined as the target service provider, and the inventory management service can be assigned to service provider C.
[0056] This technical solution can use a consistent hashing strategy to perform hash operations on key information in a service call request and the identification information of a service provider, determine the position of the service call request and the service provider on the hash ring, and perform service call allocation. It can determine the target service provider for a service call request when the number of service providers increases or decreases dynamically, achieve high efficiency and flexibility in service calls, and improve the overall service call performance of a distributed service system.
[0057] S140: Send the service call request to the target service provider, so that the target service provider calls the corresponding service to execute the service call request, and generates and feeds back the service call execution result.
[0058] Among them, it can be that when the service type corresponding to the service call request initiated by the service consumer and the candidate service provider determine the target service provider, the service call request sender is the target service provider, and the target service provider calls the corresponding service according to the service call request for processing, generates the execution result of the service call and gives feedback. Specifically, when sending the service call request to the target service provider so that the target service provider calls the corresponding service to execute the service call request, generates and gives feedback on the service call execution result, the service call request can be serialized and the serialized service call request can be sent to the target service provider. So that the target service provider can deserialize the service call request, call the corresponding service to execute the service call request, generate and give feedback on the service call execution result. Further, when giving feedback on the service call result, the service call execution result can be serialized and the serialized service call execution result can be fed back to realize the efficient transmission of the service call request and the service call execution result in the network. Among them, serialization can be to convert the data in the memory into a data format that can be transmitted over the network, and deserialization can be to restore the data format that can be transmitted over the network to the original data structure.
[0059] Exemplarily, continuing the above, when the service consumer initiates a service call request for the inventory management service and determines that the target service provider is service provider C, the service call request is serialized and sent to service provider C. Service provider C deserializes the serialized service call request and executes the inventory management service to generate a service call execution result, such as a unit deducted from the inventory quantity. Further, service provider C serializes the generated service call execution result and sends the serialized service call execution result to the service consumer. The service consumer deserializes the serialized service call execution result and obtains an inventory management service call execution result with the inventory data deducted from one unit.
[0060] In an optional solution of this embodiment, it can be combined with one or more optional solutions of this embodiment. Optionally, obtain a number of service providers that register services in the service registration center in the current time period; determine the server performance corresponding to each service provider; determine whether to update the current service scheduling strategy based on the performance of each server; if so, update the current service scheduling strategy based on the performance of each server to obtain the updated current service scheduling strategy.
[0061] The service registration center may be a data platform for realizing dynamic registration and discovery of services. Specifically, statistics may be collected on all service providers of the service registration center in the current time period, and the server performance corresponding to each service provider may be determined. Then, according to the determined performance of each server, the current service scheduling strategy may be updated to obtain the updated current service scheduling strategy.
[0062] Exemplarily, there may be service provider D, service provider E, and service provider F, where when service providers D, E, and F are registered, the performance of the servers corresponding to each of them is consistent, and the current service scheduling strategy is a polling strategy. As service providers D, E, and F call the corresponding services according to the service call request initiated by the service consumer, the performance of the server corresponding to service provider D decays by 40%, the performance of the server corresponding to service provider E decays by 10%, and the performance of the server corresponding to service provider F decays by 20%. The polling strategy is mainly applicable to scenarios where the performance of the servers corresponding to the service providers is similar. It can be determined that the current service scheduling strategy is updated, and it can be determined that the updated service scheduling strategy is a weighted polling strategy.
[0063] This technical solution can update the current service scheduling strategy according to the performance of the server corresponding to each service provider, and optimize the load of each service provider, thereby improving the utilization rate of service resources, the flexibility of the service calling system and the user experience.
[0064] The technical solution of the embodiment of the present invention obtains the service call request sent by the service consumer, and parses the service call request to determine the type of service being called; determines at least one candidate service provider based on the type of service being called; obtains the current service scheduling strategy, and selects a target service provider from each candidate service provider based on the current service scheduling strategy; sends the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, and generate and feedback the service call execution result. This technical solution can determine the candidate service provider based on the service call type of the service call request obtained, thereby improving the efficiency and response speed of the service call; further, it can also select the target service provider from the candidate service providers based on the current service scheduling strategy to execute the service call request, thereby achieving high efficiency and flexibility of the service call, and improving the overall service call performance of the distributed service system.
[0065] Embodiment 2
[0066] Figure 2 This is a flow chart of a service scheduling method provided in the second embodiment of the present invention. Based on the above embodiments, this embodiment further optimizes the above service scheduling method.
[0067] Furthermore, after the step "sending the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, generate and feedback the service call execution result", add the step "if the current time period meets the task start time of the service consumer's service scheduled task, then obtain the service scheduled task and task execution information from the corresponding slot of the time wheel to which the service scheduled task belongs; determine the task service provider according to the service scheduled task; send the service scheduled task and task execution information to the task service provider so that the task service provider can call the corresponding service, execute the service scheduled task based on the task execution information, and generate and feedback the task service execution result." to improve the generation method of the user access permission list. Figure 2 As shown, the method includes:
[0068] S210: Obtain a service call request sent by a service consumer, parse the service call request, and determine the type of service being called.
[0069] S220: Determine at least one candidate service provider according to the calling service type.
[0070] S230: Obtain the current service scheduling strategy, and select a target service provider from the candidate service providers according to the current service scheduling strategy.
[0071] S240: Send the service call request to the target service provider, so that the target service provider can call the corresponding service to execute the service call request, generate and feedback the service call execution result.
[0072] S250: If the current time period satisfies the task start time of the service scheduled task of the service consumer, the service scheduled task and task execution information are obtained from the corresponding slot of the time wheel to which the service scheduled task belongs.
[0073] Among them, the service scheduled task can be a task that is executed at a specified time based on a service call request initiated by a service consumer and set in the service call request. For example, if the service call request initiated is an order processing service, and the order processing service can also be used to make order payments, the time for executing the order payment task can be set while initiating the service call request, such as executing the order payment task after three minutes or five minutes. The order payment time can be set by the user according to actual needs. Task execution information can be the resource information required to execute the scheduled task, such as the payment account and payment password and other resource information required to execute the order payment task.
[0074] The time wheel can be a system component in a distributed system for recording service timed tasks. A slot can represent each time interval unit in the time wheel, where the time interval unit can be one minute or one second, which can be set by technical personnel according to actual conditions. Specifically, when a service timed task is included in a service call request initiated by a service consumer, the service timed task and the resource information required to execute the timed task can be placed in the corresponding slot according to the execution time of the timed task.
[0075] For example, if the time interval set in the time wheel is one second, and the service timer task is executed after 5 seconds, the service timer task can be placed in the fifth slot of the time wheel. There can also be a pointer inside the time wheel, and the pointer can move forward one grid according to the time interval. The pointer can point to the service timer task after 5 seconds, and then it can be determined that the current time period meets the task start time of the service timer task set by the service consumer in the service call request initiated, and the service timer task and the resource information required to execute the service timer task can be obtained in the fifth slot.
[0076] Optionally, the timing wheel is constructed as follows: obtain at least one scheduled task to be executed of at least one service consumer; determine the slot division method of the timing wheel according to the task time accuracy and task execution frequency of each scheduled task to be executed; divide the timing wheel into slots based on the slot division method to obtain at least one slot; add each scheduled task to be executed to the corresponding slot according to the task execution time of each scheduled task to be executed, so as to realize the construction of the timing wheel.
[0077] The task time accuracy may refer to the time interval set for the scheduled task, which may be one second or one minute. The specific time accuracy may be determined according to the scheduled tasks to be executed initiated by the service consumer. For example, if the first scheduled task to be executed is to be executed after 3 seconds and the second scheduled task to be executed is to be executed after 5 seconds, the task time accuracy may be determined to be one second, and this embodiment does not impose any specific restrictions on this.
[0078] The task execution frequency may refer to the number of scheduled tasks that need to be executed within a time period, such as executing a task once per second or once per minute.
[0079] Specifically, the slots of the time wheel can be divided according to the task time accuracy. For example, if the time accuracy can be one second, a time wheel can be constructed and include 60 slots, and the time wheel can represent 60 seconds (that is, each slot can be represented as one second), wherein the time accuracy can also be one minute, and the specific time accuracy can be determined according to the timing length of the scheduled task to be executed. Exemplarily, continuing the above example, if the timing duration of the scheduled task to be executed can be 3 seconds, it can be determined that each slot in the time wheel represents one second, and the scheduled task to be executed is placed in the third slot. Furthermore, if the timing duration of the scheduled task to be executed is 5 minutes, it can be determined that each slot in the time wheel represents one minute, and the scheduled task to be executed is placed in the fifth slot.
[0080] Furthermore, the slots of the time wheel can be divided according to the task execution frequency. Specifically, the number of scheduled tasks to be executed in the call service request appearing in each time interval can be counted, and the frequency of occurrence of the scheduled tasks in each time interval can be calculated, and then the slots of the time wheel can be divided according to the frequency of occurrence of the scheduled tasks. For example, the time interval can be 1 hour, in which there are 60 scheduled tasks appearing between 8 and 9 p.m., and 120 scheduled tasks appearing between 9 and 10 p.m., then it can be determined that the task execution frequency between 8 and 9 p.m. is to execute a scheduled task once per minute, and the task execution frequency between 9 and 10 p.m. is to execute two scheduled tasks per minute, and accordingly, the time wheel corresponding to 8 and 9 p.m. can be divided into 60 slots, and the time wheel corresponding to 9 and 10 p.m. can be divided into 120 slots, and then each task to be executed can be arranged in the corresponding slot.
[0081] This technical solution can divide the slots according to the task time accuracy and task execution frequency of the scheduled tasks to be executed initiated by the service consumers, and place the scheduled tasks to be executed in the corresponding slots, thereby optimizing the scheduling and triggering mechanism of the service scheduled tasks and improving the accuracy and efficiency of the execution of scheduled tasks.
[0082] S260: Determine the task service provider according to the scheduled service task.
[0083] Specifically, the corresponding service call request initiated by the service consumer can be determined based on the service timing task. Based on the service call request, the target service provider is determined, and the target service provider is determined as the task service provider. Exemplarily, if the service timing task is an order receipt task, the service timing task can be determined as a service call request initiated by the service consumer to call the order processing service. Furthermore, the target service provider can be determined based on the order processing service call, and the target service provider can be determined as the task service provider.
[0084] Specifically, the pre-built time wheel result can be obtained, and the slots in minutes can be determined in the time wheel structure, such as 60 slots can correspond to 1 hour. Exemplarily, when the order payment service is obtained and the payment is not completed, an order timeout task can be generated and the slot where the order timeout task should be inserted can be calculated according to the timeout time of the order (such as canceling the order payment service if the payment is not completed within 30 minutes). For example, if the order creation time is 10:00, the timeout task should be inserted into the slot corresponding to 10:30. The time wheel can run at a speed of one grid per minute. When the pointer moves to the slot corresponding to the order timeout task, the timing task of automatically canceling the order timeout and non-payment is triggered. At this time, the execution of the timed task is no longer a simple cancellation operation performed locally, but the target service provider is determined through the service scheduling strategy. Specifically, an order processing service provider can be selected based on the service strategy (such as the minimum active call number strategy) to execute the order timeout task and cancel the order logic. At the same time, it is also necessary to coordinate and schedule operations such as updating the database order status, rolling back the inventory (if it has been reserved before), and recording related logs that may be involved in the order cancellation logic. It is also necessary to coordinate and schedule with other related services (such as inventory management services, user points services, etc.).
[0085] S270: Send the service timing task and the task execution information to the task service provider, so that the task service provider can call the corresponding service, execute the service timing task based on the task execution information, and generate and feedback the task service execution result.
[0086] Among them, when the service timer task can be started, the service timer task can be sent to the task service provider, that is, the target service provider. Then, the target service provider can call the corresponding service, process the service timer task, generate the task service execution result and provide feedback. Specifically, when the service timer task is sent to the task service provider, and when the task service provider provides feedback on the generated task service execution result, serialization and deserialization processing can be adopted, and the specific implementation method can be the relevant content of the above-mentioned embodiment 1.
[0087] In an optional solution of this embodiment, one or more optional solutions of this embodiment can be combined. Optionally, the service provider's service call success rate, service response time, and scheduled task execution efficiency are monitored; according to the service call success rate, service response time, and scheduled task execution efficiency, it is determined whether to issue a service provider alarm; if so, an alarm notification message is generated and sent to the corresponding service provider.
[0088] Among them, the service call success rate can be used to indicate the proportion of successful calls to the total number of calls among all service calls. For example, if the service provided by the service provider can receive 100 service call requests in one hour, of which 95 service calls are successful and 5 service calls fail, then the service call success rate can be considered to be 95%.
[0089] Among them, the service response time can be the time when the service provider calls the corresponding service for processing and returns the processing result when receiving the service call request sent by the service consumer. For example, if the service provider receives the service call request sent by the service consumer at 10:30 and returns the processing result at 10:31, it can be determined that the service response time is 1 minute.
[0090] The efficiency of scheduled task execution can be the efficiency of starting and completing a task within a set time interval. Specifically, it can be a comprehensive execution efficiency calculated based on task execution time, task execution frequency, resource consumption, and system response.
[0091] Among them, determining whether to issue a service provider alarm can specifically be to compare the service call success rate, service response time and scheduled task execution efficiency of the monitored service provider with a preset threshold, and then issue a service provider alarm based on the comparison result. The specific threshold can be set by the technician based on experience. Exemplarily, the threshold corresponding to the preset service call success rate can be 90%, the threshold corresponding to the service response time can be 10 seconds, and the threshold corresponding to the scheduled task execution efficiency can be 80%. If the service call success rate of the service provider monitored within a week is 95%, the service response time is 11 seconds, and the scheduled task execution efficiency is 75%, it can be determined that the service response time and the scheduled task execution efficiency are both lower than the threshold, and it is determined to issue a service provider alarm. Generate an alarm message that the service response time and the scheduled task execution efficiency are lower than the threshold, and send the alarm message to the service provider.
[0092] This technical solution can monitor the service provider's service call success rate, service response time and scheduled task execution efficiency. When the monitored data is lower than the threshold, it can automatically trigger an alarm message, thereby strengthening the monitoring and alarm capabilities of the service call system, being able to promptly discover and handle potential problems, and improving the stability and reliability of the service call system.
[0093] The technical solution of the embodiment of the present invention determines the candidate service provider according to the service call type of the service call request obtained; and selects the target service provider from the candidate service providers according to the current service scheduling strategy to execute the service call request. Furthermore, if the current time period meets the task start time of the service timed task of the service consumer, the service timed task and task execution information are obtained from the corresponding slot of the time wheel to which the service timed task belongs; the task service provider is determined according to the service timed task; the service timed task and task execution information are sent to the task service provider so that the task service provider can call the corresponding service, execute the service timed task based on the task execution information, and generate and feedback the task service execution result. This technical solution can use the time wheel structure to directly send the service timed task to the target service provider when the current time period meets the start time of the service timed task, thereby realizing efficient scheduling and precise triggering of the timed task; it can also realize the efficiency and flexibility of service calls based on the service scheduling strategy on the basis of the structure of the time wheel, and improve the service call performance of the distributed service system.
[0094] Embodiment 3
[0095] Figure 3 A schematic diagram of the structure of a service scheduling device provided in the third embodiment of the present invention. A service scheduling device provided in the embodiment of the present invention can be applied to the situation where the service scheduling performance of a distributed service scheduling system is insufficient and the scheduling efficiency of scheduled tasks is low. The service scheduling device can be implemented in the form of hardware and / or software, such as Figure 3 As shown, it specifically includes: a service type determination module 310, a candidate service provider determination module 320, a target service provider selection module 330 and a service call request sending module 340. Among them,
[0096] The service type determination module 310 is used to obtain the service call request sent by the service consumer, and perform request analysis on the service call request to determine the call service type.
[0097] The candidate service provider determination module 320 is used to determine at least one candidate service provider according to the calling service type.
[0098] The target service provider selection module 330 is used to obtain the current service scheduling policy and select a target service provider from the candidate service providers according to the current service scheduling policy.
[0099] The service call request sending module 340 is used to send the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, and generate and feedback the service call execution result.
[0100] This technical solution can determine candidate service providers based on the service call type of the acquired service call request, thereby improving the efficiency and response speed of the service call; further, it can also select the target service provider from the candidate service providers based on the current service scheduling strategy to execute the service call request, thereby achieving high efficiency and flexibility of the service call and improving the overall service call performance of the distributed service system.
[0101] Optionally, the device further includes:
[0102] The service policy adjustment module is used to obtain several service providers that register services in the service registration center in the current time period;
[0103] Determining the server performance corresponding to each of the service providers;
[0104] Determining whether to update the current service scheduling policy according to the performance of each server;
[0105] If so, the current service scheduling strategy is updated according to the performance of each server to obtain an updated current service scheduling strategy.
[0106] Optionally, the target service provider selection module 330 is specifically used to:
[0107] If the current service scheduling strategy is a consistent hash call strategy, determining the request key information of the service call request, and performing a hash calculation on the request key information to determine the request hash value;
[0108] Determine a target position of the request hash value of the service call request in the hash ring;
[0109] Determine a target service provider according to a target location of the service call request and based on reference locations corresponding to the candidate service providers in the hash ring;
[0110] The reference position of the candidate service provider in the hash ring is determined based on the reference hash value of the candidate service provider itself; and the reference hash value of the candidate service provider itself is determined based on its own identification information.
[0111] Optionally, the device further includes:
[0112] A scheduled task acquisition module, used for acquiring the service scheduled task and task execution information from the corresponding slot of the time wheel to which the service scheduled task belongs if the current time period meets the task start time of the service scheduled task of the service consumer;
[0113] Determine a task service provider according to the service timing task;
[0114] The service timing task and task execution information are sent to the task service provider, so that the task service provider can call the corresponding service, execute the service timing task based on the task execution information, and generate and feed back the task service execution result.
[0115] Optionally, the device further includes:
[0116] A time wheel construction module, used to obtain at least one scheduled task to be executed of at least one service consumer;
[0117] Determining the slot division method of the timing wheel according to the task time accuracy and task execution frequency of each of the scheduled tasks to be executed;
[0118] Divide the time wheel into slots based on the slot division method to obtain at least one slot;
[0119] According to the task execution time of each of the scheduled tasks to be executed, each of the scheduled tasks to be executed is added to a corresponding slot to realize the construction of the time wheel.
[0120] Optionally, the device further includes:
[0121] Monitoring module, used to monitor the service provider's service call success rate, service response time and scheduled task execution efficiency;
[0122] Determine whether to issue a service provider alarm based on the service call success rate, service response time and scheduled task execution efficiency;
[0123] If so, an alarm notification message is generated and sent to a corresponding service provider.
[0124] The service scheduling device provided in the embodiment of the present invention can execute the service scheduling method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0125] Embodiment 4
[0126] Figure 4A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0127] like Figure 4 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0128] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0129] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 41 executes the various methods and processes described above, such as a service scheduling method.
[0130] In some embodiments, the service scheduling method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the service scheduling method described above may be performed. Alternatively, in other embodiments, the processor 41 may be configured to perform the service scheduling method in any other appropriate manner (e.g., by means of firmware).
[0131] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0132] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0133] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0134] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0135] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0136] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0137] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0138] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A service scheduling method, characterized in that: include: Obtaining a service call request sent by a service consumer, and parsing the service call request to determine the type of service being called; Determining at least one candidate service provider according to the calling service type; Acquire a current service scheduling strategy, and select a target service provider from the candidate service providers according to the current service scheduling strategy; The service call request is sent to the target service provider, so that the target service provider calls the corresponding service to execute the service call request, and generates and feeds back the service call execution result.
2. The method according to claim 1, characterized in that The method further comprises: Get several service providers that have registered services in the service registration center in the current time period; Determining the server performance corresponding to each of the service providers; Determining whether to update the current service scheduling policy according to the performance of each server; If so, the current service scheduling strategy is updated according to the performance of each server to obtain an updated current service scheduling strategy.
3. The method according to claim 1, characterized in that If the current service scheduling strategy is a consistent hashing call strategy, then selecting a target service provider from each of the candidate service providers according to the current service scheduling strategy includes: Determine the request key information of the service call request, and perform hash calculation on the request key information to determine the request hash value; Determine a target position of the request hash value of the service call request in the hash ring; Determine a target service provider according to a target location of the service call request and based on reference locations corresponding to the candidate service providers in the hash ring; The reference position of the candidate service provider in the hash ring is determined based on the reference hash value of the candidate service provider itself; and the reference hash value of the candidate service provider itself is determined based on its own identification information.
4. The method according to claim 1, characterized in that The method further comprises: If the current time period meets the task start time of the service scheduled task of the service consumer, the service scheduled task and task execution information are obtained from the corresponding slot of the time wheel to which the service scheduled task belongs; Determine a task service provider according to the service timing task; The service timing task and task execution information are sent to the task service provider, so that the task service provider can call the corresponding service, execute the service timing task based on the task execution information, and generate and feedback the task service execution result.
5. The method according to claim 4, characterized in that The timing wheel is constructed as follows: Obtain at least one scheduled task to be executed of at least one service consumer; Determining the slot division method of the timing wheel according to the task time accuracy and task execution frequency of each of the scheduled tasks to be executed; Divide the time wheel into slots based on the slot division method to obtain at least one slot; According to the task execution time of each of the scheduled tasks to be executed, each of the scheduled tasks to be executed is added to a corresponding slot to realize the construction of the time wheel.
6. The method according to claim 1, characterized in that The method further comprises: Monitor the service provider's service call success rate, service response time, and scheduled task execution efficiency; Determine whether to issue a service provider alarm based on the service call success rate, service response time and scheduled task execution efficiency; If so, an alarm notification message is generated and sent to a corresponding service provider.
7. A service scheduling device, characterized in that: include: A service type determination module is used to obtain a service call request sent by a service consumer, and perform request parsing on the service call request to determine the call service type; A candidate service provider determination module, configured to determine at least one candidate service provider according to the calling service type; A target service provider selection module is used to obtain a current service scheduling strategy and select a target service provider from each of the candidate service providers according to the current service scheduling strategy; The service call request sending module is used to send the service call request to the target service provider so that the target service provider can call the corresponding service to execute the service call request, and generate and feedback the service call execution result.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the service scheduling method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the service scheduling method according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the service scheduling method according to any one of claims 1 to 6.