Memory management method and device, electronic equipment and storage medium

By monitoring the container memory usage and growth trend in real time, combining the network latency difference value, and dynamically adjusting the memory management strategy, the memory overflow lag problem in Kubernetes clusters is solved, and the effect of preventing memory overflow and relieving stress is achieved in advance.

CN120508351AActive Publication Date: 2025-08-19INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510994912.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-18
Publication Date
2025-08-19
Estimated Expiration
2045-07-18

AI Technical Summary

Technical Problem

In Kubernetes cluster, when container service memory overflows, conventional solutions have lag, causing cluster crashes and failing to relieve memory pressure in time.

Method used

By collecting container memory usage and growth trends, predicting memory alarm levels, and based on the expansion capacity and network latency difference, it is decided to expand or migrate containers on the current node or candidate node, including modifying the memory limit value and creating cloned containers.

Benefits of technology

Without affecting the normal operation of the cluster, prevent memory overflow in advance, effectively alleviate memory pressure, and avoid cluster crashes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120508351A_ABST
    Figure CN120508351A_ABST
Patent Text Reader

Abstract

The invention discloses a memory management method and device, electronic equipment and a storage medium, and relates to the technical field of computers.The method comprises the steps that the memory alarm level of a current container is predicted according to the memory utilization rate and the memory growth trend; when the memory alarm level is a first alarm level, determining whether expansion is carried out on the current node or expansion and migration are carried out on the candidate nodes according to the final expansion amount of the current container and the network delay difference values between the current node and the candidate nodes; the technical problem of hysteresis of a memory overflow solution in related technologies is solved, and the technical effects of preventing memory overflow in advance and effectively relieving memory pressure are achieved while normal operation of a cluster is not affected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a memory management method, device, electronic device, and storage medium. Background Art

[0002] In a Kubernetes cluster (an open-source container orchestration engine), when the memory usage of a container service exceeds the configured value, that is, when the container reaches out-of-memory status, the container will be unable to provide services for a short period of time. Furthermore, because other services in the cluster are still running, restarting services immediately to alleviate memory pressure is not possible; otherwise, the entire cluster will crash. Therefore, conventional solutions to out-of-memory issues often have a certain delay. Summary of the Invention

[0003] The present application provides a memory management method, device, electronic device and storage medium to at least solve the problem of lag in memory overflow solutions in related technologies.

[0004] This application provides a memory management method, which includes: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and the candidate node are obtained. The target node for memory management is determined based on the final expansion capacity and the network delay difference. The current node is the node where the current container is located, and the candidate node is the node other than the current node in the cluster. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0005] The present application also provides a memory management device, the memory management device comprising: The container status monitoring module is used to collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; A memory pressure analysis module is used to determine the memory alarm level of the current container based on the memory usage rate and memory growth trend, where the memory alarm level includes at least the first alarm level; The cluster resource scheduling module is used to obtain the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes if the memory alarm level is the first alarm level, and determine the target node that needs memory management based on the final expansion capacity and network delay difference, where the current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node; The container operation execution module is used to modify the memory limit value of the current container according to the final expansion capacity if the target node is the current node; if the target node is a candidate node, create a clone container of the current container on the target node according to the final expansion capacity and delete the current container.

[0006] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing a memory management method comprising at least the following steps when executing the computer program: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0007] The present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, at least a memory management method comprising the following steps is implemented: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0008] The present application also provides a computer program product, including a computer program, which, when executed by a processor, implements at least a memory management method comprising the following steps: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0009] Through this application, the memory alarm level of the current container is predicted based on the memory usage rate and memory growth trend; when the memory alarm level is the first alarm level, based on the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes, it is determined whether to expand the capacity on the current node or to expand and migrate the capacity on the candidate nodes. This solves the technical problem of lag in memory overflow solutions in related technologies, and achieves the technical effect of preventing memory overflow in advance and effectively alleviating memory pressure without affecting the normal operation of the cluster. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0011] Figure 1 1 is a flow chart of a memory management method according to an embodiment; Figure 2 is a structural block diagram of a memory management device in one embodiment; Figure 3 FIG. 1 is a diagram showing the internal structure of an electronic device in one embodiment. DETAILED DESCRIPTION

[0012] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0013] It should be noted that, in the description of this application, the terms "comprises," "includes," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. The terms "first," "second," etc., in this application are used to distinguish similar objects, and are not used to describe a particular order or sequence.

[0014] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below with reference to the accompanying drawings and specific implementation methods.

[0015] In one embodiment, Figure 1 As shown, a memory management method is provided, and the memory management method includes: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0016] Specifically, the memory alarm level of the current container is predicted based on the memory usage rate and memory growth trend; when the memory alarm level is the first alarm level, based on the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes, it is determined whether to expand the capacity on the current node or to expand and migrate the capacity on the candidate nodes. This solves the technical problem of lag in memory overflow solutions in related technologies, and achieves the technical effect of preventing memory overflow in advance and effectively alleviating memory pressure without affecting the normal operation of the cluster.

[0017] In a specific implementation, the preset time period is set to 5 minutes, and the memory usage of the current container over the last 5 minutes is collected in real time at a sampling frequency of 500ms. The memory growth trend can be obtained by calculating the memory usage slope between the first and last time points. For example, if the memory usage is 70% at the first time point and 80% at the last time point, and the time difference between the first and last time points is 5 minutes, the memory usage slope is (80% - 70%) / 5 = 2% / min. Alternatively, the memory usage slope can be calculated by calculating the memory usage slope between the last time point and the previous time point. For example, if the memory usage is 80% at the last time point and 30% at the previous time point, and the time difference between the last and previous time points is 500ms, the memory usage slope is (80% - 30%) / 500ms = 0.1% / ms.

[0018] In specific implementations, if the target node is the current node, the online capacity expansion mechanism is triggered, dynamically modifying the container's memory limit through the container runtime interface and / or updating the replica configuration through the container's automatic horizontal scaling. If the target node is a candidate node, a cloned container instance is created on the target node based on the final capacity expansion and the current container is deleted. Memory snapshots are saved using CRIU (Checkpoint / Restore In Userspace), a tool that implements process checkpointing and recovery in user space. A double-buffered switching mechanism is used to ensure service continuity, and the traffic switching time window is generally controlled within 200ms.

[0019] Furthermore, based on the memory usage and memory growth trend, the memory alarm level of the current container is determined, including: Determine an initial memory alarm level for the current container based on a relationship between the memory usage and a preset threshold, where the preset threshold includes at least a first threshold, a second threshold, and a third threshold, and the first threshold is greater than the second threshold, and the second threshold is greater than the third threshold; A final memory alarm level of the current container is determined according to the initial memory alarm level and the memory growth trend, wherein the memory growth trend includes at least a first state, a second state, and a third state.

[0020] Specifically, after determining the initial memory alarm level of the current container based on the relationship between memory usage and the preset threshold, the final memory alarm level of the current container is further determined in combination with the memory growth trend, thereby achieving the effect of predicting the container memory alarm level for subsequent capacity expansion.

[0021] In practice, cAdvisor (Container Advisor), an open-source tool for monitoring and analyzing container performance, is integrated to collect real-time data on core metrics such as container memory usage, working set size, and anonymous page usage. The sampling frequency can be configured to 500ms. The system analyzes memory growth trends within the last 5 minutes or a 5-minute sliding window, and constructs a multi-dimensional feature vector based on the container resource object values provided by the containerized service's memory subsystem.

[0022] In specific implementations, the first threshold is set at 90%, the second at 85%, and the third at 80%. The second threshold serves as the base threshold, representing the container's memory usage warning line. It can be dynamically adjusted based on historical load patterns over the same period, with an adaptive adjustment range of ±5%. The first threshold serves as the emergency threshold. When the container's memory usage is greater than or equal to the first threshold, pre-allocated swap partitions are used to alleviate memory pressure.

[0023] In specific implementations, the memory usage rate 1 minute later can be predicted based on the memory usage slope between the first and last time points in the last 5 minutes, or based on the memory usage slope between the last and previous time points in the last 5 minutes, and then the final memory alarm level of the current container can be determined based on the memory usage rate 1 minute later.

[0024] In a specific implementation, the memory usage between a range of greater than or equal to the first threshold and less than or equal to the maximum value is used as the first threshold segment, the memory usage between a range of greater than or equal to the second threshold and less than the first threshold is used as the second threshold segment, the memory usage between a range of greater than or equal to the third threshold and less than the second threshold is used as the third threshold segment, and the memory usage between a range of greater than or equal to the minimum value and less than the third threshold is used as the fourth threshold segment. The maximum value can be set to any number between greater than 90% and less than or equal to 100%, and the minimum value can be set to any number between greater than or equal to 0% and less than 80%. If the memory usage rate predicted at 1 minute in the future based on the memory usage slope is greater than the memory usage rate at the last time point within the last 5 minutes, and the threshold segment of the memory usage rate changes, the memory growth trend is determined to be the first state; if the memory usage rate predicted at 1 minute in the future based on the memory usage slope is the same as the threshold segment of the memory usage rate at the last time point within the last 5 minutes, the memory growth trend is determined to be the second state; if the memory usage rate predicted at 1 minute in the future based on the memory usage slope is less than the memory usage rate at the last time point within the last 5 minutes, and the threshold segment of the memory usage rate changes, the memory growth trend is determined to be the third state.

[0025] That is, if the memory usage at the last time point within the last 5 minutes is within the second threshold range, and the memory usage slope predicts that the memory usage will be within the first threshold range one minute into the future, then the memory alarm level of the current container is determined to be the first alarm level. If the memory usage at the last time point within the last 5 minutes is within the second threshold range, and the memory usage slope predicts that the memory usage will be within the second or third threshold range one minute into the future, then the memory alarm level of the current container is determined to be the second alarm level. Similarly, based on the memory usage at the last time point within the last 5 minutes and the memory usage one minute into the future, it is determined whether the memory alarm level of the current container is the third alarm level and / or the fourth alarm level.

[0026] Furthermore, based on the relationship between the memory usage and the preset threshold, the initial memory alarm level of the current container is determined, including: If the memory usage is greater than or equal to the first threshold, determining that the initial memory alarm level of the current container is the first alarm level; If the memory usage is greater than or equal to the second threshold and less than the first threshold, determining the initial memory alarm level of the current container to be the second alarm level, wherein the second alarm level is less than the first alarm level; If the memory usage is greater than or equal to the third threshold and less than the second threshold, determining the initial memory alarm level of the current container to be the third alarm level, wherein the third alarm level is less than the second alarm level; If the memory usage is less than the third threshold, the initial memory alarm level of the current container is determined to be a fourth alarm level, where the fourth alarm level is less than the third alarm level.

[0027] Specifically, an initial memory alarm level of the current container is determined according to the first threshold, the second threshold, and the third threshold, so that a final memory alarm level of the current container is subsequently determined in combination with a memory growth trend.

[0028] In the specific implementation, if the memory usage rate is less than 80%, the container is in a normal state and the memory alarm level at this time is the fourth alarm level, and no special processing is performed; if the memory usage rate is greater than or equal to 80% and less than 85%, the container is in a warning state and the memory alarm level at this time is the third alarm level, triggering a general alarm to the system administrator, but no special processing is performed; if the memory usage rate is greater than or equal to 85% and less than 90%, the container is in a serious alarm state and the memory alarm level at this time is the second alarm level, prompting the system administrator to handle it according to needs, such as releasing the memory of the corresponding service according to actual needs; if the memory usage rate is greater than or equal to 90%, the container is in an emergency alarm state and the memory alarm level at this time is the first alarm level, triggering mechanisms such as expansion demand calculation.

[0029] Furthermore, based on the initial memory alarm level and the memory growth trend, the final memory alarm level of the current container is determined, including: If the initial memory alarm level is the first alarm level, then determine that the final memory alarm level of the current container is the first alarm level; If the initial memory alarm level is the second alarm level and the memory growth trend is the first state, the final memory alarm level of the current container is determined to be the first alarm level; If the initial memory alarm level is the second alarm level and the memory growth trend is the second state or the third state, the final memory alarm level of the current container is determined to be the second alarm level; If the initial memory alarm level is the third alarm level and the memory growth trend is the first state, the final memory alarm level of the current container is determined to be the second alarm level; If the initial memory alarm level is the third alarm level and the memory growth trend is the second or third state, the final memory alarm level of the current container is determined to be the third alarm level; If the initial memory alarm level is the fourth alarm level and the memory growth trend is the first state, the final memory alarm level of the current container is determined to be the third alarm level; If the initial memory alarm level is the fourth alarm level and the memory growth trend is the second state or the third state, the final memory alarm level of the current container is determined to be the fourth alarm level.

[0030] Specifically, based on the initial memory alarm level, the final memory alarm level of the current container is determined in combination with the memory growth trend, so as to predict the memory pressure of the current container and prevent memory overflow through expansion and / or migration.

[0031] Furthermore, the final expansion capacity of the current container is obtained, including: Obtain the memory request amount of the current container, and obtain the baseline expansion capacity of the current container based on the first expansion coefficient and the memory request amount; Obtain the available memory of the cluster, the available memory of the current node, and the service quality level of the container group where the current container is located, and determine the second expansion factor of the current container based on the available memory of the cluster, the available memory of the current node, and the service quality level of the container group where the current container is located; The final expansion capacity of the current container is obtained according to the second expansion coefficient and the benchmark expansion capacity.

[0032] Specifically, based on the memory request amount and the first expansion coefficient, the final expansion capacity is calculated in combination with the second expansion coefficient, so that the calculation of the final expansion capacity is more accurate.

[0033] In a specific implementation, the available memory amount may refer to the remaining unused memory amount, and the memory request amount refers to the memory amount requested when the program is running. The first expansion coefficient may be set to a fixed value of 1.5. In this case, the baseline expansion capacity = memory request amount × 1.5.

[0034] Furthermore, according to the available memory of the cluster, the available memory of the current node, and the quality of service level of the container group in which the current container is located, a second expansion coefficient of the current container is determined, including: Get the resource adequacy factor of the current container based on the available memory of the cluster and the available memory of the current node; Comparing the resource sufficiency factor with the service quality level; If the resource abundance factor is greater than or equal to the service quality level, the service quality level is determined to be the second expansion coefficient of the current container; If the resource abundance factor is less than the service quality level, the resource abundance factor is determined as the second expansion coefficient of the current container.

[0035] Specifically, the minimum value between the resource abundance factor and the service quality level is determined as the second expansion factor to achieve a balance between security and priority when allocating resources. For example, to prevent overexpansion: even if the resource abundance factor is 10, indicating high resource abundance, it will be limited by the service quality level priority weight, preventing services with low service quality levels from occupying too many resources; to protect high-priority services: even if the resource abundance factor is 1, indicating low resource abundance, services with higher service quality levels can still obtain more resources; to prevent resource contention: when cluster resources are insufficient, the expansion needs of services with low service quality levels are prioritized.

[0036] In specific implementations, the resource abundance factor = the total available memory of the cluster / the available memory of the current node. The service priority weight depends on the service quality level of the container group to which the container belongs. The final expansion capacity = baseline expansion capacity × min (resource abundance factor, service priority weight).

[0037] In specific implementation, the service quality levels include at least guaranteed, burstable and best-effort. Guaranteed: each container is set with the minimum amount of resources required for normal operation and the maximum amount of resources allowed to be used by the container, and the two values are equal. The maximum amount of resources allowed to be used by the container is the memory limit value; Burstable: the container is set with the minimum amount of resources and the memory limit value, but the two values are not equal. Generally, the minimum amount of resources is smaller than the memory limit value; Best-effort: the container does not have a minimum amount of resources and a memory limit value.

[0038] In a specific implementation, the priority weight value of the guaranteed type is greater than the priority weight value of the burstable type, and the priority weight value of the burstable type is greater than the priority weight value of the best-effort type. For example, the priority weight value of the guaranteed type is set to 1.2, the priority weight value of the burstable type is set to 1.0, and the priority weight value of the best-effort type is set to 0.8.

[0039] Furthermore, the target nodes requiring memory management are determined based on the final expansion capacity and the network delay difference, including: Obtain the available memory threshold based on the preset ratio and final expansion capacity; Compare the available memory of the current node with the available memory threshold; If the available memory of the current node is greater than the available memory threshold, the current node is determined to be the target node; If the available memory of the current node is less than or equal to the available memory threshold, the target node is determined from multiple candidate nodes based on the network delay difference.

[0040] Specifically, if the current node meets the expansion conditions, expansion is prioritized on the current node; if the current node does not meet the expansion conditions, the target node for migration is determined from multiple candidate nodes. This allows for dynamic adaptation to resource demands while minimizing service interruptions.

[0041] In practice, the preset ratio can be set to 120%, and the available memory threshold = final expansion capacity × 120%. Obtain a resource view of each node in the cluster and use an affinity algorithm to calculate the optimal migration and expansion node: Step 1: If the current node's available memory is greater than the available memory threshold, prioritize the original node.

[0042] Furthermore, according to the network delay difference, a target node is determined from multiple candidate nodes, including: Obtain available memory amounts of multiple candidate nodes, and compare the available memory amounts of the multiple candidate nodes with available memory amount thresholds respectively; If the available memory of the current candidate node is greater than the available memory threshold, the current candidate node is determined as the first candidate node, and the network delay differences between the current node and the multiple first candidate nodes are compared with the network delay threshold respectively; If the network delay differences between the current node and multiple first candidate nodes are all greater than or equal to the network delay threshold, then sort the multiple first candidate nodes in ascending order according to the network delay differences, and select the first candidate node ranked first as the target node; If the network delay difference between the current node and the current first candidate node is less than the network delay threshold, the current first candidate node is determined as the second candidate node; Obtaining the availability zone information of the plurality of second candidate nodes and the availability zone information of the current node, and comparing the availability zone information of the plurality of second candidate nodes with the availability zone information of the current node respectively; If the availability zone information of the current second candidate node is the same as the availability zone information of the current node, the current second candidate node is determined as the third candidate node; Sort multiple third candidate nodes in ascending order according to the network delay difference, and select the third candidate node ranked first as the target node; If the availability zone information of multiple second candidate nodes is different from the availability zone information of the current node, the multiple second candidate nodes are sorted from small to large according to the network delay difference, and the second candidate node ranked first is used as the target node.

[0043] Specifically, when the network delay difference is less than the network delay threshold, selecting a node in the same availability zone generally reduces cross-zone traffic costs while maintaining low latency. If the network delay difference is greater than or equal to the network delay threshold, or if the network delay difference is less than the network delay threshold but there are no candidate nodes in the same availability zone as the current node, the cross-zone candidate node with the smallest network delay difference is selected to maintain low latency.

[0044] In a specific implementation, the network delay threshold can be set to 5ms, and the optimal migration and expansion node can be calculated through the affinity algorithm: Step 2, if the network delay difference is less than the network delay threshold, the node with the smallest network delay difference is selected from the nodes in the same availability zone as the current node as the target node; Step 3, if the network delay difference is greater than or equal to the network delay threshold, or the network delay difference is less than the network delay threshold, but there is no candidate node in the same availability zone as the current node, the node with the smallest network delay difference is selected from the candidate nodes as the target node.

[0045] In this specific embodiment, container X is selected as the monitoring target, with a memory limit of 4GB. Container X's memory usage is sampled at a 500ms sampling frequency, retaining the most recent 5 minutes of data. Based on the memory growth trend over the past 5 minutes, memory usage is predicted for the next 1 minute. When memory usage reaches 95%, cluster resource scheduling is triggered.

[0046] If the current memory request is 2GB, the cluster's available memory is 100GB, the current node's available memory is 20GB, and the QoS weight of the container group containing the current container is 1.2, then the baseline expansion capacity is 3GB, the resource abundance factor is 5, the final expansion capacity is 3.6GB, and the available memory threshold is 4.32GB. Since 4.32GB is less than 20GB, the current container is expanded and the memory limit is changed to 7.6GB.

[0047] If the current memory request is 1GB, the cluster's available memory is 10GB, the current node's available memory is 2GB, and the QoS weight of the container group containing the current container is 1.2, then the baseline capacity expansion is 1.5GB, the resource abundance factor is 5, the final capacity expansion is 1.8GB, and the available memory threshold is 2.16GB. Because 2.16GB is larger than 2GB, the current container is cloned on the target node, the memory limit is modified to 5.8GB, and the node is restarted. After all business data is suspended, the current container is deleted and the cloned container is allowed to start successfully.

[0048] In a specific embodiment, in a high-availability environment, resource data from other nodes is prioritized, and containers created on the same node are avoided as much as possible. This allows suspended services to run more smoothly. When the cloned container is restarted, the current container is deleted and data on all nodes is updated. After the data update is complete, an alarm recovery notification is sent to the system administrator.

[0049] In a specific embodiment, if it is in a stand-alone environment, when available resources are insufficient, an alarm message is sent to the system administrator, and the service is restarted. At the same time, all logs are sent to the specified service directory for storage so that maintenance personnel can find the problem. After the restart is completed, an alarm recovery notification is sent to the system administrator.

[0050] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0051] In one embodiment, Figure 2 As shown, a memory management device is provided, the memory management device comprising: The container status monitoring module is used to collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; A memory pressure analysis module is used to determine the memory alarm level of the current container based on the memory usage rate and memory growth trend, where the memory alarm level includes at least the first alarm level; The cluster resource scheduling module is used to obtain the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes if the memory alarm level is the first alarm level, and determine the target node that needs memory management based on the final expansion capacity and network delay difference, where the current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node; The container operation execution module is used to modify the memory limit value of the current container according to the final expansion capacity if the target node is the current node; if the target node is a candidate node, create a clone container of the current container on the target node according to the final expansion capacity and delete the current container.

[0052] In a specific embodiment, the device is connected to the control plane of the container orchestration platform through a real-time data bus, and establishes a two-way communication channel with the underlying container runtime interface. The architecture adopts a plug-in design.

[0053] In practice, the cluster resource scheduling module allocates data to services that require expansion and reclaims data that has already been expanded. The allocated memory space must ensure the normal operation of the services. Once the predicted container memory overflow issue is alleviated, if subsequent memory usage drops below 80% and does not increase above 80% within the next minute, the expanded memory is released to ensure sufficient memory for other available services. The monitoring duration for expanded containers is set to 30 minutes, and memory reclaim is triggered if memory usage drops below 80% within 30 minutes.

[0054] In a specific implementation, for the current container, if a clone container of the current container is created on the target node, the container operation execution module will gradually take the current container offline, remove the current container instance from the service discovery registration center, and restart the current container after waiting for the ongoing request to be completed. The maximum waiting time is 30s. For the created clone container, after applying for a new resource quota, the clone container instance is started, and the memory preheating technology is used to load the commonly used data set. At the same time, the health status of the clone container instance is verified, and the health status is synchronized to the service grid. If the expansion fails, a rollback operation is performed. Among them, the triggering condition for the rollback operation is that the resource allocation time is greater than 15s or the health status verification fails. The rollback operation specifically includes: 1. Release the applied resources; 2. Restore the original configuration version; 3. Alarm upgrade process.

[0055] For the specific definition of the memory management device, please refer to the definition of the memory management method above, which will not be repeated here. The various modules in the above-mentioned memory management device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory of the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0056] In one embodiment, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit value of the current container is modified according to the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0057] When the program instructions are read and executed by one or more processors, they can also perform operations corresponding to the various steps in the above method embodiments. Please refer to the above description and will not be repeated here. Figure 3 , which exemplarily shows the architecture of an electronic device, which may specifically include a processor 310, a video display adapter 311, a disk drive 312, an input / output interface 313, a network interface 314, and a memory 320. The processor 310, video display adapter 311, disk drive 312, input / output interface 313, network interface 314, and memory 320 may be communicatively connected via a communication bus 330.

[0058] Among them, the processor 310 can be implemented by a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in this application.

[0059] The memory 320 can be implemented in the form of a read-only memory (ROM), a random access memory (RAM), a static storage device, a dynamic storage device, etc. The memory 320 can store an operating system 321 for controlling the operation of the electronic device 300, and a basic input and output system (BIOS) 322 for controlling the low-level operations of the electronic device 300. In addition, a web browser 323, a data storage management 324, and an icon font processing system 325, etc. can also be stored. The above-mentioned icon font processing system 325 can be an application program that specifically implements the operations of the aforementioned steps in the embodiment of the present application. In short, when the technical solution provided by the present application is implemented by software or firmware, the relevant program code is stored in the memory 320 and is called and executed by the processor 310.

[0060] The input / output interface 313 is used to connect to input / output modules to enable information input and output. The input / output modules can be configured as components within the device (not shown) or externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, and various sensors. Output devices may include a display, speaker, vibrator, indicator light, and the like.

[0061] The network interface 314 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.).

[0062] The bus 330 comprises a pathway for transmitting information between the various components of the device (eg, the processor 310 , the video display adapter 311 , the disk drive 312 , the input / output interface 313 , the network interface 314 , and the memory 320 ).

[0063] In addition, the electronic device 300 may also obtain information on specific collection conditions from a virtual resource object collection condition information database (not shown in the figure) for use in condition determination.

[0064] It should be noted that although the electronic device 300 shown above only includes a processor 310, a video display adapter 311, a disk drive 312, an input / output interface 313, a network interface 314, a memory 320, and a bus 330, in a specific implementation, the electronic device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the device may only include the components necessary to implement the solution of the present application, and does not necessarily include all the components shown in the figure.

[0065] Through the description of the above implementation methods, it can be seen that those skilled in the art can clearly understand that the present application can be implemented by means of software plus the necessary general hardware platform. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling an electronic device (which can be a personal computer, a cloud server, or a network device, etc.) to execute the methods of each embodiment of the present application or certain parts of the embodiments.

[0066] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0067] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0068] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0069] The above embodiments merely illustrate several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make numerous variations and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application.

[0070] In one embodiment, a computer program product is provided, wherein a computer program is stored on the product, and when the computer program is executed by a processor, the following steps are performed: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0071] In one embodiment, a computer program product is provided, including a non-volatile computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the following steps: Collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; Determine the memory alarm level of the current container based on the memory usage and memory growth trend, where the memory alarm level includes at least the first alarm level; If the memory alarm level is the first alarm level, the final expansion capacity of the current container and the network delay difference between the current node and multiple candidate nodes are obtained. The target node for memory management is determined based on the final expansion capacity and network delay difference. The current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node. If the target node is the current node, the memory limit of the current container is modified based on the final expansion capacity; If the target node is a candidate node, a clone container of the current container is created on the target node based on the final expansion capacity, and the current container is deleted.

[0072] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program. The computer program can be stored in a computer program product. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods.

[0073] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0074] The above embodiments merely illustrate several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make numerous variations and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application.

Claims

1. A memory management method, characterized in that: The method comprises: Collecting the memory usage of the current container within a preset time period, and determining the memory growth trend of the current container based on the memory usage; Determining a memory alarm level of the current container according to the memory usage rate and the memory growth trend, wherein the memory alarm level includes at least a first alarm level; If the memory alarm level is the first alarm level, obtaining a final expansion capacity of the current container and a network delay difference between the current node and multiple candidate nodes, and determining a target node requiring memory management according to the final expansion capacity and the network delay difference, wherein the current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node; If the target node is the current node, modifying the memory limit value of the current container according to the final expansion capacity; If the target node is the candidate node, a clone container of the current container is created on the target node according to the final expansion capacity, and the current container is deleted.

2. The method according to claim 1, characterized in that The determining, according to the memory usage and the memory growth trend, the memory alarm level of the current container includes: Determining an initial memory alarm level of the current container based on a relationship between the memory usage and a preset threshold, wherein the preset threshold includes at least a first threshold, a second threshold, and a third threshold, and the first threshold is greater than the second threshold, and the second threshold is greater than the third threshold; A final memory alarm level of the current container is determined according to the initial memory alarm level and the memory growth trend, wherein the memory growth trend includes at least a first state, a second state, and a third state.

3. The method according to claim 2, characterized in that The determining, based on a magnitude relationship between the memory usage and a preset threshold, an initial memory alarm level of the current container includes: If the memory usage is greater than or equal to the first threshold, determining that the initial memory alarm level of the current container is the first alarm level; If the memory usage is greater than or equal to the second threshold and less than the first threshold, determining that the initial memory alarm level of the current container is a second alarm level, wherein the second alarm level is less than the first alarm level; If the memory usage is greater than or equal to the third threshold and less than the second threshold, determining that the initial memory alarm level of the current container is a third alarm level, wherein the third alarm level is less than the second alarm level; If the memory usage is less than the third threshold, the initial memory alarm level of the current container is determined to be a fourth alarm level, wherein the fourth alarm level is less than the third alarm level.

4. The method according to claim 3, characterized in that The determining, according to the initial memory alarm level and the memory growth trend, a final memory alarm level of the current container includes: If the initial memory alarm level is the first alarm level, determining the final memory alarm level of the current container to be the first alarm level; If the initial memory alarm level is the second alarm level, and the memory growth trend is the first state, determining that the final memory alarm level of the current container is the first alarm level; If the initial memory alarm level is the second alarm level, and the memory growth trend is the second state or the third state, determining that the final memory alarm level of the current container is the second alarm level; If the initial memory alarm level is the third alarm level and the memory growth trend is the first state, determining that the final memory alarm level of the current container is the second alarm level; If the initial memory alarm level is the third alarm level, and the memory growth trend is the second state or the third state, determining that the final memory alarm level of the current container is the third alarm level; If the initial memory alarm level is the fourth alarm level and the memory growth trend is the first state, determining that the final memory alarm level of the current container is the third alarm level; If the initial memory alarm level is the fourth alarm level, and the memory growth trend is the second state or the third state, the final memory alarm level of the current container is determined to be the fourth alarm level.

5. The method according to claim 1, characterized in that: The obtaining the final expansion capacity of the current container includes: Obtaining a memory request amount of the current container, and obtaining a baseline expansion capacity of the current container based on a first expansion coefficient and the memory request amount; Obtaining the available memory of the cluster, the available memory of the current node, and the quality of service level of the container group where the current container is located, and determining a second expansion coefficient of the current container based on the available memory of the cluster, the available memory of the current node, and the quality of service level of the container group where the current container is located; A final expansion capacity of the current container is obtained according to the second expansion coefficient and the benchmark expansion capacity.

6. The method according to claim 5, characterized in that The determining, according to the available memory amount of the cluster, the available memory amount of the current node, and the quality of service level of the container group where the current container is located, a second expansion coefficient of the current container includes: Obtaining a resource sufficiency factor of the current container based on the available memory of the cluster and the available memory of the current node; comparing the resource sufficiency factor with the quality of service level; If the resource abundance factor is greater than or equal to the quality of service level, determining the quality of service level as the second expansion coefficient of the current container; If the resource abundance factor is less than the service quality level, the resource abundance factor is determined as a second expansion coefficient of the current container.

7. The method according to claim 1, characterized in that: The determining, according to the final expansion capacity and the network delay difference, a target node requiring memory management, includes: Obtaining an available memory threshold based on a preset ratio and the final expansion capacity; Comparing the available memory amount of the current node with the available memory amount threshold; If the available memory of the current node is greater than the available memory threshold, determining the current node as the target node; If the available memory of the current node is less than or equal to the available memory threshold, the target node is determined from the multiple candidate nodes according to the network delay difference.

8. A memory management device, characterized in that: The device comprises: A container status monitoring module is used to collect the memory usage of the current container within a preset time period and determine the memory growth trend of the current container based on the memory usage; a memory pressure analysis module, configured to determine a memory alarm level of the current container based on the memory usage rate and the memory growth trend, wherein the memory alarm level includes at least a first alarm level; a cluster resource scheduling module, configured to, if the memory alarm level is the first alarm level, obtain a final expansion capacity of the current container and a network delay difference between the current node and multiple candidate nodes, and determine a target node requiring memory management based on the final expansion capacity and the network delay difference, wherein the current node is the node where the current container is located, and the candidate nodes are other nodes in the cluster except the current node; The container operation execution module is configured to modify the memory limit value of the current container according to the final expansion capacity if the target node is the current node; and to create a clone container of the current container on the target node according to the final expansion capacity if the target node is the candidate node, and to delete the current container.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the memory management method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the memory management method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Memory management method, device and equipment and readable storage medium

    CN113608862A

  • Memory leak detection method, readable medium and electronic equipment

    CN116680161A

  • Memory early warning method for java dynamic array

    CN117312109A

  • K8s cluster capacity expansion and contraction method and device, electronic equipment and storage medium

    CN120029769A

  • Storage system sizing service

    US11868629B1