CN-122001935-A - Micro-service resource allocation recommendation method and computer-readable storage medium
Abstract
The invention discloses a micro-service resource allocation recommendation method and a computer-readable storage medium, which solve the defects that in the prior art, allocation rules are stiff, intelligent adaptation is not possible, manual dependence is relied on, and large-scale application is difficult. The micro-service resource allocation recommendation method comprises the steps of obtaining running state information and running environment information of a target micro-service in a first historical time period, determining a resource allocation recommendation strategy for the target micro-service based on the running environment information, and executing the resource allocation recommendation strategy based on the running state information to generate a recommendation result for carrying out resource allocation on the target micro-service next time.
Inventors
- LIU QIXIANG
- FU KEWEI
Assignees
- 广联达科技股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20260210
Claims (11)
- 1. A micro-service resource allocation recommendation method, comprising: Acquiring running state information and running environment information of a target micro-service in a first historical time period; Determining a resource allocation recommendation strategy for the target micro-service based on the running environment information; And executing the resource allocation recommendation strategy based on the running state information to generate a recommendation result for carrying out resource allocation on the target micro-service next time.
- 2. The method for recommending micro-service resource allocation according to claim 1, wherein the operation environment information comprises a programming language type to which the target micro-service belongs; When the programming language type is JAVA language, the running environment information also comprises a JDK version of the target micro-service; the resource configuration recommendation strategy comprises a JVM prediction model for recommending JVM configuration parameters, a first memory calculation strategy for recommending first memory configuration parameters and a first CPU calculation strategy for recommending first CPU configuration parameters; When the programming language type is a non-JAVA language, the running state information comprises a second memory performance index and a second CPU performance index, and the resource configuration recommendation strategy comprises a second memory calculation strategy for recommending second memory configuration parameters and a second CPU calculation strategy for recommending the second CPU configuration parameters.
- 3. The micro service resource allocation recommendation method according to claim 2, wherein when the programming language type is JAVA language, the executing the resource allocation recommendation policy based on the running state information to generate a recommendation result for resource allocation of the target micro service next time includes: Inputting the JVM performance index into the JVM prediction model to obtain the JVM configuration parameters, wherein the JVM configuration parameters comprise XMX parameters and XMN parameters; Inputting the first memory performance index into the first memory calculation strategy to obtain the first memory configuration parameter; Inputting the first CPU performance index into the first CPU calculation strategy to obtain the first CPU configuration parameter; when the JDK version is a preset version or is earlier than the preset version, the XMX parameter, the XMN parameter, the first memory configuration parameter and the first CPU configuration parameter are used as the recommendation result; and when the JDK version is later than the preset version, taking the XMX parameter, the first memory configuration parameter and the first CPU configuration parameter as the recommendation result.
- 4. The method for recommending micro-service resource allocation according to claim 3, wherein the first memory performance index comprises a plurality of JVM off-heap memory usage sample values and a plurality of JVM thread number sample values of the target micro-service; The inputting the first memory performance index into the first memory calculation policy to obtain the first memory configuration parameter includes: Determining the maximum JVM off-heap memory usage sampling value from the plurality of JVM off-heap memory usage sampling values; Determining the maximum JVM thread number sampling value from the JVM thread number sampling values; calculating the memory amount required by the JVM based on the XMX parameter, the maximum JVM off-heap memory usage sampling value and the maximum JVM thread number sampling value; weighting the memory amount required by the JVM based on a preset first weight coefficient to obtain a first memory allocation amount; Weighting the memory amount required by the JVM based on a preset second weight coefficient to obtain a first upper limit of the memory usage amount, wherein the first weight coefficient and the second weight coefficient are both larger than 1, and the second weight coefficient is larger than the first weight coefficient; And taking the first memory allocation amount and the first memory use amount upper limit as first memory configuration parameters of the target micro-service.
- 5. The method for recommending micro-service resource allocation according to claim 3, wherein the first CPU performance index comprises a plurality of first CPU usage sampling values of the target micro-service and YGC maximum time consumption in unit time; the inputting the first CPU performance index into the first CPU computing policy to obtain the first CPU configuration parameter includes: Determining a first CPU usage sampling value which can represent the CPU demand level from the plurality of first CPU usage sampling values as a first CPU allocation amount; calculating a third weight coefficient of the first CPU allocation amount based on the YGC maximum time consumption; Weighting the first CPU allocation amount of the first multiple based on the third weight coefficient to obtain a CPU comparison value; Determining a larger value between the CPU comparison value and a preset first fixed CPU usage amount, and determining a smaller value between the larger value and a second multiple of a first CPU allocation amount as a first CPU usage amount upper limit, wherein the first multiple and the second multiple are both larger than 1, the second multiple is larger than the first multiple, and the third weight coefficient is larger than or equal to 1; And taking the first CPU allocation amount and the first CPU usage upper limit as first CPU configuration parameters of the target micro-service.
- 6. The method according to claim 2, wherein when the programming language type is a non-JAVA language, the executing the resource configuration recommendation policy based on the running state information to generate a recommendation result for configuring the resource for the target micro service next time, comprises: Inputting the second memory performance index into the second memory calculation strategy to obtain the second memory configuration parameter; inputting the second CPU performance index into the second CPU calculation strategy to obtain the second CPU configuration parameter; and taking the second memory configuration parameters and the second CPU configuration parameters as the recommendation result.
- 7. The method for recommending micro-service resource allocation according to claim 6, wherein the second memory performance index comprises a plurality of first memory usage sampling values of the target micro-service; The inputting the second memory performance index into the second memory calculation policy to obtain the second memory configuration parameter includes: Determining a first memory usage sampling value capable of representing a memory demand level from the plurality of first memory usage sampling values; Weighting the determined sampling value of the first memory usage based on a preset fourth weight coefficient to obtain a second memory allocation; weighting the second memory allocation amount based on a preset fifth weight coefficient to obtain a second memory usage upper limit, wherein the fourth weight coefficient and the fifth weight coefficient are both larger than 1; and taking the second memory allocation amount and the second memory use amount upper limit as second memory configuration parameters of the target micro-service.
- 8. The method for recommending micro-service resource allocation according to claim 6, wherein the second CPU performance index comprises a plurality of second CPU usage sampling values of the target micro-service; The inputting the second CPU performance index into the second CPU computing policy to obtain the second CPU configuration parameter includes: determining a second CPU usage sampling value which can represent the CPU demand level from the plurality of second CPU usage sampling values as a second CPU allocation amount; determining a larger value between a third multiple of second CPU allocation amount and a preset second fixed CPU usage amount as a second CPU usage amount upper limit, wherein the third multiple is larger than 1; And taking the second CPU allocation amount and the second CPU usage upper limit as second CPU configuration parameters of the target micro-service.
- 9. The micro service resource allocation recommendation method according to claim 1, wherein after said executing the resource allocation recommendation policy based on the running state information to generate a recommendation result for resource allocation of the target micro service next time, the method further comprises: when a deployment signal for redeploying the target micro-service is detected, reading all recommended results generated in a second historical time period; Determining a target recommendation result meeting service stability from all recommendation results; Generating a resource allocation fragment of the target micro-service based on the target recommendation result; intercepting a deployment file of the target micro-service, and writing the resource configuration fragment into the deployment file to redeploy the target micro-service based on a new deployment file.
- 10. The micro-service resource allocation recommendation method of claim 9, wherein after intercepting the deployment file of the target micro-service and writing the resource allocation fragment to the deployment file to redeploy the target micro-service based on a new deployment file, the method further comprises: periodically monitoring resource indexes of the redeployed target micro service in the running period, wherein the resource indexes comprise CPU (central processing unit) utilization rate, JVM (Java virtual machine) heap memory utilization rate and GC (gas chromatography) behavior indexes of the target micro service; calculating a CPU pressure value based on the CPU utilization; calculating a JVM heap memory pressure value based on the JVM heap memory utilization; Based on the GC behavior index, calculating a GC pressure value; calculating a total value of resource pressure of the target micro-service during operation based on the CPU pressure value, the JVM heap memory pressure value and the GC pressure value; When the total value of the resource pressure exceeds a first preset pressure threshold value, increasing the node of the target micro-service; And when the total value of the resource pressure is lower than a second preset pressure threshold value, reducing the nodes of the target micro-service, wherein the first preset pressure threshold value is larger than the second preset pressure threshold value.
- 11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program is for implementing the steps of the method according to any one of claims 1 to 10 when being executed by a processor.
Description
Micro-service resource allocation recommendation method and computer-readable storage medium Technical Field The present invention relates to the field of computer technologies, and in particular, to a method for recommending micro-service resource allocation and a computer readable storage medium. Background The micro service resource allocation schemes widely used at present include the following three. Fixed multiple method, according to unified rule configuration, for example, the JVM memory is set to 70% of the container memory. The method is simple, and the actual running difference of different micro services is not considered at all, so that resource waste or insufficient performance is easily caused. And the static configuration method is to preset a resource rule according to the service type, such as setting a 2GB memory for high frequency transaction service. This approach cannot be reasonably adjusted according to the actual load during operation and the configuration often does not match the actual demand. The manual tuning method is to check the monitoring index by means of expert experience and manually tune. The effect of the method depends on the personal level, the time consumption is long, hundreds of micro services cannot be handled, and the method is difficult to scale. Aiming at the defects that the configuration rules in the prior art are stiff, cannot be intelligently adapted, depend on manpower and are difficult to apply on a large scale, no effective solution exists at present. Disclosure of Invention The invention aims to provide a micro-service resource allocation recommendation method and a computer-readable storage medium, which are used for solving the defects that in the prior art, allocation rules are stiff, intelligent adaptation is not realized, manual work is relied on, and large-scale application is difficult. According to one aspect of the present invention, there is provided a micro-service resource allocation recommendation method, including: Acquiring running state information and running environment information of a target micro-service in a first historical time period; Determining a resource allocation recommendation strategy for the target micro-service based on the running environment information; And executing the resource allocation recommendation strategy based on the running state information to generate a recommendation result for carrying out resource allocation on the target micro-service next time. Optionally, the running environment information comprises a programming language type to which the target micro-service belongs; When the programming language type is JAVA language, the running environment information also comprises a JDK version of the target micro-service; the resource configuration recommendation strategy comprises a JVM prediction model for recommending JVM configuration parameters, a first memory calculation strategy for recommending first memory configuration parameters and a first CPU calculation strategy for recommending first CPU configuration parameters; When the programming language type is a non-JAVA language, the running state information comprises a second memory performance index and a second CPU performance index, and the resource configuration recommendation strategy comprises a second memory calculation strategy for recommending second memory configuration parameters and a second CPU calculation strategy for recommending the second CPU configuration parameters. Optionally, when the programming language type is JAVA, the executing the resource configuration recommendation policy based on the running state information to generate a recommendation result for configuring the resource for the target micro-service next time includes: Inputting the JVM performance index into the JVM prediction model to obtain the JVM configuration parameters, wherein the JVM configuration parameters comprise XMX parameters and XMN parameters; Inputting the first memory performance index into the first memory calculation strategy to obtain the first memory configuration parameter; Inputting the first CPU performance index into the first CPU calculation strategy to obtain the first CPU configuration parameter; when the JDK version is a preset version or is earlier than the preset version, the XMX parameter, the XMN parameter, the first memory configuration parameter and the first CPU configuration parameter are used as the recommendation result; and when the JDK version is later than the preset version, taking the XMX parameter, the first memory configuration parameter and the first CPU configuration parameter as the recommendation result. Optionally, the first memory performance index comprises a plurality of JVM (Java virtual machine) out-of-heap memory usage sampling values and a plurality of JVM thread number sampling values of the target micro-service; The inputting the first memory performance index into the first memory calculation policy to o