Memory release method and device, electronic equipment and storage medium

By planning the business importance level for the business services in the container and linking it with the order of memory release, the problem of OOM scheduler giving priority to killing important services when memory is insufficient, and realizing the priority of releasing non-critical services when memory is insufficient to protect the operation of critical services.

CN120295772APending Publication Date: 2025-07-11DUXIAOMAN TECH (BEIJING) CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510349326.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

In Linux operating systems, OOM schedulers may prioritize killing important business services when there is insufficient memory, affecting the operation of other business services. The existing technology has failed to effectively solve this problem.

Method used

By planning different business importance levels for different business services running in containers and linking them to the memory release order, we ensure that the memory release order is negatively correlated with the business importance level, and priority is given to the release of containers with lower business importance levels.

Benefits of technology

It avoids priority release of important business services when memory resources are insufficient, reduces the impact of memory release on important business services, and ensures the stable operation of key services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295772A_ABST
    Figure CN120295772A_ABST
Patent Text Reader

Abstract

The invention provides a memory release method and device, electronic equipment and a storage medium, and relates to the technical field of memory management.The method comprises the steps that if a memory release requirement exists, the business importance levels of a plurality of running containers are obtained; based on the business importance level, determining a memory release sequence of each container in the plurality of containers, the memory release sequence being in negative correlation with the business importance level of the container; and based on the memory release sequence, determining a target container from the plurality of containers, and performing memory release on a target memory occupied by the target container during operation. According to the method, accurate putting of the target marketing strategy is realized. By means of the method, the container with the low business importance level can be released preferentially, the situation that the high-priority service of the business is released earlier than the low-priority service under the condition that memory resources are insufficient is avoided, and the influence of memory release on important business services is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of memory management, and particularly to a memory release method, apparatus, electronic device, and storage medium. Background Art

[0002] The OOM (Out of Memory) mechanism in the Linux operating system is a mechanism for handling insufficient memory resources. When the memory resources in the system are exhausted, the Linux system monitors and controls the memory usage of processes through the OOM scheduler. Under the action of the OOM scheduler, the system will select some processes to sacrifice to ensure that the system can continue to run. When selecting the processes to be sacrificed, it is often determined according to the OOM scores of the processes. The higher the OOM score of a process, the more likely it is to be closed first; in actual applications, processes with higher OOM scores may be important business services. If such a process is directly closed, it may affect the operation of other business services. Summary of the Invention

[0003] The present disclosure provides a memory release method, apparatus, electronic device, and storage medium. The technical solutions are as follows:

[0004] According to one aspect of the present disclosure, a memory release method is provided. The method includes:

[0005] If there is a memory release requirement, obtain the business importance levels of multiple running containers;

[0006] Based on the business importance levels, determine the memory release order of each of the multiple containers, where the memory release order is negatively correlated with the business importance level of the container;

[0007] Based on the memory release order, determine a target container from the multiple containers, and release the target memory occupied by the target container during runtime.

[0008] According to another aspect of the present disclosure, a memory release apparatus is provided. The apparatus includes:

[0009] An obtaining module, configured to obtain the business importance levels of multiple running containers if there is a memory release requirement;

[0010] A first determination module, configured to determine the memory release order of each of the multiple containers based on the business importance levels, where the memory release order is negatively correlated with the business importance level of the container;

[0011] A second determination module, configured to determine a target container from the multiple containers based on the memory release order, and release the target memory occupied by the target container during runtime.

[0012] According to one aspect of the present disclosure, an electronic device is provided, including: a processor and a memory storing a program, the program including instructions that, when executed by the processor, cause the processor to execute the memory release method as described above.

[0013] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, the computer instructions being used to cause the computer to execute the memory release method as described above.

[0014] According to another aspect of the present disclosure, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to execute the above-mentioned memory release method.

[0015] The beneficial effects brought by the technical solutions provided in the embodiments of the present disclosure at least include:

[0016] An embodiment of the present application provides a memory release method: by pre-planning different priorities, that is, service importance levels, for different business services running in containers, and associating the service importance levels with the memory release order; when there is a memory release requirement, by obtaining the service importance levels of multiple running containers, and determining the memory release order of each container based on the service importance levels, so as to select a target container that needs to release memory based on the memory release order. Since the service importance level of the business service running in the container is considered during memory release, and the memory release order is negatively correlated with the service importance level, it is possible to preferentially release the containers with a lower service importance level, avoid the high-priority services of the business being released before the low-priority services in the case of insufficient memory resources, and reduce the impact of memory release on important business services. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In the following description of exemplary embodiments with reference to the drawings, more details, features, and advantages of the present disclosure are disclosed. In the drawings:

[0018] Figure 1 A flowchart showing a method for determining a marketing strategy according to an exemplary embodiment of the present disclosure is shown;

[0019] Figure 2 A flowchart showing another memory release method according to an exemplary embodiment of the present disclosure is shown;

[0020] Figure 3 It is a schematic structural diagram of a memory release device provided by an embodiment of the present disclosure;

[0021] Figure 4 It shows a structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present disclosure. Detailed implementation manners

[0022] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although some embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Instead, these embodiments are provided to more thoroughly and completely understand the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not used to limit the protection scope of the present disclosure.

[0023] It should be understood that the steps recorded in the method embodiments of the present disclosure can be executed in different orders and / or executed in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this regard.

[0024] The term "including" and its variants used herein are open-ended, that is, "including but not limited to". The term "based on" is "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description. It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependent relationships. It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive. Those skilled in the art should understand that unless otherwise clearly stated in the context, it should be understood as "one or more". The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.

[0025] The following describes the solution of the present invention with reference to the accompanying drawings, and details the technical solutions provided by the embodiments of the present invention through specific embodiments and their application scenarios.

[0026] First, some explanations will be given to the nouns that may be involved in the embodiments of the present application:

[0027] (1) Pod: A Pod is the smallest unit that can be created and managed in the k8s system. It is the smallest resource object model created or deployed by users in the resource object model and is also the resource object for running containerized applications on k8s. Other resource objects are used to support or extend the functions of the Pod object. A Pod consists of one or more containers.

[0028] (2) Container: A container, i.e., a container, is an open-source application container engine that allows developers to package their applications and dependencies in a portable container in a unified manner and then publish them to any server with the docker engine installed (including popular Linux machines and Windows machines), and virtualization can also be achieved. Containers use a sandbox mechanism completely and there are no interfaces between them. There is almost no performance overhead and they can be easily run on machines and in data centers.

[0029] (3) k8s Quality of Service: Kubernetes (abbreviated as k8s) classifies the running Pods and assigns each Pod to a specific QoS (Quality of Service). Kubernetes uses this classification to affect the way different Pods are processed. Kubernetes classifies the QoS of Pods based on the resource requests and limits of the containers in the Pod.

[0030] (4) Guaranteed: It has the strictest resource limits in the k8s quality of service. Each container in the Pod must set the request and limit of CPU and memory, and the CPU request must be equal to the CPU limit, and the memory request must be equal to the memory limit.

[0031] (5) Burstable: The Pod does not meet the criteria of Guaranteed, and at least one container in the Pod has a request or limit for memory or CPU.

[0032] (6) BestEffort: The Pod does not meet the criteria of Guaranteed or Burstable, and each container in the Pod does not set a request or limit for memory or CPU.

[0033] (7) Kubelet: Kubelet is an agent component on the kubernetes worker node. It runs on each node. Kubelet is the main service on the worker node, mainly used to create, manage, and monitor containers to ensure that the Pod and its containers run under the expected specifications.

[0034] (8) Kubernetes, abbreviated as k8s, is a container orchestration engine open-sourced by Google. It supports automated deployment, large-scale scalability, and application containerization management.

[0035] The OOM (Out of Memory) mechanism in the Linux operating system is a mechanism for handling insufficient memory resources. When the memory resources in the system are exhausted, the Linux system will use the OOM scheduler to monitor and control the memory usage of processes. Under the action of the OOM scheduler, the system will select some processes to sacrifice to ensure that the system can continue to run. In the Linux system, each process has an oom_score value, which represents the priority of the process in the OOM scheduler. The higher the oom_score value of a process, the more likely it is to become a victim of the OOM scheduler. The oom_score value is obtained by combining the oom_score_adj value of the process with its memory usage.

[0036] In k8s, the kubelet component sets an oom_score_adj value for each container according to the Quality of Service (QoS) of the Pod. If the kubelet is unable to reclaim memory before the node encounters OOM, the OOM scheduler calculates the effective oom_score for each container based on the percentage of memory it uses on the node plus the oom_score_adj. Then, by killing the container with the highest score, the purpose of releasing memory is achieved. The kubelet sets different oom_score_adj values for containers with different service qualities. The specific setting method is shown in Table 1:

[0037] Table 1

[0038]

[0039] In Table 1, memoryRequestBytes is the memory request set by the container, and machineMemoryCapacityBytes is the total allocable memory of the node. For the same container belonging to the Burstable quality of service, its corresponding oom_score_adj is a fixed value.

[0040] From the above content, it can be seen that the influencing factors of the OOM order of Containers in k8s include the QoS (Quality of Service) level, memory application volume, and memory usage volume. However, under the same QoS level, the memory application volume and memory usage volume do not represent the importance of the Container at the business level. According to the current logic, when OOM occurs, a service with a high priority at the business level may be killed first, while the low-priority service continues to run.

[0041] Therefore, to solve the problem of the order of OOM kill (killed due to insufficient memory) for containers in the scenario of insufficient memory resources and avoid high-priority services at the business level being OOM killed before low-priority services in case of insufficient memory resources, the present application provides a new memory release method. Please refer to Figure 1 , which shows a flowchart of a method for determining a marketing strategy according to an exemplary embodiment of the present disclosure. This method is described by way of example when applied to a memory management device. As Figure 1 shown, the method includes:

[0042] Step 101, if there is a memory release requirement, obtain the business importance levels of multiple running containers.

[0043] To avoid high-priority services at the business level being OOM killed before low-priority services, in a possible implementation, different priorities, that is, business importance levels, are pre-planned for different business services running in containers, so that when there is a memory release requirement, the memory management process in the device can obtain the business importance levels of multiple running containers. The business importance level is the priority of the business service associated with the application or process running in each container, and the higher the business importance level, the higher the priority of the business service. For business services with higher priorities, the order in which they are OOM killed should be later.

[0044] Among them, the memory release requirement refers to the situation where the remaining memory resources in the memory cannot meet the new memory allocation requirements.

[0045] Step 102, based on the business importance levels, determine the memory release order for each of the multiple containers, and the memory release order is negatively correlated with the business importance level of the container.

[0046] To achieve the purpose of releasing low-priority services before high-priority services from memory, the business importance level is associated with the memory release order, and the higher the business importance level, the later the memory release order. In a possible implementation, based on the business importance levels, the memory release order for each of the multiple running containers can be determined, and the memory release order is negatively correlated with the business importance level of the container.

[0047] Exemplarily, if containers 1, 2, 3, and 4 are running in a device node, and the obtained business importance levels corresponding to each container are: the business importance level corresponding to container 1 is 2000, the business importance level corresponding to container 2 is 3000, the business importance level corresponding to container 3 is 4000, and the business importance level corresponding to container 4 is 5000, then the memory release order for each container is: container 1 > container 2 > container 3 > container 4. That is, container 1 is released first, and container 4 is released last.

[0048] Step 103: Determine a target container from multiple containers based on the memory release order, and release the target memory occupied by the target container during runtime.

[0049] After determining the memory release order of each running container, a target container can be determined from multiple containers based on the memory release order, and the target memory occupied by the target container during runtime can be released. Specifically, the container with the earliest order in the memory release order can be used as the target container.

[0050] In summary, the embodiments of the present application provide a memory release method: By pre-planning different priorities, that is, business importance levels, for different business services running in containers, and associating the business importance levels with the memory release order; when there is a memory release requirement, by obtaining the business importance levels of multiple running containers, and determining the memory release order of each container based on the business importance levels, so as to select a target container that needs to release memory based on the memory release order. Since the business importance level of the business service running in the container is considered during memory release, and the memory release order is negatively correlated with the business importance level, it is possible to preferentially release the containers with a lower business importance level, avoid the high-priority services in the business being released before the low-priority services in the case of insufficient memory resources, and reduce the impact of memory release on important business services.

[0051] In order to associate the business importance level with the memory release order, the embodiments of the present application also improve the determination method of the oom_score_adj value used in the process of killing containers by OOM, so as to ensure that low-priority services are released before high-priority services.

[0052] Please refer to Figure 2 , which shows a flowchart of another memory release method according to an exemplary embodiment of the present disclosure. This method is described by way of example as being applied to a memory management device. As Figure 2 shown, this method includes:

[0053] Step 201: If there is a memory release requirement, obtain the business importance levels of multiple running containers.

[0054] The implementation manner of Step 201 can refer to Step 101, and will not be elaborated in this embodiment.

[0055] Step 202: Based on the business importance levels, determine the target score corresponding to each container among multiple containers, and the target score is negatively correlated with the business importance level.

[0056] When Kubernetes determines the memory release order (OOM order) of each container, it often needs to calculate the OOM score corresponding to each container first. If the OOM score of a container is higher, it means that the memory occupied by the container is more likely to be released. In order to ensure that low-priority services are released before high-priority services without changing the original OOM order determination logic, the embodiment of the present application introduces a parameter of business importance level in the process of determining the OOM score, so as to link the business importance level with the memory release order. In a possible implementation manner, first, based on the business importance level, determine the target score (i.e., OOM score) corresponding to each container among multiple containers, and then determine the memory release order corresponding to each container based on the sorting of the target scores. And the target score is also negatively correlated with the business importance level, that is, the higher the business importance level, the lower the target score, and the later the container is released from memory; while the lower the business importance level, the higher the target score, and the earlier the container is released from memory.

[0057] The OOM score mainly consists of two parts. One part is the priority adjustment parameter (i.e., oom_score_adj), and the other part is the memory usage rate of the container. In order to introduce the business importance level into the OOM score, only the priority adjustment parameter can be improved. In an exemplary example, step 202 may include step 202A and step 202B.

[0058] Step 202A, determine the priority adjustment parameter associated with the business importance level.

[0059] Different from the related art where oom_score_adj (priority adjustment parameter) is only related to the quality of service, the embodiment of the present application makes a more detailed division of the priority adjustment parameter according to the business importance level, and pre-associates and stores the business importance level and the corresponding priority adjustment parameter in the device. So that when memory is released, the priority adjustment parameter associated with the business importance level can be found and obtained based on the business importance level.

[0060] Among them, the parameter range of the priority adjustment parameter is -1000 to 1000, and the priority adjustment parameter is negatively correlated with the business importance level, that is, the higher the business importance level, the smaller the priority adjustment parameter (closer to -1000), and the lower the business importance level, the larger the priority adjustment parameter (closer to 1000).

[0061] Since Kubernetes sets the corresponding priority adjustment parameter for each container according to the quality of service of the container, in order to link the priority adjustment parameter with the business importance level, different business importance levels are divided under each quality of service. Exemplarily, the relationship between the newly added quality of service and the business importance level is shown in Table 2:

[0062] Table 2

[0063]

[0064] In Table 2, k8s provides 2 priorityClassNames (priority class names), namely system-cluster-critical (system critical cluster) and system-node-critical (system critical node). Each priority will have a corresponding numerical value, and the larger the number, the higher the priority. In Table 2, except for system-cluster-critical and system-node-critical, other priorityClassNames are the priorities (i.e., business importance levels) planned for the business in the embodiments of the present application. There is a certain corresponding relationship between the planned priorities and the k8s service quality. For example, when the service quality is Guaranteed, there are also two priorities, Level1-0-priority and Level1-1-priority; when the service quality is Burstable, there are also four priorities, Level2-0-priority, Level2-1-priority, Level2-2-priority, and Level2-3-priority; when the service quality is BestEffort, there are also two priorities, Level3-0-priority and Level3-1-priority. Business personnel will pre-evaluate the importance of business services and set the corresponding business importance levels for each business service.

[0065] Optionally, Table 2 is only for illustrative purposes, and the number of priorities divided under each service quality can be customized by business personnel; or it can be determined according to the number of business services included under that service quality. The more business services there are, the more priorities can be set.

[0066] When setting the business importance level, there is a certain corresponding relationship between the business importance level and the service quality. Therefore, when determining the priority adjustment parameter according to the business importance level, the differences in different service qualities are also considered. Optionally, step 202A may further include steps 202A1 and 202A2.

[0067] Step 202A1, in the case where the business importance level indicates that the container belongs to the first type of service quality and the third type of service quality, look up and obtain the priority adjustment parameter associated with the business importance level from the adjustment parameter relationship table.

[0068] Since there are fewer business services included in the first type of quality of service and the third type of quality of service, setting different priority adjustment parameters according to their corresponding business importance levels respectively can meet the differentiated memory release requirements of different business services. In the corresponding device, there is a pre-stored adjustment parameter relationship table between the business importance levels and the priority adjustment parameters under the first type of quality of service and the third type of quality of service, so that when the business importance level indication container belongs to the first type of quality of service and the third type of quality of service, the associated priority adjustment parameters can be directly found from the adjustment parameter table based on the business importance level.

[0069] Exemplarily, the first type of quality of service is Guaranteed, and the third type of quality of service is BestEffort.

[0070] Step 202A2, in the case where the business importance level indication container belongs to the second type of quality of service, find and obtain the adjustment parameter calculation method associated with the business importance level from the adjustment parameter relationship table; based on the adjustment parameter calculation method, calculate the priority adjustment parameter, and the adjustment parameter calculation methods corresponding to different business importance levels under the second type of quality of service are different.

[0071] Since there are more business services included in the second type of quality of service, setting different priority adjustment parameters according to their corresponding business importance levels respectively will still result in the same memory release order for many business services, with insufficient differentiation. Therefore, in order to increase the differentiation of the priority adjustment parameters corresponding to different business importance levels under the second type of quality of service, different adjustment parameter calculation methods are set for different business importance levels under the second type of quality of service, so that when the business importance level indication container belongs to the second type of quality of service, the adjustment parameter calculation method associated with the business importance level is found and obtained from the adjustment parameter relationship table, and the priority adjustment parameter is calculated based on the adjustment parameter calculation method. Among them, the second type of quality of service is Burstable.

[0072] Exemplarily, the priority adjustment parameters under different business importance levels are shown in Table 3 (Table 3 is the adjustment parameter relationship table).

[0073] Table 3

[0074]

[0075] As can be seen from Table 3, under the first type of Quality of Service (Guaranteed), there are two service importance levels, Level1-0-priority and Level1-1-priority. The priority adjustment parameter corresponding to Level1-0-priority is -997, and the priority adjustment parameter corresponding to Level1-1-priority is -700. Under the third type of Quality of Service (BestEffort), there are two service importance levels, Level3-0-priority and Level3-1-priority. The priority adjustment parameter corresponding to Level3-0-priority is 800, and the priority adjustment parameter corresponding to Level3-1-priority is 1000. Under the second type of Quality of Service (Burstable), there are four service importance levels, Level2-0-priority, Level2-1-priority, Level2-2-priority, and Level2-3-priority. The priority adjustment parameters corresponding to these four service importance levels are calculated by different methods (priority adjustment parameter calculation formulas). Among them, the calculation method for the adjustment parameter corresponding to Level2-0-priorityLevel is: -(400 + (100 * memoryRequestBytes) / machineMemoryCapacityBytes); the calculation method for the adjustment parameter corresponding to Level2-1-priority is: -(100 + (100 * memoryRequestBytes) / machineMemoryCapacityBytes); the calculation method for the adjustment parameter corresponding to Level2-2-priority is: 200 - (100 * memoryRequestBytes) / machineMemoryCapacityBytes; the calculation method for the adjustment parameter corresponding to Level2-3-priority is 500 - (100 * memoryRequestBytes) / machineMemoryCapacityBytes. And memoryRequestBytes in the priority adjustment parameter calculation formula is the memory request amount set by the container, and machineMemoryCapacityBytes is the total allocable memory of the device node.

[0076] For the second type of quality of service, based on the calculation method of the adjustment parameter, the process of calculating the priority adjustment parameter can be as follows: Obtain the memory request amount of the container during runtime and the total allocable memory of the device node, and substitute the memory request amount and the total allocable memory into the corresponding adjustment parameter calculation method (adjustment parameter calculation formula), and then the priority adjustment parameter corresponding to the business importance level can be obtained.

[0077] Since memoryRequestBytes (memory request amount) must be less than or equal to machineMemoryCapacityBytes (total allocable memory), it can be inferred that the value range of oom_score_adj (priority adjustment parameter) corresponding to Level2-0-priority is [-500, -400]; the value range of oom_score_adj (priority adjustment parameter) corresponding to Level2-1-priority is [-200, -100]; the value range of oom_score_adj (priority adjustment parameter) corresponding to Level2-2-priority is [100, 200]; the value range of oom_score_adj (priority adjustment parameter) corresponding to Level2-3-priority is [400, 500]. It can be seen that the priority adjustment parameters corresponding to every two business importance levels differ by at least 200 points, which can ensure that for the target score (OOM score) calculated based on the priority adjustment parameter subsequently, the OOM score of the high business importance level must be less than the OOM score of the low business importance level.

[0078] Step 202B, based on the priority adjustment parameter, determine the target score corresponding to each container among multiple containers.

[0079] Furthermore, after determining the priority adjustment parameter, the target score (OOM score) corresponding to each container can be jointly determined in combination with the memory usage rate.

[0080] Optionally, step 202B may further include step 202B1 and step 202B2.

[0081] Step 202B1, obtain the memory usage rate corresponding to each container.

[0082] Step 202B2, based on the memory usage rate and the priority adjustment parameter, determine the target score corresponding to each container among multiple containers.

[0083] In an exemplary example, the calculation formula of the target score (OOM score) can be as shown in formula (1).

[0084] oom_score = oom_score_adj + memory utilization rate * 1000 (1)

[0085] Among them, oom_score represents the target score (OOM score), and oom_score_adj represents the priority adjustment parameter. After obtaining the memory utilization rate corresponding to each container, the memory utilization rate and the priority adjustment parameter can be substituted into formula (1) to calculate the target score corresponding to each container.

[0086] In the production environment, the k8s administrator will provide different pod packages for business services, that is, resource usage such as CPU and memory. The maximum memory in the largest pod package is 48G, that is, the pod memory limit is at most 48G. Given that the total memory of the k8s node machine is 256G. Then for pod containers, the memory utilization rate ranges from [0, 48 / 256], that is, [0, 0.1875]. On the basis that the priority adjustment parameters corresponding to every two business importance levels differ by at least 200 points, after calculating the target score based on formula (1), it can be ensured that the target score of a high business importance level must be less than the target score of a low business importance level. Then, according to the rules of the operating system oom scheduler, the oom scheduler selects the process with the highest oom_score value to kill. Therefore, setting according to the rules of this application can ensure that business services with a low business importance level are oom killed before business services with a high business importance level.

[0087] Step 203: Determine the memory release order of each container among multiple containers based on the high or low of the target scores, and the memory release order is positively correlated with the target scores.

[0088] After determining the target score corresponding to each container, the containers can be sorted from high to low according to the target scores, so as to obtain the memory release order corresponding to each container. The higher the target score, the earlier the memory release order; the lower the target score, the later the memory release order.

[0089] Step 204: Obtain the memory demand required for the memory release requirement. Step 205: Determine the target container from multiple containers based on the memory demand and the memory release order.

[0090] When the device often has a memory release requirement when it cannot meet the new memory demand, when selecting a target container for memory release, the current memory demand should also be considered, corresponding to obtaining the memory demand required for the memory release requirement, and then combining the memory demand and the memory release order to comprehensively determine the target container to be released.

[0091] In an exemplary example, step 205 may include step 205A and step 205B.

[0092] Step 205A, obtain the memory occupancy of the container with the highest memory release order.

[0093] Step 205B, if the memory occupancy is greater than or equal to the memory requirement, determine the container with the highest memory release order as the target container.

[0094] Specifically, first obtain the memory occupancy of the container with the highest memory release order. If the memory occupancy is greater than or equal to the memory requirement, it means that by releasing this container, the current memory requirement can be met, and there is no need to release the container with the second-highest memory release order. Correspondingly, the container with the highest memory release order is used as the target container, and the target memory occupied by the target container during operation is released.

[0095] On the contrary, if the memory occupancy is less than the memory requirement, it means that releasing only the container with the highest memory release order cannot meet the current requirement. It is necessary to further judge the relationship between the sum of the memory occupancies of the top two containers in the memory release order and the required memory requirement. If it can be met, the top two containers in the memory release order are determined as the target containers for memory release. If it cannot be met, continue to judge the relationship between the sum of the memory occupancies of the top three containers in the memory release order and the required memory requirement, and so on, to determine the target container.

[0096] In this embodiment, by improving the determination process of the priority adjustment parameter in the OOM score and introducing the business importance level therein, it is ensured that the OOM score of the service with high priority (i.e., high business importance level) must be lower than the OOM score of the service with low priority (i.e., low business importance level). Thus, when releasing memory, based on the principle of releasing the container with the highest OOM score first, the service with low priority can be released before the service with high priority, thereby reducing the impact of memory release on important business services.

[0097] Please refer to Figure 3 , which is a schematic structural diagram of a memory release device provided by an embodiment of the present disclosure. Exemplarily, as Figure 3 shown, the device 300 includes:

[0098] An obtaining module 301, configured to obtain the business importance levels of multiple running containers if there is a memory release requirement;

[0099] A first determining module 302, configured to determine the memory release order of each of the multiple containers based on the business importance level, and the memory release order is negatively correlated with the business importance level of the container;

[0100] The second determination module 303 is configured to determine a target container from the multiple containers based on the memory release order, and release the target memory occupied by the target container during runtime.

[0101] Optionally, the first determination module 302 is further configured to:

[0102] Determine a target score corresponding to each of the multiple containers based on the service importance level, where the target score has a negative correlation with the service importance level;

[0103] Determine the memory release order of each of the multiple containers based on the level of the target score, and the memory release order has a positive correlation with the target score.

[0104] Optionally, the first determination module 302 is further configured to:

[0105] Determine a priority adjustment parameter associated with the service importance level;

[0106] Determine the target score corresponding to each of the multiple containers based on the priority adjustment parameter.

[0107] Optionally, the first determination module 302 is further configured to:

[0108] Obtain the memory usage rate corresponding to each container;

[0109] Determine the target score corresponding to each of the multiple containers based on the memory usage rate and the priority adjustment parameter.

[0110] Optionally, the first determination module 302 is further configured to:

[0111] When the service importance level indicates that the container belongs to the first type of service quality and the third type of service quality, look up and obtain the priority adjustment parameter associated with the service importance level from the adjustment parameter relationship table;

[0112] When the service importance level indicates that the container belongs to the second type of service quality, look up and obtain the adjustment parameter calculation method associated with the service importance level from the adjustment parameter relationship table; calculate the priority adjustment parameter based on the adjustment parameter calculation method, and the adjustment parameter calculation methods corresponding to different service importance levels under the second type of service quality are different.

[0113] Optionally, the second determination module 303 is configured to:

[0114] Obtain the memory requirement for the memory release requirement;

[0115] Determine the target container from the multiple containers based on the memory requirement and the memory release order.

[0116] Optionally, the second determination module 303 is configured to:

[0117] Obtain the memory occupancy of the container with the highest memory release order;

[0118] If the memory occupancy is greater than or equal to the memory requirement, determine the container with the highest memory release order as the target container.

[0119] An embodiment of the present application provides a memory release method: by pre-planning different priorities, that is, service importance levels, for different business services running in containers, and associating the service importance levels with the memory release order; such that when there is a memory release requirement, by obtaining the service importance levels of multiple running containers and determining the memory release order of each container based on the service importance levels, thereby selecting a target container that needs to release memory based on the memory release order. Since the service importance levels of the business services running in the containers are considered during memory release, and the memory release order is negatively correlated with the service importance levels, it is possible to preferentially release the containers with lower service importance levels, avoiding the situation where high-priority services are released before low-priority services in case of insufficient memory resources, and reducing the impact of memory release on important business services.

[0120] An exemplary embodiment of the present disclosure further provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, it is used to cause the electronic device to execute the method according to the embodiment of the present disclosure.

[0121] An exemplary embodiment of the present disclosure further provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is used to cause a computer to execute the method according to the embodiment of the present disclosure when executed by a processor of the computer.

[0122] An exemplary embodiment of the present disclosure further provides a computer program product, including a computer program, wherein the computer program is used to cause a computer to execute the method according to the embodiment of the present disclosure when executed by a processor of the computer.

[0123] Reference Figure 4, a structural block diagram of an electronic device 400 that can be a server or a client of the present disclosure will now be described. It is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as, laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as, personal digital processors, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0124] As Figure 4 shown, the electronic device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0125] Multiple components in the electronic device 400 are connected to the I / O interface 405, including: an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. The input unit 406 can be any type of device that can input information into the electronic device 400. The input unit 406 can receive input digital or character information, and generate key signal inputs related to the user settings and / or function controls of the electronic device. The output unit 407 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 408 can include but is not limited to a magnetic disk, an optical disk. The communication unit 409 allows the electronic device 400 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0126] The computing unit 401 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 401 executes the various methods and processes described above. For example, in some embodiments, Figure 1 , Figure 2 the method shown can be implemented as a computer software program tangibly embodied in a machine-readable medium, such as the storage unit 408. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 400 via the ROM 402 and / or the communication unit 409. In some embodiments, the computing unit 401 can be configured to execute Figure 1 , Figure 2 the method shown by any other suitable means (e.g., by means of firmware).

[0127] The program code for implementing the methods of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowchart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0128] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0129] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., magnetic disks, optical disks, memory, programmable logic devices (PLD)) used to provide machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal used to provide machine instructions and / or data to a programmable processor.

[0130] In order to provide an interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can also be used to provide an interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and the input received from the user can be in any form (including acoustic input, speech input, or tactile input).

[0131] The systems and techniques described herein can be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.

[0132] A computer system can include a client and a server. The client and the server are generally remote from each other and typically interact through a communication network. The relationship of the client and the server is generated by computer programs running on the respective computers and having a client-server relationship with each other.

Claims

1. A memory release method, characterized in that, The method includes: If there is a memory release requirement, obtain the business importance levels of multiple running containers; Based on the business importance levels, determine the memory release order of each of the multiple containers, where the memory release order is negatively correlated with the business importance level of the container; Based on the memory release order, determine a target container from the multiple containers, and release the target memory occupied by the target container during operation.

2. The method according to claim 1, wherein The determining the memory release order of each of the multiple containers based on the business importance level includes: Based on the business importance level, determine the target score corresponding to each of the multiple containers, where the target score is negatively correlated with the business importance level; Based on the high and low of the target scores, determine the memory release order of each of the multiple containers, and the memory release order is positively correlated with the target score.

3. The method according to claim 2, wherein The determining the target score corresponding to each of the multiple containers based on the business importance level includes: Determine a priority adjustment parameter associated with the business importance level; Based on the priority adjustment parameter, determine the target score corresponding to each of the multiple containers.

4. The method according to claim 3, wherein The determining the target score corresponding to each of the multiple containers based on the priority adjustment parameter includes: Obtain the memory usage rate corresponding to each container; Based on the memory usage rate and the priority adjustment parameter, determine the target score corresponding to each of the multiple containers.

5. The method according to claim 3, characterized in that The determining the priority adjustment parameter associated with the business importance level includes: When the business importance level indicates that the container belongs to the first service quality and the third service quality, look up and obtain the priority adjustment parameter associated with the business importance level from the adjustment parameter relationship table; When the business importance level indicates that the container belongs to the second service quality, look up and obtain the adjustment parameter calculation method associated with the business importance level from the adjustment parameter relationship table; based on the adjustment parameter calculation method, calculate the priority adjustment parameter, and the adjustment parameter calculation methods corresponding to different business importance levels under the second service quality are different.

6. The method according to any one of claims 1 to 5, characterized in that The determining a target container from the multiple containers based on the memory release order includes: Obtain the memory requirement amount required by the memory release requirement; Based on the memory requirement amount and the memory release order, determine the target container from the multiple containers.

7. The method according to claim 6, characterized in that, The determining the target container from the multiple containers based on the memory requirement amount and the memory release order includes: Obtain the memory occupancy of the container with the highest memory release order; If the memory occupancy is greater than or equal to the memory requirement amount, determine the container with the highest memory release order as the target container.

8. A memory release device, characterized in that, The device includes: An obtaining module, configured to obtain the business importance levels of multiple running containers if there is a memory release requirement; A first determination module, configured to determine the memory release order of each of the multiple containers based on the business importance level, where the memory release order is negatively correlated with the business importance level of the container; A second determination module, configured to determine a target container from the multiple containers based on the memory release order, and release the target memory occupied by the target container during operation.

9. An electronic device, comprising: A processor; And A memory storing a program, wherein the program includes instructions that, when executed by the processor, cause the processor to execute the method according to any one of claims 1-7.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.

Citation Information

Cited By

  • Business processing method and device, electronic equipment and storage medium

    CN121396922A