A method, device, equipment and medium for dynamic scheduling of microservices
By dynamically scheduling microservices, based on the call links and deployment information of the target service and server, cross-server call losses are reduced, solving the problems of performance loss and low scheduling efficiency in microservice scenarios, and achieving efficient service calling and scheduling.
Patent Information
- Application Number
- CN202310435332.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-21
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2043-04-21
AI Technical Summary
In microservice scenarios, cross-server calls will degrade server performance, and manual scheduling is time-consuming and labor-intensive, making efficient service scheduling impossible.
By determining the target service and target server corresponding to the microservice, obtaining the service deployment information of each target server, and dynamically scheduling services based on the call links and dependencies within a preset time, the service can be reduced in the number of servers spanned by the service call links.
It improves the service call performance in microservice scenarios and achieves efficient server resource utilization and service scheduling.
Smart Images

Figure CN116405543B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of network architecture technology, and in particular to a method, apparatus, device, and medium for dynamic scheduling of microservices. Background Art
[0002] Microservices is a cloud-native architectural approach in which a single application is composed of many loosely coupled, independently deployable services. As enterprises advance towards microservices, the scale of microservices continues to expand, and the call relationships between services become increasingly complex. From a deployment architecture perspective, whether using virtual machines or containers, services are often deployed across multiple servers.
[0003] Currently, the service call chain for each business request involves multiple services, which means that the service chain spans multiple servers. In order to fully utilize server resources, manual scheduling is used to determine which services to deploy on each server.
[0004] However, cross-server calls can suffer performance degradation due to network issues, resulting in delayed responses to service requests. Furthermore, manual scheduling is time-consuming and labor-intensive, making it difficult to efficiently schedule different services across servers. Summary of the Invention
[0005] Embodiments of the present invention provide a method, apparatus, device, and medium for dynamic scheduling of microservices to enable a service call link to span as few servers as possible, improve service call performance in microservice scenarios, and dynamically and efficiently schedule services deployed on servers.
[0006] In a first aspect, the present invention provides a method for dynamic scheduling of microservices, the method comprising:
[0007] Determine multiple target services corresponding to the microservice and target servers corresponding to the target services;
[0008] Obtaining service deployment information of each target server at the current moment, and obtaining multiple target categories corresponding to the multiple target services based on the current moment; wherein the target categories are determined based on call links between the multiple target services within a preset time period;
[0009] The microservice is dynamically scheduled based on the target category and the service deployment information.
[0010] In a second aspect, the present invention provides a device for dynamic scheduling of microservices, the device comprising:
[0011] A service determination module is used to determine multiple target services corresponding to a microservice and target servers corresponding to the target services;
[0012] A target category acquisition module, configured to acquire service deployment information of each target server at a current moment, and acquire multiple target categories corresponding to multiple target services based on the current moment;
[0013] A service dynamic scheduling module is used to dynamically schedule the microservice based on the target category and the service deployment information.
[0014] In a third aspect, the present invention provides an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by at least one processor. The computer program is executed by the at least one processor so that the at least one processor can perform the method for dynamic scheduling of microservices in any embodiment of the present invention.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer instructions, which are used to enable a processor to implement the method for dynamic scheduling of microservices of any embodiment of the present invention when executed.
[0019] The technical solution provided by the embodiment of the present invention determines multiple target services corresponding to a microservice and target servers corresponding to the target services, obtains the service deployment information of each target server at the current moment, and obtains multiple target categories corresponding to the multiple target services based on the current moment, wherein the target category is determined based on the call link between the multiple target services within a preset time period, thereby dynamically scheduling the microservice based on the target category and service deployment information. The embodiment of the present invention solves the problem of server performance loss caused by cross-server service calls in microservice scenarios. By comparing the target services included in the target category and the service deployment information corresponding to each current target server, the microservice is dynamically scheduled, achieving a service call link across as few servers as possible, improving the service call performance in the microservice scenario, and realizing dynamic and efficient service scheduling of each server.
[0020] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. 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.
[0022] Figure 1 A flowchart of a method for dynamic scheduling of microservices provided in Example 1 of the present invention;
[0023] Figure 2 This is a schematic diagram of the target service and target server involved in the first embodiment of the present invention;
[0024] Figure 3 This is a schematic diagram of dynamic scheduling of microservices involved in the first embodiment of the present invention;
[0025] Figure 4 A flowchart of a method for dynamic scheduling of microservices provided in the second embodiment of the present invention;
[0026] Figure 5 This is a flowchart of a method for dynamic scheduling of microservices provided in Example 3 of the present invention;
[0027] Figure 6 A schematic diagram of a service consumer and a service caller corresponding to the service consumer involved in the third embodiment of the present invention;
[0028] Figure 7 A schematic diagram of the structure of a device for dynamic scheduling of microservices provided in the fourth embodiment of the present invention;
[0029] Figure 8 This is a structural diagram of an electronic device provided in Example 5 of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions 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 embodiments described 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 making creative efforts should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first precondition," "second precondition," and the like 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 precedence. It should be understood that the terms used in this manner are interchangeable 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," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units that are not explicitly listed or that are inherent to these processes, methods, products, or apparatuses.
[0032] Before introducing this technical solution, we can first provide an example application scenario. As enterprises gradually deepen their microservices, the scale of microservices continues to expand, and the calling relationships between services are becoming increasingly complex. From a deployment architecture perspective, whether it is a virtual machine or containerized deployment model, services are mostly deployed on multiple servers to achieve various requirements such as resource isolation, high availability, and ease of management. In actual application, the service call chain for each business request will involve multiple services, resulting in the service chain spanning multiple servers. Cross-server calls will lose certain performance due to network and other reasons. If as many calls between services as possible can be made between the same server, so that a service call link spans as few servers as possible, the service call performance can be improved to a certain extent. Based on this, the technical solution provided by the embodiment of the present invention can determine multiple target services in the current microservice scenario and the target servers corresponding to the target services during the operation of the microservice, and then obtain the service deployment information of each target server at the current moment, and obtain multiple target categories corresponding to the multiple target services at the current moment, so as to dynamically schedule the microservice based on the target category and service deployment information, so as to realize a service call link spanning as few servers as possible, improve the service call performance in the microservice scenario, and realize dynamic and efficient service scheduling of each server.
[0033] Example 1
[0034] Figure 1 This is a flowchart of a method for dynamic scheduling of microservices provided in the first embodiment of the present invention. This embodiment is applicable to the situation of dynamically and efficiently scheduling services for servers in microservice scenarios. The method can be executed by a device for dynamic scheduling of microservices, which can be implemented in the form of hardware and / or software. The device can be configured on a computer device, which can be a notebook, desktop computer, smart tablet, etc. Figure 1 As shown, the method includes:
[0035] S110: Determine multiple target services corresponding to the microservice and target servers corresponding to the target services.
[0036] Microservices (or microservices architecture) is a cloud-native architectural approach in which a single application is composed of many loosely coupled, independently deployable services. Target services are all services included in the current microservices scenario, and there are multiple target services. Target servers are the data processing devices that host target services, and there are multiple target servers. Scheduling determines which target service type is deployed on which target server. Therefore, there is no one-to-one correspondence between multiple target services and multiple target servers.
[0037] Specifically, in a specific microservice application scenario, all target services included in the current microservice scenario are determined, and the target servers used to host each target service are also determined. Based on this, multiple target services in the current microservice scenario and the target servers corresponding to the target services can be directly obtained.
[0038] For example, the target service and target server diagram are shown in Figure 2 ,like Figure 2 The microservices scenario shown includes four target services: target service A, target service B, target service C, and target service D. Two target servers are configured in the microservices scenario to host the target services: target server 1 and target server 2.
[0039] S120: Obtain service deployment information of each target server at the current moment, and obtain multiple target categories corresponding to multiple target services based on the current moment.
[0040] The service deployment information can be understood as which target services are deployed on each target server at the current moment. Figure 2 As shown, target service A and target service B are deployed on target server 1, and target service C and target service D are deployed on target server 2.
[0041] Among them, the target category is determined based on the call link between multiple target services within a preset duration. The preset duration is a pre-set length of time, for example, the preset duration is 24 hours. In the process of the system completing a business request task, the call information (time, interface, level, result) between the services is marked in the log, and then all the marked data are connected into a tree chain to generate a call link. In this embodiment, the call relationship between each target service can be determined based on the call link. By counting the number of calls in the call link, it is possible to further determine which services have frequent call relationships, and then the services with frequent call relationships can be classified into the same target category. In actual applications, the target category can be determined every preset duration.
[0042] Specifically, the service deployment information corresponding to each target server at the current moment can be directly obtained through log data. At the current moment, the multiple target categories corresponding to the multiple target services are pre-determined and can be directly obtained.
[0043] For example, during the specific execution process, the service deployment information corresponding to each target server at the current moment is first obtained to determine the target services currently deployed on each target server. At the same time, multiple target categories corresponding to multiple target services within a preset time corresponding to the current moment are obtained. For example, if the current moment is 6:00 AM on January 2nd, the target categories obtained are the multiple target categories determined based on the call links between 6:00 AM on January 1st and 6:00 AM on January 2nd.
[0044] In another embodiment, assuming the initial time is 6:00 a.m. and the preset duration is 24 hours, the target category can be determined at 6:00 a.m. every day based on the call links between multiple target services within 24 hours. The current target category is determined based on the call links between multiple target services between 6:00 a.m. on January 1 and 6:00 a.m. on January 2. During the time period between 6:00 a.m. on January 2 and 6:00 a.m. on January 3, the multiple target categories corresponding to the multiple target services obtained at the current time are all the current target categories.
[0045] S130: Dynamically schedule microservices based on target categories and service deployment information.
[0046] Specifically, after determining the target category and service deployment information, it can be further determined whether the microservice needs to be scheduled based on the target services included in each target category and the service deployment information corresponding to each target server.
[0047] Optionally, dynamic scheduling of microservices may specifically include: when the target service included in the target category is consistent with the service deployment information, after a preset time interval, returning to execute the step of determining multiple target services corresponding to the microservice and the target server corresponding to the target service; when the target service included in the target category is inconsistent with the service deployment information, adjusting the current service deployed in each target server based on the target service included in each target category.
[0048] In this embodiment, two situations can be obtained by comparing the target services included in each target category and the service deployment information corresponding to each target server. The first is that the target services included in the target category are consistent with the service deployment information, and the other is that the target services included in the target category are inconsistent with the service deployment information. In the first case, it indicates that there is no need to perform service scheduling, and within the next preset time, the business request task can still be executed with the service deployment information of the current target server, until the preset time is reached and the step of determining the multiple target services corresponding to the microservice and the target servers corresponding to the target services is returned. In the second case, the target services that need to be deployed in each target server are scheduled according to the target services included in each target category, so that the target services in the current target server are consistent with the target services included in the target category.
[0049] For an example, see the microservice dynamic scheduling diagram. Figure 3 .like Figure 3 As shown, there are two target categories: Target Category 1 and Target Category 2. Target Services A, B, and C belong to Target Category 1, while Target Services D and E belong to Target Category 2. Target Server 1 currently deploys Target Services A, B, and D, while Target Server 2 currently deploys Target Services C and E. In this case, dynamic scheduling is required. Target Service C deployed on Target Server 2 can be scheduled to Target Server 1, and Target Service D deployed on Target Server 1 can be scheduled to Target Server 2.
[0050] The technical solution provided by the embodiment of the present invention determines multiple target services corresponding to a microservice and target servers corresponding to the target services, obtains the service deployment information of each target server at the current moment, and obtains multiple target categories corresponding to the multiple target services based on the current moment, wherein the target category is determined based on the call link between the multiple target services within a preset time period, thereby dynamically scheduling the microservice based on the target category and service deployment information. The embodiment of the present invention solves the problem of server performance loss caused by cross-server service calls in microservice scenarios. By comparing the target services included in the target category and the service deployment information corresponding to each current target server, the microservice is dynamically scheduled, achieving a service call link across as few servers as possible, improving the service call performance in the microservice scenario, and realizing dynamic and efficient service scheduling of each server.
[0051] Example 2
[0052] Figure 4 This is a flowchart of a method for dynamic scheduling of microservices provided in the second embodiment of the present invention. Based on the above embodiment, the embodiment of the present invention describes in detail how the embodiment of the present invention determines multiple target categories corresponding to multiple target services. The embodiment of the present invention can be combined with various optional solutions in one or more of the above embodiments. Figure 4 As shown, the method includes:
[0053] S210: Determine multiple target services corresponding to the microservice and target servers corresponding to the target services.
[0054] S220: Obtain service deployment information of each target server at the current moment.
[0055] S230: Determine the call links between multiple target services within a preset duration corresponding to the current moment.
[0056] The preset duration corresponding to the current time can be specifically understood as the period between the current time as the end point and the preset duration before the current time as the start point. For example, if the current time is 6:00 AM on January 2nd and the preset duration is 24 hours, then the preset duration corresponding to the current time is the 24 hours between 6:00 AM on January 1st and 6:00 AM on January 2nd.
[0057] In this embodiment, the call links between multiple target services within a preset duration corresponding to the current moment must first be determined. The call links between multiple target services can be obtained using a target toolkit. For example, a toolkit consisting of Sleuth and Zipkin components can be used to obtain the call links between multiple target services, or the Skywalking toolkit can be used to obtain the call links between multiple target services.
[0058] Based on the above example, if the current time is 6:00 a.m. on January 2, you can use a toolkit consisting of Sleuth and Zipkin components or the Skywalking tool to obtain the call links between multiple target services between 6:00 a.m. on January 1 and 6:00 a.m. on January 2.
[0059] S240: Determine the dependency weight between every two target services based on the call link, and divide the multiple target services into multiple target categories based on the dependency weights.
[0060] The dependency weight is used to characterize the degree of dependency between each two target services. The larger the dependency weight value is, the greater the degree of dependency is.
[0061] In this embodiment, based on the call link, the number of calls between each two target services can be counted, and the dependency weight between each two target services can be determined based on the number of calls. The multiple target services can then be divided into multiple target categories based on the numerical values of the dependency weights.
[0062] Optionally, determining the dependency weight between each two target services based on the call link may specifically include: determining the number of calls between each two target services in the call link; determining the dependency weight between each two target services based on the number of calls and the correspondence between the pre-set number of calls and the dependency weight.
[0063] In this embodiment, in the process of determining the call link through the target toolkit, the number of calls per minute between any two services can be queried. For example, Skywalking's graphql interface can query the number of calls per minute between any two services. Furthermore, by counting the number of calls per minute between any two services, the number of calls of the two services within a preset time length can be calculated. A correspondence table between the number of calls and the dependency weight can be established in advance. The more calls, the greater the dependency weight value, and vice versa. On the basis of obtaining the number of calls between each two target services, according to the number of calls and the correspondence table, the dependency weight corresponding to the number of calls is queried, thereby determining the dependency weight between each two target services.
[0064] Optionally, multiple target services are divided into multiple target categories based on the weights of each dependency relationship, which may specifically include: determining the number of target servers corresponding to the multiple target services, and determining the number of categories based on the number of servers; using a preset clustering algorithm to divide the multiple target services into multiple target categories based on the weights of each dependency relationship and the number of categories.
[0065] The number of categories is the number of target categories into which the plurality of dependency weight values are divided. The preset clustering algorithm is a pre-set clustering algorithm, for example, the clustering algorithm may be a K-means clustering algorithm.
[0066] In this embodiment, the number of target servers corresponding to the multiple target services can be used as the number of categories. A preset clustering algorithm is used to cluster the dependency weight relationships, and the dependency weights are divided into different groups of the same number of categories, so that the multiple target services can be divided into multiple target categories.
[0067] Exemplarily, the target services include target service A, target service B, target service C, and target service D, and the dependency weights between each two target services are shown in the following table. Assuming that the number of target servers corresponding to multiple target services is 2, S1, S2, S3, S4, S5, and S6 can be clustered into 2 groups, the first group including S2, S3, and S6, and the second group including S1, S4, and S5. Since the number of target servers is 2, the number of target categories is 2, namely target category 1 and target category 2. Target category 1 contains target service A, target service C, and target service D, and target category 2 contains target service A, target service B, target service C, and target service D.
[0068] Table 1 Dependency weights between each two target services
[0069] A and B S1 A and C S2 A and D S3 B and C S4 B and D S5 C and D S6
[0070] S250: Dynamically schedule microservices based on target categories and service deployment information.
[0071] The technical solution provided by the embodiment of the present invention, when determining multiple target categories corresponding to multiple target services, first determines the call links between the multiple target services within a preset time period corresponding to the current moment, and then determines the dependency weights between every two target services based on the call links, and divides the multiple target services into multiple target categories based on the dependency weights. This allows target services with strong dependencies to be divided into one target category. When microservices are dynamically scheduled based on the target categories and service deployment information, a service call link spans as few servers as possible, further improving the service call performance in the microservice scenario.
[0072] Example 3
[0073] Figure 5This is a flowchart of a method for dynamic scheduling of microservices provided in the third embodiment of the present invention. Based on the above embodiments, if there is at least one backup service for the target service, the call priority between target services with a call relationship can be determined based on the target service and the target server corresponding to the backup service. This embodiment of the present invention can be combined with various optional solutions in one or more of the above embodiments. Figure 5 As shown, the method includes:
[0074] S310: Determine multiple target services corresponding to the microservice and target servers corresponding to the target services;
[0075] S320: Obtain service deployment information of each target server at the current moment, and obtain multiple target categories corresponding to multiple target services based on the current moment.
[0076] S330: Dynamically schedule microservices based on target categories and service deployment information.
[0077] S340: Determine service consumers in multiple target services and service callers corresponding to the service consumers.
[0078] In this embodiment, if a target service has at least one backup service, the call priority between target services that have a call relationship can be determined based on the target service and the target server corresponding to the backup service. If the backup service and the target service execute exactly the same content, the backup service can be considered a replica of the target service.
[0079] In this embodiment, the service consumer and the service caller corresponding to the service consumer are shown in FIG. Figure 6 ,like Figure 6 As shown, target service A2 is the backup service for target service A1, and target service B2 is the backup service for target service B1. Target service A and target service B have a call relationship. When executing a business request task, target service A is the service consumer, and target service B is the service caller corresponding to target service A. Service callers include the target service with which the service consumer has a call relationship and the backup service corresponding to the target service. Specifically, the service callers corresponding to target service A, the service consumer, are target service B1 and target service B2.
[0080] S350: For each service consumer, determine the call weight corresponding to the service caller according to the target server corresponding to the service consumer and the target server corresponding to the service caller.
[0081] Among them, the call weight is used to represent the priority of the target service in the service caller and each backup service when calling the service consumer. The larger the call weight, the higher the priority of the call.
[0082] In this embodiment, for each service consumer, the method of determining the call weight corresponding to the service caller is the same, and one of the service consumers is taken as an example for explanation.
[0083] Optionally, determining the call weight corresponding to the service caller may specifically include: when the target server corresponding to the service caller is the same as the target server corresponding to the service consumer, determining the call weight corresponding to the service caller as the first weight; when the target server corresponding to the service caller is different from the target server corresponding to the service consumer, determining the call weight corresponding to the service caller as the second weight; wherein the first weight is greater than the second weight.
[0084] Based on the above examples, Figure 6 As shown in the figure, if target service A1 is a service consumer, the service callers corresponding to target service A1 include target service B1 and target service B2. Since the target server corresponding to target service A1 is the same as the target server corresponding to target service B1, the call weight corresponding to target service B1 is the first weight, for example, the first weight is 0.8; the target server corresponding to target service A1 is different from the target server corresponding to target service B2, so the call weight corresponding to target service B2 is the second weight, for example, the first weight is 0.3.
[0085] S360: Determine a target service caller corresponding to the service consumer based on the call weight.
[0086] The target service caller is the service caller that is finally determined to have a calling relationship with the service consumer.
[0087] In this embodiment, the call weight serves as an important reference when determining the target service caller corresponding to the service consumer. Furthermore, the server configuration information of the target server corresponding to the service consumer and the target server corresponding to each service caller must also be considered. The server configuration information includes at least one of the following: network connection status, the server's physical location, and operating device parameters. Finally, the call weight and server configuration information are used together to determine the target service caller corresponding to the service consumer.
[0088] The technical solution provided by the embodiment of the present invention, after dynamically scheduling microservices based on target categories and service deployment information, if there is at least one backup service for the target service, can determine the service consumers and service callers corresponding to the service consumers in multiple target services during the specific execution process. For each service consumer, the call weight corresponding to the service caller is determined based on the target server corresponding to the service consumer and the target server corresponding to the service caller, and thus the target service caller corresponding to the service consumer is determined based on the call weight, which embodies the service call mechanism of the proximity strategy and further improves the service call performance in the microservice scenario.
[0089] Example 4
[0090] Figure 7 This is a schematic diagram of the structure of a device for dynamic microservice scheduling provided in the fourth embodiment of the present invention. The device can execute the method for dynamic microservice scheduling provided in the embodiment of the present invention. The device includes: a service determination module 410, a target category acquisition module 420, and a service dynamic scheduling module 430.
[0091] A service determination module 410 is configured to determine a plurality of target services corresponding to a microservice and target servers corresponding to the target services;
[0092] The target category acquisition module 420 is configured to acquire service deployment information of each target server at a current moment, and acquire multiple target categories corresponding to multiple target services based on the current moment;
[0093] The service dynamic scheduling module 430 is used to dynamically schedule the microservice based on the target category and the service deployment information.
[0094] On the basis of the above technical solutions, the service dynamic scheduling module 430 is also used to, when the target service included in the target category is consistent with the service deployment information, return to the step of determining multiple target services corresponding to the microservice and the target server corresponding to the target service after the preset time interval; when the target service included in the target category is inconsistent with the service deployment information, adjust the current service deployed in each target server based on the target service included in each target category.
[0095] Based on the above technical solutions, the device for dynamic microservice scheduling also includes a target category determination module, which includes:
[0096] A call link determination submodule, configured to determine a call link between a plurality of target services within a preset duration corresponding to the current moment;
[0097] The target category determination submodule is configured to determine a dependency weight between each two target services based on the call link, and to divide the target services into a plurality of target categories based on the dependency weights.
[0098] On the basis of the above technical solutions, the target category determination submodule further includes a call count determination unit and a dependency weight determination unit.
[0099] A call count determination unit, configured to determine the call count between each two target services in the call link;
[0100] The dependency weight determining unit is configured to determine the dependency weight between each two target services based on the number of calls and a predetermined correspondence between the number of calls and the dependency weight.
[0101] On the basis of the above technical solutions, the target category determination submodule further includes a category quantity determination unit and a target category determination unit.
[0102] a category quantity determining unit, configured to determine the server quantity of the target servers corresponding to the plurality of target services, and determine the category quantity based on the server quantity;
[0103] The target category determination unit is configured to divide the plurality of target services into a plurality of target categories based on the dependency weights and the number of categories by using a preset clustering algorithm.
[0104] On the basis of the above technical solutions, the device for dynamic scheduling of microservices further includes a target caller determination module, which includes:
[0105] A caller determination unit, configured to determine a service consumer among multiple target services and a service caller corresponding to the service consumer, wherein the service caller includes a target service having a call relationship with the service consumer and a backup service corresponding to the target service;
[0106] A call weight determination unit, configured to determine, for each of the service consumers, a call weight corresponding to the service caller according to a target server corresponding to the service consumer and a target server corresponding to the service caller;
[0107] The target caller determining unit is configured to determine a target service caller corresponding to the service consumer based on the call weight.
[0108] Based on the above technical solutions, calling the weight determination unit includes:
[0109] A first weight determination subunit is configured to determine the call weight corresponding to the service caller as a first weight when the target server corresponding to the service caller is the same as the target server corresponding to the service consumer;
[0110] The second unit determines a subunit, which is used to determine the call weight corresponding to the service caller as a second weight when the target server corresponding to the service caller is different from the target server corresponding to the service consumer; wherein the first weight is greater than the second weight.
[0111] The technical solution provided by the embodiment of the present invention determines multiple target services corresponding to a microservice and target servers corresponding to the target services, obtains the service deployment information of each target server at the current moment, and obtains multiple target categories corresponding to the multiple target services based on the current moment, wherein the target category is determined based on the call link between the multiple target services within a preset time period, thereby dynamically scheduling the microservice based on the target category and service deployment information. The embodiment of the present invention solves the problem of server performance loss caused by cross-server service calls in microservice scenarios. By comparing the target services included in the target category and the service deployment information corresponding to each current target server, the microservice is dynamically scheduled, achieving a service call link across as few servers as possible, improving the service call performance in the microservice scenario, and realizing dynamic and efficient service scheduling of each server.
[0112] The device for dynamic scheduling of microservices provided in the embodiments of the present disclosure can execute the method for dynamic scheduling of microservices provided in any embodiment of the present disclosure, and has functional modules and beneficial effects corresponding to the execution method.
[0113] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0114] Example 5
[0115] Figure 8A structural diagram of an electronic device provided for embodiment five of the present invention. The electronic device 10 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 may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable electronic 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.
[0116] like Figure 8 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 13. An input / output (I / O) interface 15 is also connected to the bus 13.
[0117] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other electronic devices via a computer network such as the Internet and / or various telecommunication networks.
[0118] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the method for dynamic scheduling of microservices.
[0119] In some embodiments, the method for dynamic scheduling of microservices can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the method for dynamic scheduling of microservices described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the method for dynamic scheduling of microservices in any other appropriate manner (e.g., by means of firmware).
[0120] Various embodiments of the systems and techniques described 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), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes 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.
[0121] Computer programs for implementing the methods of the present invention can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable microservices dynamically scheduled device, so that when executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer programs can be executed entirely on the machine, partially on the machine, as a standalone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0122] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use by an instruction execution system, device or electronic device or used in combination with an instruction execution system, device or electronic device. Computer-readable storage media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or electronic devices, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage electronic devices, magnetic storage electronic devices, or any suitable combination of the foregoing.
[0123] To provide interaction with a user, the systems and techniques described herein can 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 pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0124] The systems and techniques described herein can be implemented in a computing system that includes back-end 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 front-end components (e.g., a user computer with a graphical user interface or 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 back-end components, middleware components, or front-end components. The components of the system can 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.
[0125] A computing system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. The client-server relationship is established by computer programs running on the respective computers and establishing a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within a cloud computing service system that addresses the management difficulties and poor scalability of traditional physical hosts and virtual private server (VPS) services. It should be understood that the various forms of the processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the present disclosure are achieved. This is not intended to limit the scope of protection of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure are intended to be included within the scope of protection of this disclosure.
Claims
1. A method for dynamic scheduling of microservices, characterized in that: include: Determine multiple target services corresponding to the microservice and target servers corresponding to the target services; Obtaining service deployment information of each target server at the current moment, and obtaining multiple target categories corresponding to the multiple target services based on the current moment; wherein the target categories are determined based on call links between the multiple target services within a preset time period; Dynamically scheduling the microservice based on the target category and the service deployment information; If the target service has at least one backup service, the method further includes: Determining a plurality of service consumers and service callers corresponding to the service consumers in the target services, wherein the service callers include a target service having a calling relationship with the service consumer and a backup service corresponding to the target service; For each of the service consumers, when the target server corresponding to the service caller is the same as the target server corresponding to the service consumer, determining the call weight corresponding to the service caller as the first weight; In a case where the target server corresponding to the service caller is different from the target server corresponding to the service consumer, determining the call weight corresponding to the service caller as the second weight; The call weight is used to represent the priority of the target service in the service caller and each backup service when calling the service consumer, and the first weight is greater than the second weight; Based on the call weight, a target service caller corresponding to the service consumer is determined.
2. The method according to claim 1, characterized in that Before acquiring a plurality of target categories corresponding to a plurality of target services based on the current moment, the method further includes: Determining call links between a plurality of the target services within a preset time period corresponding to the current moment; A dependency weight between every two target services is determined based on the call link, and a plurality of target services are divided into a plurality of target categories based on the dependency weights.
3. The method according to claim 2, characterized in that The determining the dependency weight between each two target services based on the call link includes: Determine the number of calls between each two target services in the call link; Based on the number of calls and the predetermined correspondence between the number of calls and the dependency weight, the dependency weight between each two target services is determined.
4. The method according to claim 2, characterized in that The dividing the plurality of target services into a plurality of target categories based on the dependency weights includes: determining the number of target servers corresponding to the plurality of target services, and determining the number of categories based on the number of servers; A preset clustering algorithm is used to divide the plurality of target services into a plurality of target categories based on the dependency weights and the number of categories.
5. The method according to claim 1, wherein The dynamically scheduling the microservice based on the target category and the service deployment information includes: When the target service included in the target category is consistent with the service deployment information, after the preset time interval, returning to the step of determining multiple target services corresponding to the microservice and target servers corresponding to the target services; In a case where the target services included in the target categories are inconsistent with the service deployment information, the current services deployed in each target server are adjusted based on the target services included in each target category.
6. A device for dynamic scheduling of microservices, characterized in that: include: A service determination module is used to determine multiple target services corresponding to a microservice and target servers corresponding to the target services; A target category acquisition module, configured to acquire service deployment information of each target server at a current moment, and acquire multiple target categories corresponding to multiple target services based on the current moment; A service dynamic scheduling module, configured to dynamically schedule the microservice based on the target category and the service deployment information; The device further includes a target caller determination module, and the target caller determination module includes: a caller determination unit, configured to determine, if the target service has at least one backup service, a plurality of service consumers in the target services and service callers corresponding to the service consumers, wherein the service callers include the target service having a calling relationship with the service consumer and the backup service corresponding to the target service; The target caller determination module further includes a call weight determination unit, and the call weight determination unit includes: A first weight determination subunit is configured to, for each of the service consumers, determine, when the target server corresponding to the service caller is the same as the target server corresponding to the service consumer, a call weight corresponding to the service caller as a first weight; A second weight determination subunit is configured to determine the call weight corresponding to the service caller as a second weight when the target server corresponding to the service caller is different from the target server corresponding to the service consumer; The call weight is used to represent the priority of the target service in the service caller and each backup service when calling the service consumer, and the first weight is greater than the second weight; The target caller determination module further includes a target caller determination unit, which is configured to determine a target service caller corresponding to the service consumer based on the call weight.
7. 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 that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the method for dynamic scheduling of microservices according to any one of claims 1 to 5.
8. 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 method for dynamic scheduling of microservices according to any one of claims 1 to 5 when executed.
Citation Information
Patent Citations
Distributed micro-service scheduling optimization method
CN115714820A
Micro-service distribution method, electronic equipment and storage medium
CN115834689A