Disclosure of Invention
In view of this, the present application provides a method, apparatus, device and storage medium for scheduling micro services, which are used to solve the problem that the service condition of resources will change, and if the service value of each micro service, such as cpu, memory value, etc., is unreasonable, the resource utilization rate of the whole cluster will be affected, which is not beneficial to the whole operation of the service cluster.
In order to achieve the above object, the following schemes are proposed:
in a first aspect, a method for scheduling micro services includes:
responding to a request instruction for scheduling each micro-service in a service cluster, and selecting a target computing node from each computing node in the service cluster;
deploying a target controller acquired in advance on the target computing node to obtain an independent computing node;
transmitting each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service;
and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service.
Preferably, the process of determining the category of each micro service by the independent computing node includes:
determining call information between every two micro services, and combining the call information into a call information set;
performing dimension reduction on the call information set to obtain a two-dimensional data set corresponding to the call relation set;
and clustering the two-dimensional data sets to obtain the category of each micro service.
Preferably, the process of determining the first service value of each micro service by the independent computing node includes:
for each micro-service, acquiring each processor value corresponding to the micro-service in a first preset time period;
taking the average value of each processor value as the minimum value of the processor corresponding to the micro service;
the processor minimum value is taken as a first service value of the micro service.
Preferably, the process of determining the second service value of each micro service by the independent computing node includes:
for each micro-service, acquiring each memory value corresponding to the micro-service in a first preset time period;
taking the average value of each memory value as the minimum memory value corresponding to the micro service;
and taking the memory minimum value as a second service value of the micro service.
Preferably, the sending each micro service to each computing node except the independent computing node based on the category of each micro service, the first service value and the second service value includes:
for each category, taking each micro service with the same category as each soft affinity service corresponding to the category;
combining each soft parent service corresponding to the category into a micro service group corresponding to the category;
determining a response node corresponding to the micro service group from each computing node except the independent computing node based on the first service value and the second service value of each soft affinity service in the micro service group;
and sending the micro service group to the response node.
Preferably, the determining the call information between every two micro services and combining the call information into a call information set includes:
judging whether a first service corresponding to each micro service exists in the independent computing node or not according to each micro service;
if a first service corresponding to the micro service exists in the independent computing node, acquiring first calling information of the first service;
determining the calling relationship between the micro service and other micro services based on the first calling information;
and integrating the calling relationship between each micro service and other micro services to obtain the calling information set.
Preferably, the target controller is a MutatingAdmission webhooks admission controller.
In a second aspect, a micro-service scheduling apparatus includes:
the target computing node selection module is used for responding to a request instruction for scheduling each micro service in the service cluster and selecting a target computing node from all computing nodes in the service cluster;
the deployment module is used for deploying the target controller acquired in advance on the target computing node to obtain an independent computing node;
the parameter determining module is used for sending each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service;
and the sending module is used for sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service.
In a third aspect, a micro-service scheduling apparatus includes a memory and a processor;
the memory is used for storing programs;
the processor is configured to execute the program to implement the steps of the micro service scheduling method according to the first aspect.
In a fourth aspect, a storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of the micro-service scheduling method according to the first aspect.
From the above technical solution, it can be seen that the present application selects a target computing node from the computing nodes in a service cluster by responding to a request instruction for scheduling each micro-service in the service cluster; deploying a target controller acquired in advance on the target computing node to obtain an independent computing node; transmitting each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service; and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service. According to the scheme, the target controller is deployed on the target computing node to obtain an independent computing node, all the micro services are sent to the independent computing node to obtain parameters of each micro service, including a category, a first service value and a second service value, and each micro service is scheduled according to the parameters, so that a scheduling result can be optimized, and efficient operation of a service cluster is ensured.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In a cloud native environment in the technical field of micro-service scheduling, thousands of micro-services can appear in one service cluster, so that the calling relationship of each micro-service needs to be managed and stored, and during service deployment, operation and maintenance personnel can correspondingly schedule each micro-service according to the estimated resource use condition of different micro-services.
However, the use condition of the resources will change, if the service values of each micro service, such as cpu, memory value, etc., are unreasonable, such as too large cpu, memory value, etc., the resource utilization rate of the whole cluster will be affected, or too small setting will affect the service stability, which is not beneficial to the whole operation of the service cluster.
In order to solve the above-mentioned drawbacks, an embodiment of the present application provides a method for scheduling micro services, which may be applied to various computer terminals or intelligent terminals, and the execution subject of the method may be a processor or a server of the computer terminal or the intelligent terminal, and a flowchart of the method is shown in fig. 1, and specifically includes:
s1: in response to a request instruction to schedule individual micro-services in a service cluster, a target computing node is selected from among the computing nodes in the service cluster.
In particular, the k8s cluster may be used as a service cluster in the present application, where the service cluster includes a plurality of computing nodes, and the computing nodes may be understood as servers, and each computing node is an independent server. When each micro service needs to be updated, responding to a request instruction for scheduling each micro service in a service cluster, and selecting one computing node from all computing nodes in the service cluster as a target computing node.
The selection method may be a random selection or a selection based on the characteristics of the service cluster, which is not limited in this embodiment.
S2: and deploying the target controller acquired in advance on the target computing node to obtain an independent computing node.
In order not to affect the online service, a pre-selected target controller can be deployed on the target computing node, so that an independent computing node is obtained, and the target controller can be deployed on the target computing node in a containerized manner.
S3: and sending each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service.
Optionally, before sending each micro-service to the independent computing node, the majorization tag of each micro-service is obtained first, and whether the majorization tag of each micro-service is false or true is determined, which is understood that the majorization tag of each micro-service is preset to indicate whether each micro-service is to be adaptively optimized. For each micro-service, if the localization tag of the micro-service is false, the micro-service does not need to be sent to an independent computing node; if the micro-service gets a mapping tag to true, the micro-service needs to be sent to an independent compute node.
And after determining each micro-service needing to be adaptively optimized, transmitting each micro-service to an independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service.
S4: and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service.
Then, according to the obtained category, the first service value and the second service value of each micro service, how to schedule each micro service can be determined, so that the operation and maintenance cost of the service cluster is reduced. Alternatively, this step may be implemented using kube-apiserver (micro-service response component).
In the method provided by the embodiment of the application, the process of determining the category of each micro service by the independent computing node is specifically described as follows:
s31: call information between every two micro services is determined and combined into a call information set.
Specifically, the step may include:
judging whether a first service corresponding to each micro service exists in the independent computing node or not according to each micro service; if a first service corresponding to the micro service exists in the independent computing node, acquiring first calling information of the first service; determining the calling relationship between the micro service and other micro services based on the first calling information; and integrating the calling relationship between each micro service and other micro services to obtain the calling information set.
The first service may be understood as a service of the same type as the micro service, if a first service of the same type as the micro service exists in an independent computing node, trace and span data may be extracted from an iso component dapper by using a DataStore micro service governance capability of an iso to obtain first call information of the first service, and then a mutual call relationship between the micro service and other micro services is determined according to the first call information. If the micro service A and the micro service B have a calling relation, the calling information between the micro service A and the micro service B is expressed as 1, and if the micro service A and the micro service B have no calling relation, the calling information between the micro service A and the micro service B is expressed as 0. In addition, the call information between the micro services themselves is 1, and in one example, there are A, B, C, D four micro services, and the call information set between the four micro services can be as shown in table 1 below:
TABLE 1
Service
|
A
|
B
|
C
|
D
|
A
|
1
|
0
|
1
|
0
|
B
|
1
|
1
|
0
|
1
|
C
|
0
|
1
|
1
|
0
|
D
|
1
|
0
|
0
|
1 |
S32: and reducing the dimension of the call information set to obtain a two-dimensional data set corresponding to the call relation set.
In this step, the calling information set in table 1 is used, PAC dimension reduction is performed on the calling information set, so as to obtain a two-dimensional data set corresponding to the calling information set, as shown in the following table 2:
TABLE 2
|
A
|
B
|
C
|
D
|
X
|
Xa
|
Xb
|
Cx
|
Dx
|
Y
|
Ya
|
Yb
|
Cy
|
Dy |
S33: and clustering the two-dimensional data sets to obtain the category of each micro service.
Specifically, the two-dimensional data set in the above table 2 is used, and the two-dimensional data set is adaptively clustered by DBSCAN clustering, so that the category of each micro service can be obtained, which is specifically shown in the following table 3:
TABLE 3 Table 3
|
A
|
B
|
C
|
D
|
Category(s)
|
Label1
|
Label2
|
Label2
|
Label1 |
As can be seen from table 3 above, the categories of the micro service a and the micro service D are the same, and are Label1; the class of micro service B and micro service C is the same, label2.
The above embodiments describe the process of determining the class of each micro service by the independent computing node in the present application, and the following describes the process of determining the first service value and the second service value of each micro service by the independent computing node in the present application in detail.
First service value: for each micro-service, acquiring each processor value corresponding to the micro-service in a first preset time period; taking the average value of each processor value as the minimum value of the processor corresponding to the micro service; the processor minimum value is taken as a first service value of the micro service.
Second service value: for each micro-service, acquiring each memory value corresponding to the micro-service in a first preset time period; taking the average value of each memory value as the minimum memory value corresponding to the micro service; and taking the memory minimum value as a second service value of the micro service.
Alternatively, the target controller may obtain the respective processor value (CPU value) and the respective memory value in the first preset time period through promethaus, where the first preset time period may be 7 days, and then the respective CPU value and the respective memory value in 7 days, that is, the CPU value and the memory value in each day in the 7 days. After the respective average value is calculated, the average value is used as the minimum value of the micro-service, namely the requests value, so that the use of resources is optimized.
The following describes in detail a procedure of transmitting each micro service to each computing node except the independent computing node based on the class, the first service value, and the second service value of each micro service in the present application.
For each category, taking each micro service with the same category as each soft affinity service corresponding to the category; combining each soft parent service corresponding to the category into a micro service group corresponding to the category; determining a response node corresponding to the micro service group from each computing node except the independent computing node based on the first service value and the second service value of each soft affinity service in the micro service group; and sending the micro service group to the response node.
Specifically, in order to improve the efficiency of mutual access between micro services, an operator may set affinities for micro services having a high call relationship or belonging to the same category, and the affinity settings between micro services are more complex than the resource settings. When the micro-services are online, operation and maintenance personnel set corresponding pod affinities (soft and hard), pod anti-affinities (soft and hard), node anti-affinities (soft and hard) and the like according to the calling relations among the micro-services, wherein the calling relations of the computing nodes are not changed generally, and the scheduling relations of the micro-services become more complex along with the increase of the number of the micro-services.
Optionally, two special admission controllers are included in Kubernetes apiserver: mutatingAdmission webhooks, validatingAdmission, the two controllers will send admission requests to external HTTP callback services and return the processing results to kube-apiserver for kube-apiserver to update and schedule the microservices. In the present application, the target controller may select MutatingAdmission webhooks an admission controller and MutatingAdmission webhooks an admission controller may intercept request instructions to update or schedule micro-services. In addition, it is necessary to ensure that the MutatingAdmission webhooks admission controller is enabled in the apiserver configuration file to ensure MutatingAdmission webhooks that the admission controller works properly, and the logic code diagram of this process may be as shown in fig. 2. In the process, the logic code of the MutatingAdmission webhooks admission controller may be packed into a Docker mirror image and one depoyment used to run the controller. The logic code diagram of the MutatingAdmission webhooks admission controller may be as shown in fig. 3. Next, the process of containerizing Deployment of MutatingAdmission webhooks admission controllers on a Service cluster, such as a Kubernetes cluster, may be implemented using a replyment+service, and the logical code diagram of this process may be as shown in fig. 4.
After the MutatingAdmission webhooks admission controller is deployed in a Kubernetes cluster in a containerized manner, the service implemented above is not yet docked with the mutte Webhook, so that the service is required to be registered in the mutte Webhook, the process only needs to create a Kubernetes resource object of mutate WebhookConfiguration type, in which the Webhook can be configured without the service then naming the Webhook as a "Webhook"
io.ydzs.adjacency-region and it is necessary to ensure that the naming is unique among clusters. The configuration of the webhook is then specified under what conditions the rule attribute is to be used under, where this webhook only needs to be invoked when a Pod is created. In addition, under the ClientConfig attribute, it is also required to specify how Kubernetes APIServer can find webhook Service, which can be served under the/validate path by a Service named admission-registry under the default namespace, and a candable attribute, which indicates that APIServer can be used by a client to verify server certificates on webhook applications by specifying a PEM-formatted CA bundle, and the corresponding registered webhook resource list is shown in fig. 5.
Corresponding to the method described in fig. 1, the embodiment of the present application further provides a micro-service scheduling apparatus, which is used for implementing the method in fig. 1, where the micro-service scheduling apparatus provided in the embodiment of the present application may be described in a computer terminal or various mobile devices with reference to fig. 6, and as shown in fig. 6, the apparatus may include:
a target computing node selection module 10, configured to select a target computing node from the computing nodes in the service cluster in response to a request instruction for scheduling each micro service in the service cluster;
the deployment module 20 is configured to deploy a target controller acquired in advance on the target computing node to obtain an independent computing node;
a parameter determining module 30, configured to send each micro service to the independent computing node, so that the independent computing node determines a class, a first service value, and a second service value of each micro service;
and a sending module 40, configured to send each micro service to each computing node except the independent computing node based on the class, the first service value and the second service value of each micro service, so as to complete the scheduling process of each micro service.
From the above technical solution, it can be seen that the present application selects a target computing node from the computing nodes in a service cluster by responding to a request instruction for scheduling each micro-service in the service cluster; deploying a target controller acquired in advance on the target computing node to obtain an independent computing node; transmitting each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service; and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service. According to the scheme, the target controller is deployed on the target computing node to obtain an independent computing node, all the micro services are sent to the independent computing node to obtain parameters of each micro service, including a category, a first service value and a second service value, and each micro service is scheduled according to the parameters, so that a scheduling result can be optimized, and efficient operation of a service cluster is ensured.
In one example, the parameter determination module 30 may include:
the combination module is used for determining calling information between every two micro services and combining the calling information into a calling information set;
the dimension reduction module is used for reducing dimension of the call information set to obtain a two-dimensional data set corresponding to the call relation set;
and the clustering module is used for clustering the two-dimensional data sets to obtain the categories of the micro services.
In one example, the parameter determination module 30 may include:
the first acquisition module is used for acquiring each processor value corresponding to each micro service in a first preset time period;
the first average value calculation module is used for taking the average value of each processor value as the minimum value of the processor corresponding to the micro service;
and the first assignment module is used for taking the minimum value of the processor as a first service value of the micro service.
In one example, the parameter determination module 30 may further include:
the second acquisition module is used for acquiring each memory value corresponding to each micro service in a first preset time period;
the second average value calculation module is used for taking the average value of each memory value as the minimum memory value corresponding to the micro-service;
and the second assignment module is used for taking the memory minimum value as a second service value of the micro service.
In one example, the transmitting module 40 may include:
the micro service group obtaining module is used for combining each soft parent and service corresponding to the category into a micro service group corresponding to the category;
a response node determining module, configured to determine, from each computing node except the independent computing node, a response node corresponding to the micro service group based on a first service value and a second service value of each soft affinity service in the micro service group;
and the micro service group sending module is used for sending the micro service group to the response node.
In one example, the combining module may include:
the judging module is used for judging whether a first service corresponding to each micro service exists in the independent computing node or not according to each micro service;
the first call information acquisition module is used for acquiring first call information of a first service corresponding to the micro service if the first service exists in the independent computing node;
the inter-calling relation determining module is used for determining the inter-calling relation between the micro service and other micro services based on the first calling information;
and the integration module is used for integrating the calling relationship between each micro service and other micro services to obtain the calling information set.
Further, the embodiment of the application provides a micro-service scheduling device. Alternatively, fig. 7 shows a hardware architecture block diagram of a micro-service scheduling device, and referring to fig. 7, the hardware architecture of the micro-service scheduling device may include: at least one processor 01, at least one communication interface 02, at least one memory 03 and at least one communication bus 04.
In the embodiment of the present application, the number of the processor 01, the communication interface 02, the memory 03 and the communication bus 04 is at least one, and the processor 01, the communication interface 02 and the memory 03 complete communication with each other through the communication bus 04.
The processor 01 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement embodiments of the present application, or the like.
The memory 03 may include a high-speed RAM memory, and may further include a nonvolatile memory (non-volatile memory) or the like, such as at least one magnetic disk memory.
The memory stores a program, and the processor can call the program stored in the memory, and the program is used for executing the following micro-service scheduling method, which comprises the following steps:
responding to a request instruction for scheduling each micro-service in a service cluster, and selecting a target computing node from each computing node in the service cluster;
deploying a target controller acquired in advance on the target computing node to obtain an independent computing node;
transmitting each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service;
and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service.
Alternatively, the refinement function and the extension function of the program may refer to the description of the scheduling method of the micro service in the method embodiment.
The embodiment of the application also provides a storage medium, which can store a program suitable for being executed by a processor, and when the program runs, the device in which the storage medium is controlled to execute the following micro-service scheduling method, comprising the following steps:
responding to a request instruction for scheduling each micro-service in a service cluster, and selecting a target computing node from each computing node in the service cluster;
deploying a target controller acquired in advance on the target computing node to obtain an independent computing node;
transmitting each micro-service to the independent computing node so that the independent computing node can determine the category, the first service value and the second service value of each micro-service;
and sending each micro service to each computing node except the independent computing node based on the category, the first service value and the second service value of each micro service so as to complete the scheduling process of each micro service.
In particular, the storage medium may be a computer-readable storage medium, which may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM.
Alternatively, the refinement function and the extension function of the program may refer to the description of the scheduling method of the micro service in the method embodiment.
In addition, functional modules in various embodiments of the present disclosure may be integrated together to form a single portion, or each module may exist alone, or two or more modules may be integrated to form a single portion. The functions, if implemented in the form of software functional modules and sold or used as a stand-alone product, may be stored on a computer readable storage medium. Based on such understanding, the technical solution of the present disclosure may be embodied in essence or a part contributing to the prior art or a part of the technical solution, or in the form of a software product stored in a storage medium, including several instructions to cause a computer device (which may be a personal computer, a live device, or a network device, etc.) to perform all or part of the steps of the methods of the embodiments of the present disclosure.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, and identical and similar parts between the embodiments are all enough to refer to each other.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.