A method, apparatus, device and medium for generating a container snapshot
Patent Information
- Application Number
- CN202311268362.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2026-09-29
- Estimated Expiration
- 2043-09-27
AI Technical Summary
[0003]相关技术中容器快照的生成技术方案,考虑到生成容器快照事件的触发因素较为片面,不能灵活地适应容器的实际状态和变化,使得容器的快照生成方案并不完善,有效数据得不到有效备份,容器的管理效率低下
[0015]根据本发明的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机指令,所述计算机指令用于使处理器执行时实现本发明任一实施例所述的容器快照的生成方法。
Smart Images

Figure CN117194113B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of container technology, and in particular to a method, apparatus, device, and medium for generating container snapshots. Background Technology
[0002] Containerization technology has become a widely used method for deploying and managing applications. Many popular containerization platforms offer lightweight, portable, and scalable containerization solutions.
[0003] The container snapshot generation technology in related technologies is imperfect because the triggering factors for generating container snapshot events are relatively one-sided and cannot flexibly adapt to the actual state and changes of containers. As a result, effective data cannot be effectively backed up, and container management efficiency is low. Summary of the Invention
[0004] This invention provides a method, apparatus, device, and medium for generating container snapshots, which enables flexible container management, better adapts to the actual state and changes of containers, and ensures the timeliness and effectiveness of data backup.
[0005] According to one aspect of the present invention, a method for generating a container snapshot is provided, the method comprising:
[0006] The operational metrics data of the target container are determined according to a preset period; the target container is a running container; the operational metrics data include at least one of the target container's CPU utilization, memory utilization, and disk utilization.
[0007] If the target container triggers a snapshot generation event at the current moment based on the operational metric data, then a target snapshot of the target container at the current moment is generated; the snapshot generation event includes at least one of the following: an automatic restart risk event, a crash risk event, and a significant change in snapshot size.
[0008] According to another aspect of the present invention, an apparatus for generating container snapshots is provided, the apparatus comprising:
[0009] The operation indicator data determination module is used to determine the operation indicator data of a target container according to a preset period; the target container is a running container; the operation indicator data includes at least one of the target container's CPU utilization, memory utilization, and disk utilization.
[0010] The target snapshot generation module is used to generate a target snapshot of the target container at the current moment if the target container triggers a snapshot generation event based on the operation index data; the snapshot generation event includes at least one of the following: an automatic restart risk event, a crash risk event, and a significant change in snapshot size.
[0011] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0012] At least one processor; and
[0013] A memory communicatively connected to the at least one processor; wherein,
[0014] The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the container snapshot generation method according to any embodiment of the present invention.
[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium storing computer instructions for causing a processor to execute and implement the container snapshot generation method according to any embodiment of the present invention.
[0016] The technical solution of this invention determines the operational metrics data of a target container according to a preset period. The target container is a running container. The operational metrics data includes at least one of the target container's CPU utilization, memory utilization, and disk utilization. If the operational metrics data determine that the target container triggers a snapshot generation event at the current moment, a target snapshot of the target container at that moment is generated. The snapshot generation event includes at least one of an automatic restart risk event, a crash risk event, and a significant change in snapshot size. By implementing this solution, flexible container management can be achieved, better adapting to the actual state and changes of the container, and ensuring the timeliness and effectiveness of data backup.
[0017] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of a method for generating a container snapshot provided in an embodiment of the present invention;
[0020] Figure 2a This is a flowchart of another method for generating container snapshots provided in an embodiment of the present invention;
[0021] Figure 2b This is a flowchart of another method for generating container snapshots provided in an embodiment of the present invention;
[0022] Figure 2c This is a schematic diagram illustrating local storage of snapshots provided in an embodiment of the present invention;
[0023] Figure 2d This is a schematic diagram of cloud storage of snapshots provided in an embodiment of the present invention;
[0024] Figure 3 This is a schematic diagram of the structure of a container snapshot generation device provided in an embodiment of the present invention;
[0025] Figure 4 This is a schematic diagram of the structure of an electronic device that implements the container snapshot generation method of this invention. Detailed Implementation
[0026] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] It is understood that before using the technical solutions disclosed in the various embodiments of the present invention, users should be informed of the types, scope of application, and usage scenarios of the personal information involved in the present invention and their authorization should be obtained in accordance with relevant laws and regulations through appropriate means.
[0029] For example, upon receiving a user's active request, a prompt message is sent to the user to explicitly inform them that the requested operation will require the acquisition and use of the user's personal information. This allows the user to independently choose whether to provide personal information to the software or hardware, such as the electronic device, application program, server, or storage medium executing the operation of this invention, based on the prompt message.
[0030] As an optional but non-limiting implementation, in response to a user's active request, sending a prompt message to the user can be done via a pop-up window, where the prompt message can be presented in text format. Furthermore, the pop-up window can also include a selection control allowing the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0031] It is understood that the above notification and user authorization process is merely illustrative and does not constitute a limitation on the implementation of the present invention. Other methods that comply with relevant laws and regulations may also be applied to the implementation of the present invention.
[0032] It is understood that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) shall comply with the requirements of relevant laws, regulations and related provisions.
[0033] Figure 1 This is a flowchart of a container snapshot generation method provided in an embodiment of the present invention. This embodiment is applicable to situations where running containers are monitored. The method can be executed by a container snapshot generation device, which can be implemented in hardware and / or software. This container snapshot generation device can be configured in an electronic device used for generating container snapshots. Figure 1 As shown, the method includes:
[0034] S110: Determine the operating index data of the target container according to a preset cycle; the target container is a container in operation.
[0035] The operational metrics data include at least one of the target container's CPU utilization, memory utilization, and disk utilization.
[0036] For example, this solution can be executed through an application running on Docker, which can monitor multiple containers running on Docker. The target container is the running container being monitored. The preset period is the interval at which the runtime metric data of the target container is collected, which can be set according to actual needs, for example, it can be set to 1 second, 5 seconds, or 30 seconds.
[0037] S120: If it is determined from the operational metric data that the target container triggers a snapshot generation event at the current moment, then a target snapshot of the target container at the current moment is generated.
[0038] The snapshot generation event includes at least one of the following: automatic restart risk event, crash risk event, and snapshot size significant change event.
[0039] Specifically, this solution determines whether a snapshot generation event has been triggered for the target container each time the operational metrics data is determined. If the snapshot generation event is triggered, the container's state needs to be backed up, and a target snapshot of the target container at the current moment is generated. If the snapshot generation event is not triggered, a target snapshot of the target container at the current moment is not generated.
[0040] The technical solution of this invention determines the operational metrics data of a target container according to a preset period. The target container is a running container. The operational metrics data includes at least one of the target container's CPU utilization, memory utilization, and disk utilization. If the operational metrics data determine that the target container triggers a snapshot generation event at the current moment, a target snapshot of the target container at that moment is generated. The snapshot generation event includes at least one of an automatic restart risk event, a crash risk event, and a significant change in snapshot size. By implementing the technical solution provided by this invention, flexible container management can be achieved, better adapting to the actual state and changes of the container, and ensuring the timeliness and effectiveness of data backup.
[0041] Figure 2a This is a flowchart of a container snapshot generation method provided in an embodiment of the present invention. This embodiment is an optimization based on the above embodiment. Figure 2a As shown, the method for generating container snapshots in this embodiment of the invention may include:
[0042] S210: Determine the target container's operational performance data according to a preset cycle.
[0043] For a detailed description of this step, please refer to the above embodiments.
[0044] S220: Determine the preset moving window.
[0045] The preset moving window is the number of sampling points used in each calculation, which can be set according to actual needs. For example, the preset moving window can be 5. A smaller preset moving window can capture instantaneous changes faster, but may be unstable; a larger preset moving window can smooth the data, but may not react promptly to faster changes.
[0046] S230: Determine the target historical time interval based on the current time, the preset moving window, and the preset period.
[0047] For example, assuming the preset moving window is 5 seconds, the preset period is 2 seconds, and the current time is 10:50:32, this solution can determine the target historical time interval as 10:50:20 to 10:50:30.
[0048] S240: Determine the historical operating index data within the target historical time interval.
[0049] This scheme can determine the historical operating indicator data within the target historical time interval according to a preset period.
[0050] S250: If it is determined that the target container triggers a snapshot generation event at the current moment based on the historical operating indicator data and the current operating indicator data at the current moment, then a target snapshot of the target container at the current moment is generated.
[0051] This solution can determine whether the target container has triggered a snapshot generation event at the current moment based on the historical operating index data within the target historical time interval and the current operating index data at the current moment. If it is determined that the target container has triggered a snapshot generation event at the current moment, then a target snapshot of the target container at the current moment is generated.
[0052] In this embodiment, optionally, determining the target container's potential crash risk event based on the historical operating indicator data and the current operating indicator data includes: determining an average historical CPU utilization rate based on the historical CPU utilization rate; determining an average historical memory utilization rate based on the historical memory utilization rate; if it is determined that the current CPU utilization rate is greater than a preset CPU utilization rate and the current memory utilization rate is greater than a preset memory utilization rate, then determining a CPU utilization rate difference based on the average historical CPU utilization rate and the current CPU utilization rate; determining a memory utilization rate difference based on the average historical memory utilization rate and the current memory utilization rate; performing a weighted summation of the CPU utilization rate difference and the memory utilization rate difference to obtain a first weighted value; determining a first preset difference threshold; if it is determined that the first weighted value is greater than the first preset difference threshold, then determining that the target container's potential crash risk event is triggered at the current moment.
[0053] If a container's CPU and memory usage suddenly spikes, the container is at risk of crashing. High CPU and memory usage can degrade the performance of applications within the container. When applications are unable to respond to requests or process tasks in a timely manner, the container may be unable to handle the load effectively, leading to a crash.
[0054] The average historical CPU utilization (pre_avg_cpu) is determined based on the average historical CPU utilization within the target historical time interval, and the average historical memory utilization (pre_avg_mem) is determined based on the average historical memory utilization within the target historical time interval. If the current CPU utilization (curr_cpu) is greater than the preset CPU utilization, and the current memory utilization (curr_mem) is greater than the preset memory utilization, then the difference between the current CPU utilization and the average historical CPU utilization (curr_cpu - pre_avg_cpu) is used as the CPU utilization difference, and the difference between the current memory utilization and the average historical memory utilization (curr_mem - pre_avg_mem) is used as the memory utilization difference. Based on the formula wei_diff1 = p1 × (curr_cpu - pre_avg_cpu) + p2 × (curr_mem - pre_avg_mem), a weighted sum of the differences in CPU utilization and memory utilization is used to obtain a first weighted value wei_diff1. A first preset difference threshold threshold1 is then determined. If the first weighted value wei_diff1 is greater than the first preset difference threshold threshold1, then the target container is considered to have triggered a crash risk event at the current moment. Preset CPU utilization and preset memory utilization can be set according to actual needs. The sum of p1 and p2 is 1, and their values can be determined based on the degree of influence of CPU and memory on the container. This allows for timely detection of container crash risks, helps to save valid data in a timely manner, and thus improves container management efficiency.
[0055] In this embodiment, optionally, determining the event of a significant change in the snapshot size of the target container at the current moment based on the historical operating indicator data and the current operating indicator data includes: determining an average historical disk utilization rate based on the historical disk utilization rates; if it is determined that the current disk utilization rate is greater than a preset disk utilization rate, and the current memory utilization rate is greater than the preset memory utilization rate, then determining a disk utilization rate difference based on the average historical disk utilization rate and the current disk utilization rate; performing a weighted summation of the absolute value of the disk utilization rate difference and the absolute value of the memory utilization rate difference to obtain a second weighted value; determining a second preset difference threshold; if it is determined that the second weighted value is greater than the second preset difference threshold, then determining that the event of a significant change in the snapshot size of the target container at the current moment is triggered.
[0056] Extensive experimental data revealed that changes in disk and memory usage affect snapshot size. A higher disk usage rate results in a larger snapshot, as does a higher memory usage rate. Therefore, disk and memory usage are positively correlated with snapshot size. However, the impact of disk and memory usage on snapshot size varies among different containers. For example, database containers like MySQL, PostgreSQL, and MongoDB rely more heavily on disk storage, making an increase in disk usage more significant for them. Conversely, containers like Tomcat and Memcached rely more on memory, making an increase in memory usage more crucial for snapshot size.
[0057] The average historical disk utilization rate, `pre_avg_disk`, is determined based on the average historical disk utilization rate within the target historical time interval, and the average historical memory utilization rate, `pre_avg_mem`, is determined based on the average historical memory utilization rate within the target historical time interval. If the current disk utilization rate, `curt_disk`, is greater than the preset disk utilization rate, and the current memory utilization rate, `curr_mem`, is greater than the preset memory utilization rate, then the difference between the current disk utilization rate and the average historical disk utilization rate, `curr_disk - pre_avg_disk`, is used as the disk utilization rate difference, and the difference between the current memory utilization rate and the average historical memory utilization rate, `curr_mem - pre_avg_mem`, is used as the memory utilization rate difference. Based on the formula wei_diff2=k1×|curr_disk-pre_avg_disk|+k2×|curr_mem-pre_avg_mem|, a second weighted value wei_diff2 is obtained by weighted summing the absolute values of the differences in disk usage and memory usage. A second preset difference threshold threshold2 is then determined. If the second weighted value wei_diff2 is greater than the second preset difference threshold threshold2, then a significant change in the snapshot size of the target container at the current moment is identified. The preset disk usage and preset memory usage can be set according to actual needs. The sum of k1 and k2 is 1, and their values can be determined based on the degree of influence of disk and memory on the snapshot size. This allows for timely detection of risks of significant changes in container snapshot size, helps to save valid data in a timely manner, and thus improves container management efficiency.
[0058] In this embodiment, optionally, determining the target container triggering an automatic restart risk event based on the running indicator data includes: if it is determined that the duration for which the CPU utilization rate of the target container is greater than the preset CPU utilization rate is greater than a first preset duration, or if it is determined that the duration for which the memory utilization rate of the target container is greater than the preset memory utilization rate is greater than a second preset duration, then it is determined that the target container triggers an automatic restart risk event at the current moment.
[0059] CPU and memory are critical resources required for the normal operation of containers. If a container maintains a high CPU and memory utilization rate, it will continuously consume these resources until they reach or exceed their availability limits. When resources are exhausted, the container can no longer operate normally and will automatically restart because it cannot obtain sufficient resources.
[0060] This solution can statistically analyze the duration for which the CPU utilization of a target container exceeds a preset CPU utilization rate, and the duration for which the memory utilization of a target container exceeds a preset memory utilization rate. Based on the relationship between these durations and first and second preset durations, it determines the current moment when the target container may trigger an automatic restart risk event. The first and second preset durations can be set according to actual needs. For example, if the CPU utilization or memory utilization of a MySQL container remains at 90% for one minute, it is determined that the container may trigger an automatic restart risk event; similarly, if the CPU utilization or memory utilization of a web container remains at 95% for five minutes, it is determined that the container may trigger an automatic restart risk event. This allows for timely detection of container automatic restart risk events, helping to save valid data promptly and thus improving container management efficiency.
[0061] In this embodiment, optionally, after determining the operating index data of the target container according to a preset period, the method further includes: if it is determined from the operating index data that the target container has not triggered a snapshot generation event within a preset time period, then a target snapshot of the target container is generated.
[0062] Assuming a preset time period of 1 hour, this solution generates a target snapshot of the target container every hour if operational metrics determine that the target container has not triggered a snapshot generation event within 1 hour. This enables timely saving of valid data, thereby improving container management efficiency.
[0063] Furthermore, this invention provides a snapshot storage strategy. When local storage space is insufficient to accommodate the generated snapshot, this solution directly stores the snapshot in a cloud storage device, such as... Figure 2bAs shown. However, when the local storage space is sufficient to accommodate a certain number of snapshots, this solution can adopt a snapshot weight-based transfer storage mechanism, where the snapshot weight is determined in three snapshot generation scenarios: 1. When the container snapshot size changes significantly, the snapshot weight is the difference between wei_diff2 and threshold2; 2. When the container is at risk of crashing, the snapshot weight is the difference between wei_diff1 and threshold1; 3. When the container is at risk of automatic restart, the snapshot weight is the sum of the CPU utilization and memory utilization at the time of snapshot generation. The storage management method will be explained in detail below:
[0064] First, this solution calculates the maximum number of snapshots that can be stored based on local storage space, let's say 20. The specific calculation method is to divide the local storage space by the size of the most recently generated snapshot. When the number of generated snapshots is half of the maximum local storage capacity, let's say 10, the weight of each snapshot is calculated and stored. Then, the snapshots are sorted according to their weights, and the snapshot with the highest weight value is selected and retained, while the previous 10 snapshots are deleted. For example... Figure 2c As shown, each small square represents a generated snapshot, and the number in the square represents the snapshot weight. The snapshot with the highest weight among the 10 snapshots is retained locally. Figure 2d As shown, when the number of locally filtered snapshots reaches half of the maximum local storage capacity (10 in this example), the snapshots are sorted according to their weights, and the snapshots with the highest weights are stored in the cloud. The 10 locally filtered snapshots are then deleted, and the process is repeated locally. Depending on the local storage space and snapshot weights, the system can flexibly choose to store snapshots locally or in the cloud. This backup method offers flexibility and can be adjusted according to actual needs, improving the flexibility and reliability of data backup.
[0065] Besides choosing to store snapshots locally or in the cloud based on available local storage space, other storage options can be considered. For example, the optimal storage location can be dynamically selected based on factors such as network bandwidth and storage costs, including local storage, cloud storage, or hybrid storage.
[0066] The technical solution of this invention determines the operational indicator data of the target container according to a preset period, determines a preset moving window, determines a target historical time interval based on the current time, the preset moving window, and the preset period, determines each historical operational indicator data within the target historical time interval, and if, based on each historical operational indicator data and the current operational indicator data at the current time, it is determined that the target container triggers a snapshot generation event at the current time, then a target snapshot of the target container at the current time is generated. By implementing the technical solution provided by this invention, flexible container management can be achieved, better adapting to the actual state and changes of the container, and ensuring the timeliness and effectiveness of data backup.
[0067] Figure 3 This is a schematic diagram of the container snapshot generation apparatus provided in an embodiment of the present invention. Figure 3 As shown, the device includes:
[0068] The operation indicator data determination module 310 is used to determine the operation indicator data of the target container according to a preset period; the target container is a running container; the operation indicator data includes at least one of the target container's CPU utilization, memory utilization, and disk utilization.
[0069] The target snapshot generation module 320 is used to generate a target snapshot of the target container at the current moment if the target container triggers a snapshot generation event at the current moment based on the operation index data; the snapshot generation event includes at least one of the following: an automatic restart risk event, a crash risk event, and a significant change in snapshot size.
[0070] Optionally, the device further includes a preset moving window determination module, used to determine a preset moving window before determining that the target container triggers a snapshot generation event at the current time based on the operation index data; a target snapshot generation module 320, including a target historical time interval determination module, used to determine a target historical time interval based on the current time, the preset moving window, and the preset period; a historical operation index data determination module, used to determine each historical operation index data within the target historical time interval; and a snapshot generation event trigger determination unit, used to determine that the target container triggers a snapshot generation event at the current time based on each of the historical operation index data and the current operation index data at the current time.
[0071] Optionally, the snapshot generation event determination unit is specifically configured to: determine the average historical CPU utilization rate based on each of the historical CPU utilization rates; determine the average historical memory utilization rate based on each of the historical memory utilization rates; if it is determined that the current CPU utilization rate is greater than a preset CPU utilization rate and the current memory utilization rate is greater than a preset memory utilization rate, then determine the CPU utilization rate difference based on the average historical CPU utilization rate and the current CPU utilization rate; determine the memory utilization rate difference based on the average historical memory utilization rate and the current memory utilization rate; perform a weighted summation of the CPU utilization rate difference and the memory utilization rate difference to obtain a first weighted value; determine a first preset difference threshold; if it is determined that the first weighted value is greater than the first preset difference threshold, then determine that the target container triggers a crash risk event at the current moment.
[0072] Optionally, the snapshot generation event determination unit is specifically used to determine the average historical disk usage rate based on each of the historical disk usage rates; if it is determined that the current disk usage rate is greater than the preset disk usage rate, and the current memory usage rate is greater than the preset memory usage rate, then a disk usage rate difference is determined based on the average historical disk usage rate and the current disk usage rate; a second weighted value is obtained by weighted summation of the absolute value of the disk usage rate difference and the absolute value of the memory usage rate difference; a second preset difference threshold is determined; if it is determined that the second weighted value is greater than the second preset difference threshold, then a significant change in snapshot size is triggered for the target container at the current time.
[0073] Optionally, the target snapshot generation module 320 is specifically used to determine that the target container triggers an automatic restart risk event at the current moment if it is determined that the duration for which the CPU utilization rate of the target container is greater than the preset CPU utilization rate is greater than a first preset duration, or if it is determined that the duration for which the memory utilization rate of the target container is greater than the preset memory utilization rate is greater than a second preset duration.
[0074] Optionally, the apparatus further includes a snapshot generation event determination device, which, after determining the operating index data of the target container according to a preset period, generates a target snapshot of the target container if it is determined from the operating index data that the target container has not triggered a snapshot generation event within a preset time period.
[0075] The container snapshot generation apparatus provided in this embodiment of the invention can execute the container snapshot generation method provided in any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0076] Figure 4A schematic diagram of an electronic device 40 that can be used to implement embodiments of the present invention is shown. The electronic device is intended to represent various forms of digital computers, 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, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0077] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42 or a random access memory (RAM) 43, communicatively connected to the at least one processor 41. The memory stores computer programs executable by the at least one processor. The processor 41 can perform various appropriate actions and processes based on the computer program stored in the ROM 42 or loaded into the RAM 43 from storage unit 48. The RAM 43 may also store various programs and data required for the operation of the electronic device 40. The processor 41, ROM 42, and RAM 43 are interconnected via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.
[0078] Multiple components in electronic device 40 are connected to I / O interface 45, including: input unit 46, such as keyboard, mouse, etc.; output unit 47, such as various types of monitors, speakers, etc.; storage unit 48, such as disk, optical disk, etc.; and communication unit 49, such as network card, modem, wireless transceiver, etc. Communication unit 49 allows electronic device 40 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0079] Processor 41 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. Processor 41 performs the various methods and processes described above, such as the method for generating container snapshots.
[0080] In some embodiments, the method for generating a container snapshot may be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program may be loaded and / or mounted on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the method for generating a container snapshot described above may be performed. Alternatively, in other embodiments, processor 41 may be configured to execute the method for generating a container snapshot by any other suitable means (e.g., by means of firmware).
[0081] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0082] Computer programs used to implement the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor, the computer programs cause the functions / operations specified in the flowcharts and / or block diagrams to be performed. The computer programs may be executed entirely on a machine, partially on a machine, or as a standalone software package, partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0083] In the context of this invention, a computer-readable storage medium can be a tangible medium that may contain or store a computer program for use by or in conjunction with an instruction execution system, apparatus, or device. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0084] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device 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 pointing device (e.g., a mouse or trackball) through which the user provides input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0085] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or computing systems that include middleware components (e.g., application servers), or computing systems that include frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include local area networks (LANs), wide area networks (WANs), blockchain networks, and the Internet.
[0086] A computing system can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a hosting product within the cloud computing service system to address the shortcomings of traditional physical hosts and VPS services, such as high management difficulty and weak business scalability.
[0087] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0088] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A method for generating a container snapshot, characterized in that, include: The operational performance data of the target container are determined according to a preset cycle; the target container is a container that is in operation. The operational metrics data include at least one of the target container's CPU utilization, memory utilization, and disk utilization. If the target container triggers a snapshot generation event at the current moment based on the operational metric data, then a target snapshot of the target container at the current moment is generated. The snapshot generation event includes at least one of the following: automatic restart risk event, crash risk event, and snapshot size significantly change event; The method further includes the following steps before determining, based on the operational metric data, that the target container triggers a snapshot generation event at the current moment: Define the preset moving window; Based on the aforementioned operational metric data, the current moment is determined to trigger a snapshot generation event for the target container, including: The target historical time interval is determined based on the current time, the preset moving window, and the preset period. Determine the historical operational indicator data for each target historical time interval; Based on the historical operational indicator data and the current operational indicator data, determine the target container triggering a snapshot generation event at the current moment; The method further includes determining the target container's potential crash risk event at the current moment based on the historical operational indicator data and the current operational indicator data at the current moment. Determine the average historical CPU utilization rate based on each historical CPU utilization rate. Determine the average historical memory utilization rate based on each historical memory utilization rate; If it is determined that the current CPU utilization rate is greater than the preset CPU utilization rate, and the current memory utilization rate is greater than the preset memory utilization rate, then the CPU utilization rate difference is determined based on the average historical CPU utilization rate and the current CPU utilization rate. The memory usage difference is determined based on the average historical memory usage and the current memory usage. The first weighted value is obtained by weighting and summing the difference in CPU utilization and the difference in memory utilization. Determine the first preset difference threshold; If it is determined that the first weighted value is greater than the first preset difference threshold, then it is determined that the target container has triggered a crash risk event at the current moment.
2. The method according to claim 1, characterized in that, It also includes determining, based on the historical operational metrics data and the current operational metrics data, an event indicating a significant change in the snapshot size of the target container at the current moment: Determine the average historical disk utilization rate based on the historical disk utilization rate; If it is determined that the current disk usage rate is greater than the preset disk usage rate, and the current memory usage rate is greater than the preset memory usage rate, then the disk usage rate difference is determined based on the average historical disk usage rate and the current disk usage rate. The second weighted value is obtained by weighting and summing the absolute values of the disk usage difference and the memory usage difference; Determine the second preset difference threshold; If it is determined that the second weighted value is greater than the second preset difference threshold, then it is determined that the target container triggers a significant change in snapshot size at the current moment.
3. The method according to claim 1, characterized in that, It also includes determining, based on the operational metric data, the risk event that the target container will trigger an automatic restart at the current moment: If it is determined that the duration for which the current CPU utilization rate of the target container is greater than the preset CPU utilization rate is greater than a first preset duration, or if it is determined that the duration for which the memory utilization rate of the target container is greater than the preset memory utilization rate is greater than a second preset duration, then it is determined that the target container triggers an automatic restart risk event at the current moment.
4. The method according to claim 1, characterized in that, The method further includes: If, based on the operational metrics data, it is determined that the target container has not triggered a snapshot generation event within a preset time period, then a target snapshot of the target container is generated.
5. An apparatus for generating container snapshots, characterized in that, include: The operation indicator data determination module is used to determine the operation indicator data of the target container according to a preset period; the target container is a container in operation. The operational metrics data include at least one of the target container's CPU utilization, memory utilization, and disk utilization. The target snapshot generation module is used to generate a target snapshot of the target container at the current moment if it is determined from the running indicator data that the target container triggers a snapshot generation event at the current moment. The snapshot generation event includes at least one of the following: automatic restart risk event, crash risk event, and snapshot size significantly change event; The device further includes: A preset moving window determination module is used to determine a preset moving window before the target container triggers a snapshot generation event at the current time, based on the operation index data. The target snapshot generation module includes: The target historical time interval determination module is used to determine the target historical time interval based on the current time, the preset moving window, and the preset period. The historical performance indicator data determination module is used to determine the historical performance indicator data within the target historical time interval; The snapshot generation event determination unit is used to determine the snapshot generation event triggered by the target container at the current moment based on the historical operating indicator data and the current operating indicator data at the current moment. The snapshot generation event determination unit is specifically used for: Determine the average historical CPU utilization rate based on each historical CPU utilization rate. Determine the average historical memory utilization rate based on each historical memory utilization rate; If it is determined that the current CPU utilization rate is greater than the preset CPU utilization rate, and the current memory utilization rate is greater than the preset memory utilization rate, then the CPU utilization rate difference is determined based on the average historical CPU utilization rate and the current CPU utilization rate. The memory usage difference is determined based on the average historical memory usage and the current memory usage. The first weighted value is obtained by weighting and summing the difference in CPU utilization and the difference in memory utilization. Determine the first preset difference threshold; If it is determined that the first weighted value is greater than the first preset difference threshold, then it is determined that the target container has triggered a crash risk event at the current moment.
6. An electronic device, characterized in that, The electronic device includes: At least one processor; and A memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, the computer program being executed by the at least one processor to enable the at least one processor to perform the container snapshot generation method according to any one of claims 1-4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a processor, implement the method for generating a container snapshot according to any one of claims 1-4.
Citation Information
Patent Citations
Cluster fault processing method and device, electronic equipment and readable storage medium
CN114691445A
Preparing containerized applications for backup using a backup services container in a container-orchestration pod
US20210011816A1