Analog simulation method and device for system load

By real-time detection of the system's CPU and memory utilization, adjusting thread pool parameters and resource pre-allocation, the problem of low accuracy of existing load simulation tools is solved, and the precise simulation and simulation of system load is realized, and the stability of the system is improved. reliability.

CN119396583APending Publication Date: 2025-02-07SHAANXI EYINHE ELECTRONICS
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411493670.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

When simulating high loads of existing loads, the existing load simulation tools are not very accurate and complex in operation, making it difficult to truly reflect the performance of the system under high load conditions, affecting the improvement of resource utilization and prevention of resource recycling.

Method used

By obtaining the system's CPU and memory utilization, adjusting the number of threads and cycle frequency in the thread pool according to the preset threshold range and value, and pre-allocating CPU and memory resources in a timely manner to ensure that the system can cope with burst loads.

Benefits of technology

It improves the stability and reliability of the system, realizes accurate simulation and simulation of system load, avoids the problem of resource recovery, and ensures the normal operation of the system under high load conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396583A_ABST
    Figure CN119396583A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of system load simulation, in particular to an analog simulation method and device for a system load. The method comprises the following steps: acquiring a CPU utilization rate of a system; when the CPU utilization rate exceeds a preset range and is smaller than a preset value, the number of loop body threads is increased in a thread pool; when the CPU utilization rate exceeds a preset range and is greater than or equal to the preset value, increasing the cycle frequency of a target thread in the thread pool; and when the cycle period of the target thread is greater than a preset period, interrupting the target thread and moving the target thread out of the thread pool. According to the method, the precision of system load simulation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention generally relates to the field of system load simulation, and more specifically, to a system load simulation method and device. Background Art

[0002] In the K8s cluster system, the ESS (elastic scaling) rule can automatically increase ECS instances to ensure computing power when business demand increases, and automatically reduce ECS instances to save costs when business demand decreases. After resource utilization is optimized and resources are recycled, in order to ensure the normal availability of system business functions and the normal operation of the system, it is necessary to use tools to simulate high-load application scenarios of the system. At the same time, in some specific application environments, it is necessary to avoid the problem of resource recycling due to low resource utilization, and it is also necessary to use tools to simulate high system load. However, existing load simulation tools often have problems such as low simulation accuracy and complex operation, which make it difficult to truly reflect the performance of the system under high load conditions, thereby affecting the improvement of resource utilization and the prevention of resource recycling. Summary of the invention

[0003] In order to solve the technical problem of low accuracy in the above-mentioned system load simulation, the present invention provides solutions in the following aspects.

[0004] In a first aspect, the present invention provides a method for simulating a system load, wherein the system load includes a CPU load and a memory load, and comprises: obtaining the CPU utilization of the system; when the CPU utilization exceeds a preset range and is less than a preset value, increasing the number of loop threads in a thread pool; when the CPU utilization exceeds a preset range and is greater than or equal to the preset value, increasing the loop frequency of a target thread in the thread pool; when the loop period of a target thread in the thread pool is greater than a preset period, interrupting the target thread and removing the target thread from the thread pool.

[0005] Further, increasing the cycle frequency of the target thread in the thread pool includes: when the cycle period of the target thread is less than or equal to a preset period, increasing the cycle period of the target thread.

[0006] Furthermore, the preset period is 2s, and the cycle period increases by 100ms each time.

[0007] Furthermore, obtaining the CPU utilization of the system includes: obtaining the CPU utilization by introducing an Oshi library.

[0008] Furthermore, it also includes: obtaining the memory usage of the system; when the memory usage exceeds the preset memory range and is lower than the memory preset value, determining the size of the target memory, creating and referencing the data occupying the target memory; when the memory usage exceeds the preset memory range and is higher than the memory preset value, reducing the memory value of the simulation data.

[0009] Furthermore, it also includes: restarting the service regularly through Cron expressions.

[0010] Further, in response to receiving an instruction of a priority set by a user, the order of the CPU load simulation and the memory load simulation is adjusted.

[0011] In a second aspect, the present invention provides a system load simulation device, comprising a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a system load simulation method according to any one of the first aspects is implemented.

[0012] The beneficial effects of the present invention are: by real-time detection of the CPU usage of the system, when the CPU utilization is lower than a preset threshold, the CPU resources are automatically pre-allocated to ensure that the system can cope with sudden loads, thereby improving the stability and reliability of the system. By real-time detection of the memory usage of the system, when the memory utilization is lower than a preset value, the memory is automatically pre-allocated to ensure that the system can cope with sudden loads. In addition, by setting the corresponding threshold range and preset value according to the actual application environment and requirements, accurate simulation and emulation of the system load is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] By reading the following detailed description with reference to the accompanying drawings, the above and other objects, features and advantages of the exemplary embodiments of the present invention will become readily understood. In the accompanying drawings, several embodiments of the present invention are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:

[0014] Figure 1 The figure schematically shows a method for simulating a system load according to an embodiment of the present invention, wherein a CPU load simulation is shown;

[0015] Figure 2 The figure schematically illustrates a method for simulating a system load according to an embodiment of the present invention, wherein a memory load simulation is illustrated;

[0016] Figure 3 is a structural diagram schematically showing a simulation device according to an embodiment of the present invention;

[0017] Figure 4FIG. 4 is a diagram schematically showing a partial result of an analysis report according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.

[0019] The specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0020] Figure 1 FIG. 4 schematically illustrates a method for simulating a system load according to an embodiment of the present invention.

[0021] In a first aspect, the present invention provides a method for simulating a system load, such as Figure 1 As shown, the method includes the following process.

[0022] Obtaining the CPU utilization of the system In one embodiment, the CPU utilization in the configuration file can be read by introducing the Oshi library (a system information library for the Java language).

[0023] Further, it is determined whether the CPU utilization of the system is within the configured threshold range (i.e., the preset range). If so, it indicates that the system does not need CPU load simulation; if not, it indicates that the system needs to perform CPU load simulation. Specifically, when performing CPU load simulation, it is determined whether the CPU utilization of the current system is less than the preset value. If so, the number of loop body threads in the thread pool is increased to improve the CPU utilization; if not, the loop frequency of the target thread in the thread pool is increased. Specifically, first, the first thread (i.e., the target thread) in the thread pool is obtained, and then it is determined whether the loop period of the target thread is greater than the preset period. If not, the loop period of the target thread is increased to reduce the CPU utilization. Further, if the loop period of the target thread is greater than the preset period, the target thread is interrupted and the target thread is removed from the thread pool. At the same time, the next target thread is obtained, and then the above judgment is performed again.

[0024] In this embodiment, the added loop body thread is a computationally intensive task, which is an infinite loop that supports interruption and modification of loop frequency.

[0025] In one embodiment, the preset period is 2s, and the cycle period increases by 100ms each time. In other optional embodiments, those skilled in the art can set the preset period and the period increased each time according to actual needs.

[0026] It is understandable that when the cycle period of the target thread exceeds 2s, it indicates that the target thread has no significant effect on reducing the CPU utilization, so it is interrupted and removed from the thread pool. In addition, when configuring the threshold range and preset value, the user can set it according to the actual application scenario and needs, so as to achieve accurate and efficient simulation of the CPU load. For example, during the actual operation of the user's system, the CPU utilization rate has always been low. When configuring the threshold range and preset value, the threshold range can be set relatively low, for example, set to 30% to 40%, and the preset value can be set to 25%. When the CPU utilization exceeds the threshold range, an alarm can be issued to remind the user to perform corresponding resource allocation processing.

[0027] By interrupting and removing the target thread that exceeds the preset period from the thread pool, the target thread is prevented from continuing to occupy system resources, so that the CPU can be better allocated to other more efficient threads, thereby improving the operating efficiency of the entire system. Furthermore, it can also free up resources for other tasks, achieve optimal resource allocation, and ensure the effect of system load simulation. In addition, long-running and inefficient threads may cause system performance degradation or even deadlock problems. By interrupting and removing them from the thread pool, potential risks can be reduced and the stability and reliability of the system can be enhanced.

[0028] Furthermore, the method of the present invention also includes memory load simulation, specifically, as follows: Figure 2 As shown, first, the memory utilization of the system is obtained. In one embodiment, the memory utilization in the configuration file can be read by introducing the Oshi library. Further, it is determined whether the current system memory utilization is within the configured threshold range (i.e., the preset memory range). If so, it indicates that the system does not need memory load simulation. If not, it indicates that the system needs memory load simulation. Specifically, during the memory load simulation, it is determined whether the memory utilization is less than the preset memory value. If so, the memory value to be occupied is calculated, and then data of the size of the memory value is created and kept referenced to improve memory utilization; if not, the simulated memory data is cleared to reduce memory utilization.

[0029] It is understandable that users can customize the corresponding threshold range and memory preset value according to the actual application scenario and needs, so that the simulated CPU utilization and memory utilization are consistent with the pre-configured ones, thereby achieving accurate and efficient simulation of memory load.

[0030] In one embodiment, when reducing memory utilization, since the garbage collection mechanism of JVM (Java virtual machine) is not directly controlled by the program (it is impossible to accurately specify when to perform garbage collection), the program can only let the garbage collector try to give priority to reclaiming the simulated memory. Therefore, when the memory utilization is higher than the preset memory value, the occupied memory will not be immediately recycled. At this time, the service can be restarted regularly to recalculate the increased memory to the specified value to achieve the reduction of the simulated memory value, thereby preventing memory overflow or resource waste. Specifically, the timing cycle can be set by Cron expression (an expression for timing execution of tasks) to achieve the timing restart task. By restarting the service regularly (for example, restarting when the business is idle), all memory resources can be forced to be released to avoid the accumulation of memory problems. In addition, it can also avoid the abnormal problem that resources are not being used, but the resource utilization rate is high, thereby ensuring the reliability and stability of the system.

[0031] Furthermore, during configuration, the target value of application.yml (a configuration file) is set within an appropriate range to avoid the problem that a target value that is too large affects the performance of existing normal services.

[0032] Furthermore, in response to receiving an instruction of a priority set by the user, the order of CPU simulation and memory simulation is adjusted. By allowing the user to set the priority of different resource simulations according to business needs and business types (for example, if the video business occupies a relatively high CPU, the priority of CPU load simulation is higher than that of memory load simulation), critical resources are avoided from being recycled. In addition, the order of CPU load simulation and memory load simulation can also be automatically adjusted. Specifically, if it is applied in a database management system, since a large amount of data needs to be stored in the memory for processing, the priority of memory load simulation should be higher than that of CPU load simulation; if it is applied in computing-intensive tasks and systems with real-time requirements, such as graphics rendering, aerospace, etc., the priority of CPU load simulation is higher than that of memory load simulation, and the priority of system load simulation can be flexibly changed according to actual needs.

[0033] By simulating the system load, we can verify whether the system can operate normally under different load conditions and whether the system business functions are available normally, so as to make corresponding adjustments and optimizations based on the simulation results to improve the stability and reliability of system operation. Furthermore, by accurately simulating the high-load application of the business system according to the actual application environment and needs, we can improve resource utilization and avoid cluster resource recycling.

[0034] It can be understood that the method of the present invention can be applied in cluster systems such as Huawei Cloud CCE and Alibaba Cloud ACK. The HPA (Horizontal Pod Autoscaling) in the cluster system can realize the automatic expansion and contraction of Pod (the smallest deployable and manageable computing unit). For example, when the business load in the Pod increases, a new Pod can be created to ensure the stable operation of the business system. When the business load in the Pod decreases, the Pod can be destroyed to improve resource utilization. Therefore, the method of the present invention can simulate the system load through HPA, thereby improving resource utilization. Specifically, HPA monitors the CPU utilization and memory utilization, determines the change of business load, and then dynamically adjusts the number of Pods. For example, when the CPU utilization rate is continuously higher than 80%, the number of Pods will be automatically increased, that is, a new Pod will be created and scheduled to a suitable node, or the Pod will be transferred from a node with high CPU utilization to a node with low CPU utilization; when the CPU utilization rate is continuously lower than 30%, the number of Pods will be automatically reduced (that is, some Pods will be destroyed).

[0035] Through CPU load simulation and memory load simulation, when the system resource utilization rate is relatively low for a long period of time (for example, some emergency systems will only be used in emergencies), the applied cluster resources will be recycled to avoid them occupying resources all the time and causing waste. However, when the business is in peak use, the system cluster resources cannot meet the demand. At this time, it is necessary to reapply for resources. However, the process of reapplying for resources is relatively complicated and inefficient. Through the CPU load simulation and memory load simulation of the present invention, the continuous occupancy rate of system resources can be maintained. For example, when the resource utilization rate is low, the corresponding system load simulation is performed to keep it within the set range, thereby avoiding the recycling of system cluster resources and avoiding the problem of needing to reapply for resources, ensuring the stability and reliability of the system.

[0036] To sum up, during the system load simulation process, by analyzing the system performance data (CPU utilization, memory utilization), the bottleneck links with low resource utilization are identified, and targeted optimization strategies (CPU load simulation, memory load simulation) are proposed to improve the system's resource utilization, thereby ensuring that the system can give full play to its performance advantages during peak load periods.

[0037] In one embodiment, the method of the present invention can also perform server failure experiments on multiple server nodes in the same k8s cluster at the same time to verify the stability of the software system in the cluster.

[0038] Figure 3 FIG. 4 is a block diagram schematically showing a structure of a system load simulation device according to the present embodiment.

[0039] In a second aspect, the present invention also provides a system load simulation device. Figure 3 As shown, the system includes a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a system load simulation method according to the first aspect of the present invention is implemented.

[0040] The device also includes other components well known to those skilled in the art, such as a communication interface, and the configuration and functions of the components are known in the art, so they will not be described in detail here.

[0041] Specifically, in practical applications, the user can use the device of the present invention to simulate the system load through the following steps.

[0042] S101, setting simulation parameters. Specifically, the user can set simulation parameters in the user interface according to actual needs. In one embodiment, the simulation parameters include load type (CPU load, memory load), load intensity, simulation duration, etc.

[0043] S102, start simulation. The device of the present invention simulates the system load in the simulation link according to the set simulation parameters.

[0044] S103, output analysis report. During the simulation process, the device of the present invention monitors the system performance data in real time, and outputs an analysis report after the simulation is completed. The user can understand the performance of the system under different load conditions through the analysis report, and make corresponding adjustments and optimizations according to the performance. Figure 4 As shown in the figure, the output report includes CPU utilization and memory utilization. Users can confirm whether the CPU utilization and memory utilization are correct by analyzing the report.

[0045] In the present invention, the aforementioned memory may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus or device. For example, a computer-readable storage medium may be any suitable magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc., or any other medium that may be used to store the required information and may be accessed by an application, a module, or both. Any such computer storage medium may be part of a device or accessible or connectable to a device. Any application or module described in the present invention may be implemented using computer-readable / executable instructions that may be stored or otherwise maintained by such a computer-readable medium.

[0046] In the description of this specification, "plurality" or "several" means at least two, such as two, three or more, etc., unless otherwise clearly and specifically defined.

[0047] Although this specification has shown and described a number of embodiments of the present invention, it will be apparent to those skilled in the art that such embodiments are provided by way of example only. Those skilled in the art will conceive of many modifications, changes and alternatives without departing from the ideas and spirit of the present invention. It should be understood that in the practice of the present invention, various alternatives to the embodiments of the present invention described herein may be employed.

Claims

1. A method for simulating system load, wherein the system load includes CPU load and memory load, characterized in that: include: Get the system's CPU utilization; When the CPU utilization exceeds a preset range and is less than a preset value, the number of loop body threads is increased in the thread pool; When the CPU utilization exceeds a preset range and is greater than or equal to the preset value, increasing the cycle frequency of the target thread in the thread pool; When the cycle period of the target thread is greater than a preset period, the target thread is interrupted and removed from the thread pool.

2. The system load simulation method according to claim 1, characterized in that: Increasing the cycle frequency of the target thread in the thread pool, including: When the cycle period of the target thread is less than or equal to a preset period, the cycle period of the target thread is increased.

3. The system load simulation method according to claim 2, characterized in that: The preset period is 2s, and the cycle period increases by 100ms each time.

4. The system load simulation method according to claim 1, characterized in that: Obtaining the CPU utilization of the system, including: obtaining the CPU utilization by introducing an Oshi library.

5. The system load simulation method according to claim 1, characterized in that: Also includes: Get the system's memory usage; When the memory usage rate exceeds a preset memory range and is less than a preset memory value, determining the size of a target memory, and creating and referencing data occupying the target memory; When the memory usage exceeds a preset memory range and is greater than or equal to the preset memory value, the memory value of the simulation data is reduced.

6. The system load simulation method according to claim 5, characterized in that: Also includes: Use Cron expressions to periodically restart services.

7. The system load simulation method according to claim 5, characterized in that: In response to receiving an instruction of a priority set by a user, the order of the CPU load simulation and the memory load simulation is adjusted.

8. A system load simulation device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, a system load simulation method according to any one of claims 1 to 7 is implemented.

Citation Information

Cited By

  • Method, system and device for realizing resource adaptive pressure test based on load scaling, processor and readable storage medium thereof

    CN121935168A