Resource scheduling method and device, electronic device, and storage medium
By monitoring the resource occupancy of the application service and the resource amount of the target service, it is decided whether to expand the capacity, which solves the problem of system crash caused by expansion and contraction in the existing technology, and improves the rationality of resource scheduling and system stability.
Patent Information
- Application Number
- CN202111593927.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-23
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-12-23
AI Technical Summary
In application systems based on cloud technology, existing expansion and contraction methods can easily lead to system crashes and fail to effectively consider the resource impact after expansion, leading to the collapse of related services.
By monitoring the resource occupancy of application services, it is determined whether the preset expansion conditions are met, and the amount of occupied resources of the target service is obtained. If it is less than the threshold, the capacity is expanded to avoid insufficient resources for associated services after expansion.
It improves the rationality of resource scheduling and system stability, avoids the collapse of related services after expansion, and improves processing efficiency and resource utilization.
Smart Images

Figure CN114385353B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a resource scheduling method and device, electronic equipment, storage medium, and program product. Background Art
[0002] In an application system implemented based on cloud technology, an application system is usually divided into multiple application services, and each application service is provided by multiple service instances with the same functions, and supports expansion or reduction of the application service. For example, in a microservice scenario based on container technology, each application service is provided by multiple containers (or pods, i.e., container groups) with the same functions, and supports expansion or reduction of the resources contained in the application service. In the related art, when expanding the capacity of an application service, it is usually determined whether to expand the capacity based on the remaining resources of the host where the service instance is located. For example, if the remaining resources of the host where the service instance is located are relatively large, the application service is expanded. However, this expansion and reduction method is prone to cause system crashes. Summary of the invention
[0003] To solve the above technical problems, the embodiments of the present application provide a resource scheduling method and device, an electronic device, a storage medium, and a program product.
[0004] According to one aspect of an embodiment of the present application, a resource scheduling method is provided, the method comprising:
[0005] Monitor the resource usage of the application service itself;
[0006] If it is monitored that the resource occupancy of the application service itself meets the preset expansion condition, then determining the target service that the application service needs to call during the execution process;
[0007] Obtaining a first occupied resource amount corresponding to the occupied resources in the target service;
[0008] If the first occupied resource amount is less than a first threshold, the application service is expanded.
[0009] According to one aspect of an embodiment of the present application, a resource scheduling device is provided, the device comprising:
[0010] A monitoring module configured to monitor resource usage of the application service itself;
[0011] A determination module configured to determine a target service that needs to be called during the execution of the application service if it is monitored that the resource occupancy of the application service itself meets a preset expansion condition;
[0012] An acquisition module configured to acquire a first occupied resource amount corresponding to the occupied resources in the target service;
[0013] The capacity expansion module is configured to expand the application service if the first occupied resource amount is less than a first threshold.
[0014] According to one aspect of an embodiment of the present application, there is provided an electronic device, including:
[0015] one or more processors;
[0016] The storage device is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the resource scheduling method as described above.
[0017] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of an electronic device, the electronic device executes the resource scheduling method as described above.
[0018] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, wherein when the computer instructions are executed by a processor, the resource scheduling method as described above is implemented.
[0019] In the technical solution provided in the embodiments of the present application, the resource occupancy of the application service itself is first monitored. If it is monitored that the resource occupancy of the application service itself meets the preset expansion conditions, the target shared service that needs to be called by the application service during execution is determined; the first occupied resource amount corresponding to the occupied resources in the target shared service is obtained. If the first occupied resource amount is less than the first threshold, the application service is expanded. In other words, when it is necessary to expand the application service, the resource occupancy of the associated services of the application service will be referred to, so as to determine whether to expand the capacity according to the resource occupancy of the associated services, so as to avoid the situation where, after the application service is expanded, the application service occupies a large amount of resources in the associated services, resulting in insufficient available resources in the associated services, the associated services crash, and then the entire application system crashes, thereby improving the rationality of resource scheduling and the stability of the system.
[0020] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0022] Figure 1 is a flow chart of a resource scheduling method shown in an exemplary embodiment of the present application;
[0023] Figure 2 yes Figure 1 A flowchart of step S140 in the illustrated embodiment in an exemplary embodiment;
[0024] Figure 3 yes Figure 1 A flowchart of step S140 in the illustrated embodiment in another exemplary embodiment;
[0025] Figure 4 is a flow chart of a resource scheduling method shown in an exemplary embodiment of the present application;
[0026] Figure 5 It is an implementation environment of a resource scheduling method shown in an exemplary embodiment of the present application;
[0027] Figure 6 is a structural diagram of a resource scheduling device shown in an exemplary embodiment of the present application;
[0028] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0029] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0030] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0031] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0032] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.
[0033] In an application system implemented based on cloud technology, an application system is usually divided into multiple application services, each of which is provided by multiple service instances with the same functions, and supports expansion or reduction of the application service. However, at present, when expanding the capacity of an application service, it is usually only considered whether the remaining resources of the host where the service instance is located can support the expansion. For example, if the remaining resources of the host where the service instance is located are large, the application service is expanded. However, this expansion method does not take into account the impact of the expanded application service on other services, which can easily cause other services to crash, and then cause the system to crash. Based on this, the embodiments of the present application provide a resource scheduling method and device, an electronic device, and a storage medium, which can reduce the probability of other services crashing after the application service is expanded, thereby improving the rationality of resource scheduling and the stability of the system.
[0034] See also Figure 1 , Figure 1 FIG. 1 is a flow chart of a resource scheduling method shown in an exemplary embodiment of the present application. Figure 1 As shown, in an exemplary embodiment, the resource scheduling method may include steps S110 to S140, which are described in detail as follows:
[0035] Step S110, monitoring the resource usage of the application service itself.
[0036] It should be noted that application services are services included in application systems implemented based on cloud technology. In application systems implemented based on cloud technology, an application system is usually divided into multiple application services, each of which is provided by multiple service instances with the same functions, and supports scaling of application services. For example, in a microservice scenario based on container technology, each application service is provided by multiple containers with the same functions, and in kubernetes, each application service is provided by multiple pods with the same functions. kubernetes is an open source container orchestration engine from Google that supports automated deployment, large-scale scalability, and containerized management of applications; a pod is composed of one or more containers and can be regarded as a container group.
[0037] The resources of the application service itself are the resources allocated to the application service, that is, the resources contained in the application service, such as the resources corresponding to the aforementioned containers and pods. The resource types of the application service itself include but are not limited to computing resources (such as CPU resources, etc., where CPU is a central processing unit, i.e., central processing unit), storage resources (such as memory, etc.), etc. In addition, it supports the expansion or reduction of the resources of the application service itself.
[0038] In order to determine whether the application service needs to be expanded or reduced in capacity, in this embodiment, the resource occupancy of the application service itself is monitored.
[0039] Step S120: If it is monitored that the resource occupancy of the application service itself meets the preset expansion condition, the target service that needs to be called during the execution of the application service is determined.
[0040] The preset expansion condition is a preset condition used to determine whether the application service needs to be expanded. The preset expansion condition can be flexibly set according to actual needs, and can be set to the resource occupancy rate reaching the preset resource occupancy rate upper limit. Among them, the resource occupancy rate is the ratio of the occupied resources to the total resources (that is, the sum of the occupied resources and the remaining resources). For the application service, the resource occupancy rate is the ratio of the occupied resources in the application service to the total resources scheduled to the application service; the resource occupancy rate upper limit is used to determine whether the application service needs to be expanded. It can be set to the boundary between normal operation and abnormal operation of the application service. If it exceeds the upper limit, it indicates that the application service has fewer available resources and the application service is prone to crash. If it is lower than the upper limit, it indicates that the application service has more resources and the application service is running normally and is not prone to crash. The specific value of the resource occupancy rate upper limit can be flexibly set according to actual needs, for example, it can be set to 90%, 80%, etc. In an example, the preset expansion condition may include that the CPU resource occupancy rate of the application service exceeds 90%, or that the memory occupancy rate of the application service exceeds 80%.
[0041] The target service includes the services that need to be called during the execution of the application service. It should be understood that the application service needs to call other services in the process of realizing the corresponding functions. For example, assuming that the application service is a registration service, since the registration service needs to call the database to store the registration information in the database, in this embodiment, the service that the application service needs to call during the execution process is used as the target service. Among them, all services that need to be called during the execution of the application service can be used as target services; or, considering that a shared service is a service that can be called by multiple application services, if a shared service crashes, it will cause multiple application services to crash. Therefore, in order to avoid the crash of a shared service, in this embodiment, the shared service that needs to be called during the execution of the application service can be used as a target service, wherein shared services include but are not limited to middleware services, such as databases, message middleware, cache and other middleware services.
[0042] In the present embodiment, taking into account that after the application service is expanded, the resources occupied by the application service in the associated services may increase, in order to avoid the expansion of the application service causing the associated services to crash, or the expanded part being unable to call the associated services, in the present embodiment, after monitoring that the resource occupancy of the application service itself meets the preset expansion conditions, that is, after determining that the application service needs to be expanded, the target service that needs to be called by the application service during execution is first determined.
[0043] Step S130, obtaining a first occupied resource amount corresponding to the occupied resources in the target service.
[0044] It should be noted that resources are allocated to the target service, wherein the first occupied resource amount is the resource amount corresponding to the currently occupied resources in the target service. The resources of the target service may include computing resources, memory resources, etc., and may also include the number of connections established between other services and the target service, etc. For example, for a database, other services may create a connection with the database to read data from the database or write data to the database through the connection. The number of connections supported by the database is limited, so the occupied resources in the database may be the number of connections established between other services and the database.
[0045] In this embodiment, after determining the target service that needs to be called during the execution of the application service, the first occupied resource amount of the target service is obtained.
[0046] Step S140: If the first occupied resource amount is less than the first threshold, the application service is expanded.
[0047] The first threshold is set for the target service, and can be set to the upper limit of the resources that can be occupied when the target service is operating normally. If the occupied resources of the target service exceed the first threshold, it indicates that there are few remaining available resources in the target service, and the target service is prone to crash. The specific value of the first threshold can be set according to actual needs. For example, it can be set to 90% of the total resources of the target service; for another example, the calculation formula of the first threshold can be: f(n) = m*n*q, where m is the maximum amount of resources that can be provided by a single service instance in the target service when it is operating normally, which can be set according to experiments or experience, n is the number of service instances included in the target service, and q is a preset ratio, which can be set to 0.9, 0.8, etc.
[0048] In this embodiment, if the first occupied resource amount is less than the first threshold, it indicates that the target service has more remaining available resources, and therefore the application service can be expanded.
[0049] The specific expansion plan for the application service can be flexibly set according to actual needs. For example, the preset first ratio can be expanded based on the resources currently scheduled for the application service. The preset first ratio can be flexibly set according to actual needs, for example, it can be 50%, 30%, etc. In one example, assuming that the memory currently scheduled for the application service is 200M, the preset first ratio is 20%, and when the memory occupied in the application service is 185M, the preset expansion condition is met. Therefore, 40M is added on the basis of 200M, that is, after the expansion, the memory resources of the application service are 240M.
[0050] Expanding the capacity of an application service may be to add a new service instance to the application service. For example, assuming that the preset first ratio is 50%, before the expansion, the application service includes 8 service instances, then 4 service instances are added, that is, after the expansion, the application service includes 12 service instances. Alternatively, expanding the capacity of an application service may be to increase the amount of resources included in each service instance without adding a new service instance.
[0051] In the technical solution provided in this embodiment, the resource occupancy of the application service itself is first monitored. If it is monitored that the resource occupancy of the application service itself meets the preset expansion condition, the target shared service that the application service needs to call during the execution process is determined; the first occupied resource amount corresponding to the occupied resources in the target shared service is obtained. If the first occupied resource amount is less than the first threshold, the application service is expanded. That is to say, when it is necessary to expand the application service, the resource occupancy of the associated services of the application service will be referred to, so as to determine whether to expand the capacity according to the resource occupancy of the associated services. On the one hand, it can avoid the situation that after the application service is expanded, the expanded part cannot call the management service due to the small number of remaining available resources of the associated services, thereby improving the processing efficiency of the application service after the expansion; on the other hand, it can also avoid the situation that after the application service is expanded, the application service occupies a large amount of resources in the associated services, resulting in insufficient available resources in the associated services, the associated services crash, and then the entire application system crashes, thereby improving the rationality of resource scheduling and the stability of the system.
[0052] See also Figure 2 , Figure 2 yes Figure 1 The step S140 in the illustrated embodiment is a flow chart in an exemplary embodiment. Figure 2 As shown, if the first occupied resource amount is less than the first threshold, the process of expanding the application service may include steps S210 to S230, which are described in detail as follows:
[0053] Step S210, determining a capacity expansion plan for expanding the application service.
[0054] In this embodiment, a capacity expansion plan for expanding the application service may also be determined. The capacity expansion plan may be flexibly set according to actual needs.
[0055] Step S220, after the application service is expanded according to the determined expansion plan, it is estimated that the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target service.
[0056] During the execution process, the application service needs to call the target service, that is, it needs to occupy resources in the target service. If the remaining available resources of the target service are insufficient, after the application service is expanded, the expanded part will not be able to call the target service, the connection will time out, and even cause the target service to crash, which will lead to the crash of other businesses.
[0057] In order to ensure that after the application service is expanded, the expanded part can call the target service normally and avoid the crash of the target service, after the expansion plan is determined, the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target service after the application service is expanded can be estimated according to the expansion plan. For example, assuming that the expansion plan is to add a new service instance and the target service is a database, the total number of connections that the new service instance needs to establish with the database can be determined based on the number of connections that a single service instance in the application service needs to establish with the database in advance and the number of service instances that need to be added, and the total number of connections is used as the amount of resources to be occupied. In an example, assuming that the number of connections that a single service instance in the application service needs to establish with the database is 5, and the expansion plan is to add 6 service instances, the amount of resources to be occupied is 30.
[0058] Step S230: If the sum of the first occupied resource amount and the to-be-occupied resource amount is less than the first threshold, the application service is expanded according to the determined expansion plan.
[0059] In this embodiment, the sum of the first occupied resource amount and the to-be-occupied resource amount is calculated first. If the calculated sum is less than the first threshold, it indicates that after the application service is expanded, the amount of to-be-occupied resources that the expanded part needs to occupy in the target service is less than the remaining available resources of the target service, that is, the remaining available resources of the target service can meet the needs of the expanded part. Therefore, the application service is expanded according to the determined expansion plan, thereby ensuring that after the application service is expanded, the expanded part can call the target service normally, thereby ensuring the efficiency of the application service and reducing the probability of the target service being included.
[0060] In this embodiment, an expansion plan for expanding the application service is determined, and the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target service after the application service is expanded is estimated according to the determined expansion plan. If the sum of the first occupied resource amount and the to-be-occupied resource amount is less than a first threshold, the application service is expanded according to the determined expansion plan, so that after the application service is expanded, the expanded part can call the target service normally, thereby reducing the probability of the target service crashing and improving the stability of the business.
[0061] See also Figure 3 , Figure 3 yes Figure 1 The step S140 in the illustrated embodiment is a flow chart in an exemplary embodiment. Figure 3 As shown, if the first occupied resource amount is less than the first threshold, the process of expanding the application service may include steps S310 to S320, which are described in detail as follows:
[0062] Step S310: If the first occupied resource amount is less than the first threshold, obtain a second occupied resource amount corresponding to the resources occupied by the application service in the target service.
[0063] In this embodiment, after monitoring that the resource occupancy of the application service itself meets the preset expansion conditions and determining the target service that the application service needs to call during execution, if it is determined that the first occupied resource amount is less than the first threshold, the second occupied resource amount corresponding to the resources occupied by the application service in the target service can be obtained.
[0064] In some implementations, after determining that the sum of the first occupied resource amount and the to-be-occupied resource amount is less than the first threshold, a second occupied resource amount corresponding to the resources occupied by the application service in the target service may be obtained. For the to-be-occupied resource amount, please refer to the above description and will not be repeated here.
[0065] Step S320: If the acquired second occupied resource amount is less than the second threshold, the application service is expanded.
[0066] The second threshold is the maximum amount of resources that the application service can occupy in the target service, and the second threshold is less than the first threshold. In order to avoid the situation where the same application service occupies a large amount of resources in the target service, resulting in other application services being unable to call the target service, in this embodiment, a second threshold is set, wherein the second threshold can be flexibly set according to actual needs.
[0067] In this embodiment, if the first occupied resource amount is less than the first threshold and the acquired second occupied resource amount is less than the second threshold, it indicates that the target service has more remaining available resources and the application service has occupied fewer resources in the target service, so the application service can be expanded.
[0068] In some implementations, in order to further reduce the situation where the target service crashes after the application service is expanded, step S320 may include: if the sum of the second occupied resource amount and the resource amount to be occupied is less than the second threshold, the application service is expanded according to the determined expansion plan. The resource amount to be occupied and the expansion plan can be referred to the above introduction, which will not be repeated here.
[0069] In this embodiment, if the first occupied resource amount is less than the first threshold, the second occupied resource amount corresponding to the resources occupied by the application service in the target service is obtained. If the obtained second occupied resource amount is less than the second threshold, the application service is expanded, thereby avoiding the situation where a certain application service occupies a large number of resources in the target service and other application services cannot call the target service, thereby achieving balanced allocation of resources in the target service.
[0070] In an exemplary embodiment, when there are multiple target services, Figure 1 Step S140 in the illustrated embodiment may include: if the first occupied resource amount of each target service in the plurality of target services is less than the corresponding first threshold, expanding the capacity of the application service.
[0071] Under the condition that there are multiple target services, a corresponding first threshold is set for each target service. In order to ensure that the expansion of the application service will not affect each target service, in this embodiment, the application service can be expanded only when the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold. For example, assuming that the multiple target services include three services A, B, and C, the first threshold corresponding to target service A is a, the first threshold corresponding to target service B is b, and the first threshold corresponding to target service C is c, then the application service is expanded under the condition that the current occupied resource amount of target service A is less than a, the current occupied resource amount of target service B is less than b, and the current occupied resource amount of target service B is less than c.
[0072] In some embodiments, under the condition that multiple target services include a database and a message middleware, and the first threshold includes a first connection number threshold corresponding to the database and a second connection number threshold corresponding to the message middleware, if the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold, the process of expanding the application service may include: if the number of connections of the database is less than the first connection number threshold, and the number of connections of the message middleware is less than the second connection number threshold, expanding the application service.
[0073] It should be noted that the number of connections to the database is the number of connections established between other services (services other than the database) and the database, and the first connection number threshold is the maximum number of connections that can be established between other services and the database. The first connection number threshold can be flexibly set according to actual needs.
[0074] The message middleware is based on queue and message delivery technology, such as message queues, etc. The number of connections of the message middleware is the number of connections established between other services (services other than the message middleware) and the message middleware, and the second connection number threshold is the maximum number of connections that can be established between other services and the message middleware. The second connection number threshold can be flexibly set according to actual needs.
[0075] When the number of connections to the database is less than the first connection number threshold, and the number of connections to the message middleware is less than the second connection number threshold, it indicates that the number of available connections to the database and the message middleware is large, and the application service is expanded.
[0076] In this embodiment, under the condition that there are multiple target services, the application service is expanded only if the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold, thereby ensuring the normal operation of the application service and each target service corresponding to the application service.
[0077] In an exemplary embodiment, Figure 1 After step S130 in the illustrated embodiment, the resource scheduling method may further include: if the first used resource amount is greater than or equal to a first threshold, suspending capacity expansion of the application service and limiting the number of requests transmitted to the application service.
[0078] If the first amount of occupied resources is greater than or equal to the first threshold, it indicates that the remaining available resources of the target service are small. If the application service continues to be expanded, since the expanded part will also occupy resources in the target service, it will cause the expanded part to be unable to call the target service, and the available resources of the target service will be further reduced, causing the target service to crash, and then the entire system to crash. Therefore, in order to avoid this situation, in this embodiment, if the first amount of occupied resources is greater than or equal to the first threshold, the expansion of the application service is suspended, and the number of requests transmitted to the application service is limited, that is, the requests that need to be transmitted to the application service are limited, so as to avoid the situation where the application service crashes.
[0079] In this embodiment, if the first used resource amount is greater than or equal to the first threshold, the expansion of the application service is suspended to avoid the target service crash, and the number of requests transmitted to the application service is limited to reduce the probability of application service crash.
[0080] In an exemplary embodiment, Figure 1 After step S110 in the illustrated embodiment, the resource scheduling method may further include: if it is monitored that the resource occupancy of the application service itself meets a preset shrinking condition, shrinking the application service.
[0081] The preset shrinking condition is a preset condition used to determine whether the application service needs to be shrunk. The preset shrinking condition can be flexibly set according to actual needs. In one example, the preset shrinking condition can be set as follows: the resource occupancy rate of the application service itself is less than the preset resource occupancy rate lower limit. When the resource occupancy rate is less than the resource occupancy rate lower limit, it indicates that the remaining available resources of the application service are large. In order to improve resource utilization, the application service can be shrunk, wherein the preset resource occupancy rate lower limit can be set to 50%, 20%, 10%, etc. Or, in another example, in order to avoid contingency, the preset shrinking condition can also be set as follows: the resource occupancy rate of the application service itself is less than the preset resource occupancy rate lower limit, and the duration of the state of the resource occupancy rate being less than the resource occupancy rate lower limit exceeds the duration threshold; under this condition, if it is monitored that the resource occupancy rate of the application service itself is less than the preset resource occupancy rate lower limit, and the duration of the state of the resource occupancy rate being less than the resource occupancy rate lower limit exceeds the duration threshold, the application service is shrunk. Among them, the duration threshold can be flexibly set according to actual needs, such as 3 minutes, 5 minutes, etc.
[0082] The solution for scaling down the application service can be flexibly set according to actual needs. For example, the preset second ratio can be reduced based on the resources currently scheduled for the application service. The preset second ratio can be flexibly set according to actual needs, for example, it can be 23%, 35%, etc. In one example, assuming that the memory currently scheduled for the application service is 100M and the preset second ratio is 30%, then on the basis of 100M, 30M is reduced, that is, after scaling down, the memory resources of the application service are 70M.
[0083] In this embodiment, if it is monitored that the resource occupancy of the application service itself meets the preset shrinking condition, the application service is shrunk, thereby improving resource utilization.
[0084] The following is a specific example of the resource scheduling method. Figure 4 As shown, the resource scheduling method includes:
[0085] Step S401: Obtain metadata of application services and shared services.
[0086] The metadata of the application service includes the amount of resources that a single service instance in the application service needs to occupy in the shared service, etc. The metadata of the shared service includes the maximum amount of resources that can be occupied when the shared service is running normally, that is, the first threshold.
[0087] Step S402: monitor the resource usage of the application service.
[0088] In this embodiment, the resource usage of the application service is monitored.
[0089] Step S403: If the resource occupancy of the application service meets the preset expansion condition, then determine the target shared service that needs to be called during the execution of the application service.
[0090] In this embodiment, if the resource occupancy of the application service meets the preset expansion conditions, it indicates that the current available resources of the application service are insufficient and the application service needs to be expanded. In order to avoid the situation where the application service cannot call the target shared service or the target shared service is included after the application service is expanded, in this embodiment, it is also necessary to determine the shared service that the application service needs to call during the execution process, that is, the target shared service.
[0091] In an example, assuming that the preset expansion condition is that the CPU resource occupancy rate reaches 90% or the memory occupancy rate reaches 80%, when the CPU resource occupancy rate of the application service itself reaches 90%, or the memory occupancy rate of the application service itself reaches 80%, determine the target shared service that the application service needs to call during execution.
[0092] Step S404: obtaining a first occupied resource amount corresponding to the occupied resources in the target sharing service.
[0093] After the target shared service is determined, it is necessary to obtain the currently occupied resource amount in the target shared service, that is, the first occupied resource amount.
[0094] In an example, assuming that the target shared service includes a cache, a database, and a message queue, the database resources are the number of database connections, the message queue resources are the number of message queue connections, and the cache resources are the cache storage resources, then the number of established connections in the database, the number of established connections in the message queue, and the amount of memory resources occupied in the cache are obtained.
[0095] Step S405, determining an expansion plan for expanding the application service, and estimating the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target shared service after the application service is expanded according to the determined expansion plan.
[0096] In this embodiment, after monitoring that the resource occupancy of the application service itself meets the preset expansion conditions and determining the target service that the application service needs to call during execution, an expansion plan for expanding the application service can be determined, and the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target shared service after the application service is expanded is estimated according to the determined expansion plan. It should be noted that in this embodiment, the example of executing step S404 first and then executing step S405 is used for explanation. In other examples, step S405 can also be executed first and then step S404, or step S404 and step S405 can be executed simultaneously.
[0097] Assume that the capacity expansion plan is to increase the service instances included in the application service by a preset 50%, and the number of service instances included in the application service is 20. In the metadata of the application service, the number of connections that need to be established in the database for a single service instance is 2, the number of connections that need to be established in the message queue for a single service instance is 3, and the amount of storage resources that a single service instance needs to occupy in the cache is 4. Then, in the application service, the number of new service instances that need to be added is 20*50%=10, the amount of resources to be occupied by the new service instances in the database is 10*2=20, the amount of resources to be occupied by the new service instances in the message queue is 10*3=30, and the amount of resources to be occupied by the new service instances in the cache is 10*4=40.
[0098] Step S406: determine whether the sum of the first occupied resource amount and the to-be-occupied resource amount corresponding to the target shared service is less than the corresponding first threshold.
[0099] After obtaining the first amount of occupied resources and the amount of resources to be occupied, the sum of the first amount of occupied resources and the amount of resources to be occupied can be determined, and whether the sum is less than a first threshold value can be determined. The first threshold value can be deployed in the metadata of the target shared service. The calculation method of the first threshold value can be: m*n*q. For example, for a database, m is the maximum number of connections that can be established when a single service instance in the database is running normally, n is the number of service instances included in the database, and q is 90%.
[0100] Continuing with the above example, obtain the sum of the first occupied resource amount and the amount of resources to be occupied corresponding to the database, and determine whether the sum is less than the first threshold of the database; obtain the sum of the first occupied resource amount and the amount of resources to be occupied corresponding to the message queue, and determine whether the sum is less than the first threshold of the message queue; obtain the sum of the first occupied resource amount and the amount of resources to be occupied corresponding to the cache, and determine whether the sum is less than the first threshold of the cache.
[0101] Step S407: If yes, then expand the application service according to the determined expansion plan.
[0102] If the sum of the first occupied resource amount and the to-be-occupied resource amount corresponding to the target shared service is less than the corresponding first threshold, the application service is expanded according to the determined expansion plan.
[0103] Continuing with the above example, if the sum of the first occupied amount of resources and the amount of resources to be occupied corresponding to the database is less than the first threshold of the database, the sum of the first occupied amount of resources and the amount of resources to be occupied corresponding to the message queue is less than the first threshold of the message queue, and the sum of the first occupied amount of resources and the amount of resources to be occupied corresponding to the cache is less than the first threshold of the cache, then 10 new service instances are added to the application service.
[0104] Step S408: If not, limit the number of requests transmitted to the application service.
[0105] If the sum of the first occupied resource amount and the to-be-occupied resource amount corresponding to the target shared service is greater than or equal to the corresponding first threshold, the number of requests transmitted to the application service is limited.
[0106] Step S409: If the resource usage of the application service meets the preset reduction condition, the application service is reduced in capacity.
[0107] After step S402, if it is monitored that the resource usage of the application service meets the preset scaling-down condition, the application service is scaled down.
[0108] It should be noted that the detailed processes involved in the above steps S401 to S409 have been described in the aforementioned embodiments, and therefore will not be repeated here.
[0109] The solution of this embodiment can, on the one hand, avoid the situation where, after the application service is expanded, the expanded part cannot call the management service due to the small number of remaining available resources of the associated service, thereby improving the processing efficiency of the application service after the expansion; on the other hand, it can also avoid the situation where, after the application service is expanded, the application service occupies a large amount of resources in the associated service, resulting in insufficient available resources in the associated service, the crash of the associated service, and then the crash of the entire application system, thereby improving the rationality of resource scheduling and the stability of the system.
[0110] The following is a detailed description of a specific application scenario of the embodiment of the present application. Figure 5 , Figure 5 This is an exemplary application scenario of the resource scheduling method, which is applied to the cloud native scenario, and includes: a configuration module, a cloud native HPA (Horizontal Pod Autoscaling) module, a control module, a service grid platform, and a middleware management module.
[0111] Among them, the configuration module is used to configure application services and metadata of services such as middleware services that need to be called, for example, the amount of resources that a single service instance in the configuration application service needs to occupy in the middleware service, the first threshold of the middleware service, and other data.
[0112] The middleware management module is used to manage middleware services such as database, cache, message queue, etc., and provide resource usage information of middleware services.
[0113] The control module is used to obtain the resource occupation status of the middleware service from the middleware management module, and compare the occupied resource amount corresponding to the middleware service with the corresponding first threshold to obtain a comparison result.
[0114] The cloud-native HPA module is used to achieve elastic scaling of container resources. In this embodiment, it is used to determine whether the preset shrinking condition or the preset expansion condition is met based on the resource occupancy of the application service itself. When the preset expansion condition is met, the control module is called to compare the amount of occupied resources corresponding to the middleware service with the corresponding first threshold, and the comparison result is obtained from the control module. According to the comparison result, the application service is expanded or the service grid platform is controlled to limit the number of requests transmitted to the application service.
[0115] The service mesh platform is used to manage the number of requests transmitted to the application service. For example, under the control of the cloud native HPA module, the number of requests transmitted to the application service is limited.
[0116] It should be noted that the functions implemented by each module of the application scenario belong to the same concept as the resource scheduling method provided in the above embodiment, and the specific methods of each module of the application scenario have been described in detail in the method embodiment and will not be repeated here.
[0117] See also Figure 6 , Figure 6 FIG. 1 is a block diagram of a resource scheduling device shown in an exemplary embodiment of the present application. Figure 6 As shown, the device comprises:
[0118] The monitoring module 601 is configured to monitor the resource occupancy of the application service itself; the determination module 602 is configured to determine the target service that the application service needs to call during the execution process if the resource occupancy of the application service itself is monitored to meet the preset expansion condition; the acquisition module 603 is configured to obtain the first occupied resource amount corresponding to the occupied resources in the target service; the expansion module 604 is configured to expand the application service if the first occupied resource amount is less than the first threshold.
[0119] In another exemplary embodiment, the expansion module 604 includes:
[0120] The solution determination module is configured to determine an expansion solution for expanding the application service.
[0121] The estimation module is configured to estimate the amount of resources to be occupied corresponding to the resources that the expanded part needs to occupy in the target service after the application service is expanded according to the determined expansion plan.
[0122] The first expansion submodule is configured to expand the application service according to the determined expansion plan if the sum of the first occupied resource amount and the to-be-occupied resource amount is less than a first threshold.
[0123] In another exemplary embodiment, the apparatus further comprises:
[0124] The current limiting module is configured to suspend capacity expansion of the application service and limit the number of requests transmitted to the application service if the first occupied resource amount is greater than or equal to a first threshold.
[0125] In another exemplary embodiment, the expansion module 604 includes:
[0126] The resource amount acquisition module is configured to acquire a second occupied resource amount corresponding to the resources occupied by the application service in the target service if the first occupied resource amount is less than the first threshold.
[0127] The second expansion submodule is configured to expand the application service if the acquired second occupied resource amount is less than the second threshold.
[0128] In another exemplary embodiment, when the target service includes a shared service that needs to be called by the application service during execution, and the number of target services is multiple, the expansion module 604 includes:
[0129] The third expansion submodule is configured to expand the application service if the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold.
[0130] In another exemplary embodiment, under the condition that the multiple target services include a database and a message middleware, and the first threshold includes a first connection number threshold corresponding to the database and a second connection number threshold corresponding to the message middleware, the third expansion submodule includes:
[0131] The service expansion module is configured to expand the application service if the number of connections to the database is less than a first connection number threshold and the number of connections to the message middleware is less than a second connection number threshold.
[0132] In another exemplary embodiment, the apparatus further comprises:
[0133] The scaling-down module is configured to scale down the application service if it is detected that the resource occupancy rate of the application service itself is less than a preset resource occupancy rate lower limit, and the duration of the state in which the resource occupancy rate is less than the resource occupancy rate lower limit exceeds a duration threshold.
[0134] It should be noted that the resource scheduling device provided in the above embodiment and the resource scheduling method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.
[0135] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the electronic device implements the resource scheduling method provided in the above-mentioned embodiments.
[0136] Figure 7 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0137] It should be noted that Figure 7 The computer system 700 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0138] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 702 or the program loaded from the storage part 708 to the random access memory (RAM) 703, such as executing the method described in the above embodiment. In the RAM 703, various programs and data required for system operation are also stored. The CPU 701, ROM 702 and RAM 703 are connected to each other through a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0139] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read therefrom is installed into the storage section 708 as needed.
[0140] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 709, and / or installed from a removable medium 711. When the computer program is executed by a central processing unit (CPU) 701, various functions defined in the system of the present application are executed.
[0141] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a 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 above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0142] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0143] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0144] Another aspect of the present application further provides a computer-readable storage medium on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of an electronic device, the electronic device implements the method described above. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0145] Another aspect of the present application further provides a computer program product or a computer program, which includes computer instructions, and when the computer instructions are executed by a processor, the methods provided in the above embodiments are implemented. The computer instructions can be stored in a computer-readable storage medium; the processor of the electronic device can read the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the methods provided in the above embodiments.
[0146] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. A resource scheduling method, characterized in that: The method comprises: Monitor the resource usage of the application service itself; If it is monitored that the resource occupancy of the application service itself meets the preset expansion condition, then determining the target service that the application service needs to call during the execution process; Obtaining a first occupied resource amount corresponding to the occupied resources in the target service; If the first occupied resource amount is less than a first threshold, the application service is expanded.
2. The method according to claim 1, characterized in that If the first occupied resource amount is less than a first threshold, expanding the application service includes: Determine a capacity expansion plan for expanding the application service; After the application service is expanded according to the determined expansion plan, it is estimated that the amount of resources to be occupied by the expanded part corresponds to the resources that need to be occupied in the target service; If the sum of the first occupied resource amount and the to-be-occupied resource amount is less than the first threshold, the application service is expanded according to the determined expansion plan.
3. The method according to claim 1, characterized in that After obtaining the first occupied resource amount corresponding to the occupied resources in the target service, the method further includes: If the first occupied resource amount is greater than or equal to the first threshold, capacity expansion of the application service is suspended, and the number of requests transmitted to the application service is limited.
4. The method according to claim 1, characterized in that If the first occupied resource amount is less than a first threshold, expanding the application service includes: If the first occupied resource amount is less than a first threshold, obtaining a second occupied resource amount corresponding to the resources occupied by the application service in the target service; If the acquired second occupied resource amount is less than the second threshold, the application service is expanded.
5. The method according to claim 1, characterized in that The target service includes a shared service that needs to be called by the application service during execution, and the number of the target services is multiple; if the first occupied resource amount is less than a first threshold, the application service is expanded, including: If the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold, the application service is expanded.
6. The method according to claim 5, characterized in that The multiple target services include a database and a message middleware, and the first threshold includes a first connection number threshold corresponding to the database and a second connection number threshold corresponding to the message middleware; If the first occupied resource amount of each target service in the multiple target services is less than the corresponding first threshold, the application service is expanded, including: If the number of connections to the database is less than the first connection number threshold, and the number of connections to the message middleware is less than the second connection number threshold, the application service is expanded.
7. The method according to claim 1, characterized in that After monitoring the resource occupancy of the application service itself, the method further includes: If it is monitored that the resource occupancy rate of the application service itself is less than a preset resource occupancy rate lower limit, and the duration of the state in which the resource occupancy rate is less than the resource occupancy rate lower limit exceeds a duration threshold, the application service is scaled down.
8. A resource scheduling device, characterized in that: The device comprises: A monitoring module configured to monitor resource usage of the application service itself; A determination module configured to determine a target service that needs to be called during the execution of the application service if it is monitored that the resource occupancy of the application service itself meets a preset expansion condition; An acquisition module configured to acquire a first occupied resource amount corresponding to the occupied resources in the target service; The capacity expansion module is configured to expand the application service if the first occupied resource amount is less than a first threshold.
9. An electronic device, characterized in that: include: one or more processors; A storage device, used to store one or more programs, when the one or more programs are executed by the one or more processors, enables the electronic device to implement the resource scheduling method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is enabled to execute the resource scheduling method according to any one of claims 1 to 7.
