Container maintenance methods, apparatus and storage media
By enabling containers to self-check and automatically handle anomalies, the problem of low efficiency in manual maintenance is solved, achieving efficient and accurate container maintenance and ensuring service stability.
Patent Information
- Application Number
- CN202310552091.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-05-16
AI Technical Summary
When a large number of containers are providing services simultaneously, manually maintaining abnormal containers is inefficient and prone to errors, affecting user experience and service stability.
By sending a first message to a message queue when a container detects an abnormal state during its self-check, and the message queue sending a second message to the container controller, the container controller responds and destroys the container with the abnormal state, thus achieving automated maintenance.
This significantly reduces the workload of operations and maintenance personnel, improves the efficiency and accuracy of maintaining abnormal containers, and ensures service continuity.
Smart Images

Figure CN116599826B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of financial technology or other related fields, and in particular to a container maintenance method, apparatus and storage medium. Background Technology
[0002] In recent years, with the popularization of technologies such as microservices and containerization, more and more applications have been broken down into multiple small services. Each service will run multiple identical service instances at the same time to distribute the pressure on a single service from a huge number of users, thereby improving service stability and reducing business risks. A container can be understood as an independent micro-operating system that can run application and service instances inside.
[0003] During the operation of a service instance, various reasons can cause the container to malfunction, requiring a restart before the service instance running within it can function normally. If users encounter service instances running in malfunctioning containers, it degrades the user experience and may even pose risks to their finances or information. Therefore, it is crucial to promptly identify and address containers in abnormal states.
[0004] In related technologies, after a container is found to be unusable, it can be manually maintained by operations personnel. Specifically, this involves destroying the container and starting a new one to run the service instance. However, when a large number of containers are providing services simultaneously, manually maintaining malfunctioning containers is inefficient and prone to errors. Summary of the Invention
[0005] This application provides a container maintenance method, apparatus, and storage medium to simplify the work of maintenance personnel and improve maintenance efficiency.
[0006] In a first aspect, this application provides a container maintenance method. The method is applied to a server on which containers, a container controller, and a message queue are running. The container controller and the message queue are built based on Node.js technology. The method includes: when a container detects an abnormal state during self-checking, it sends a first message to the message queue, the first message carrying the container's identifier; the message queue sends a second message to the container controller, the second message carrying the identifier of the abnormal container; and the container controller responds to the second message and destroys the abnormal container.
[0007] Based on the above methods, automated container maintenance can be achieved, which can greatly reduce the workload of operation and maintenance personnel, improve the efficiency of maintaining abnormal containers, and improve the accuracy of maintaining abnormal containers, which is conducive to ensuring service continuity.
[0008] In conjunction with the first aspect, in some possible implementations of the first aspect, the abnormal state includes: memory usage exceeding a first preset threshold, and / or, network latency exceeding a second preset threshold.
[0009] In conjunction with the first aspect, in some possible implementations of the first aspect, the container performs a self-check every preset time interval.
[0010] In conjunction with the first aspect, in some possible implementations of the first aspect, multiple containers run in the server, and the method further includes: a message queue responding to receiving a first message and storing the first message.
[0011] In conjunction with the first aspect, in some possible implementations of the first aspect, the message queue sends a second message to the container controller, including: the message queue sends a second message to the container controller when the number of stored first messages reaches a preset threshold.
[0012] In conjunction with the first aspect, in some possible implementations of the first aspect, after the container controller destroys the container, the method further includes: the container controller starting a corresponding number of new containers, the number of new containers being greater than or equal to the number of containers destroyed.
[0013] In conjunction with the first aspect, in some possible implementations of the first aspect, the method further includes: responding to the start instructions of the container controller and the message queue, starting the container controller and the message queue; the container controller starts the container, wherein the number of containers is determined according to business requirements.
[0014] Secondly, this application provides a container maintenance device applied to a server, on which a container, a container controller, and a message queue run. The container controller and the message queue are built based on Node.js technology. The container is used to send a first message to the message queue when it detects an abnormal state during self-checking. The first message carries the identifier of the container. The message queue is used to send a second message to the container controller. The second message carries the identifier of the container with the abnormal state. The container controller is used to respond to the second message and destroy the container with the abnormal state.
[0015] In conjunction with the second aspect, in some possible implementations of the second aspect, the message queue can also be used to store the first message in response to its receipt.
[0016] In conjunction with the second aspect, in some possible implementations of the second aspect, a message queue can be used to send a second message to the container controller when the number of stored first messages reaches a preset threshold.
[0017] In conjunction with the second aspect, in some possible implementations of the second aspect, the container controller can also be used to launch a corresponding number of new containers, the number of new containers being greater than or equal to the number of containers destroyed.
[0018] In conjunction with the second aspect, in some possible implementations of the second aspect, the container controller and message queue can also be used to start the container controller and message queue in response to the start command of the container controller and message queue; the container controller can also be used to start containers, wherein the number of containers is determined according to business requirements.
[0019] Thirdly, this application provides a container maintenance apparatus, including a memory and a processor, wherein the memory is used to store a computer program; and the processor is used to invoke and execute the computer program to implement the methods in the first aspect and any possible implementation of the first aspect.
[0020] Fourthly, this application provides a computer-readable storage medium including a computer program that, when run on a computer, causes the computer to implement the methods of the first aspect and any possible implementation of the first aspect.
[0021] Fifthly, this application provides a computer program product comprising: a computer program (also referred to as code or instructions) that, when run, causes a computer to perform the methods of the first aspect and any possible implementation thereof. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0023] Figure 1 This is a flowchart illustrating a method for manual maintenance of containers by operators in the prior art, as provided in an embodiment of this application.
[0024] Figure 2 This is a schematic flowchart of the container maintenance method provided in the embodiments of this application;
[0025] Figure 3 This is another schematic flowchart of the container maintenance method provided in the embodiments of this application;
[0026] Figure 4 This is a schematic block diagram of the server provided in the embodiments of this application;
[0027] Figure 5 This is another schematic block diagram of the server provided in the embodiments of this application.
[0028] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0029] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0030] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments.
[0031] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0032] In the embodiments of this application, the terms "first," "second," etc., are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. Furthermore, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion.
[0033] Container: A container is a collection of processes with isolated views, limited resources, and an independent file system. It isolates the system from other resources (including processes, file systems, and network resources), giving it its own independent resource view. It can be understood as an independent miniature operating system that can run applications and services. This container, containing the system, applications, and services, is small and easily and quickly copied and expanded.
[0034] Figure 1 This is a flowchart illustrating the method of manual maintenance of containers by operations and maintenance personnel in existing technologies. For example... Figure 1 As shown, the current method 100 for manual maintenance of containers by operations and maintenance personnel follows this process:
[0035] In step 110, in response to the operation and maintenance personnel's operation, the container is started and the service instance is run.
[0036] Operations personnel can manually start the container, which can be used to run service instances and provide services to the outside world.
[0037] In step 120, the working status of the container is checked.
[0038] When a containerized service instance provides services to the outside world, operations and maintenance personnel can manually check the working status of the container periodically or irregularly. Alternatively, operations and maintenance personnel can also check the working status of the container in batches by running scripts or other methods.
[0039] In addition, a monitoring system can be introduced to monitor the current working status of the container in real time. If the working status of the container is abnormal, the monitoring system can notify the operation and maintenance personnel by sending system messages.
[0040] In step 130, if the container is not usable, it is destroyed in response to the operation and maintenance personnel's actions.
[0041] Regardless of the method used to check the container's working status, once the operations and maintenance personnel discover a container with an abnormal working status, they should manually destroy the container.
[0042] In step 140, in response to the operations personnel's actions, a new container is started to run the service instance.
[0043] To ensure the normal operation of service instances, operations and maintenance personnel can start a new container to replace the previously destroyed container, and the new container can continue to run the service instance.
[0044] While the above methods can promptly detect containers with abnormal operating states and notify operations personnel by introducing a monitoring system, the following problems still exist:
[0045] 1. If operations and maintenance personnel check the working status of containers in a purely manual manner, it will be very stressful for them and the operability is very low. It requires 24-hour uninterrupted manual inspection.
[0046] 2. Even if a container with abnormal working status is detected in a timely manner through a monitoring system, the timeliness of the system messages received by the operations and maintenance personnel cannot be guaranteed, and the operations and maintenance personnel also need to be on standby 24 hours a day to deal with containers with abnormal working status.
[0047] 3. The workload of operations and maintenance personnel manually destroying containers with abnormal working status and starting new containers is still relatively large.
[0048] 4. When destroying containers that are not functioning correctly, precise matching is required, as manual operation is prone to errors. If maintenance personnel destroy containers that are functioning correctly while manually maintaining containers, it may introduce new problems.
[0049] In summary, when the number of containers is small, operations and maintenance personnel can maintain them manually with relative ease. However, as the number of containers increases and a large number of containers provide services simultaneously, the pressure on operations and maintenance personnel to maintain containers also increases. Manually maintaining abnormal containers is inefficient and prone to errors.
[0050] In view of this, this application provides a highly automated method for destroying and restarting containers and services, which can realize automated container maintenance, thereby greatly reducing the workload of operation and maintenance personnel, improving the efficiency of maintaining abnormal containers, and improving the accuracy of maintaining abnormal containers, which is conducive to ensuring service continuity.
[0051] Figure 2 This is a schematic flowchart of a container maintenance method provided in an embodiment of this application. The method 200 includes steps 210 to 230. The steps in the method 200 are described in detail below.
[0052] This method is applied to servers that run containers, container controllers, and message queues.
[0053] The container controller is primarily used to automatically start and destroy containers, either individually or in batches. The message queue records which containers encounter problems and sends messages to the container controller. This allows the container controller to precisely control and handle problematic containers based on the messages in the queue.
[0054] In terms of technical implementation, the container controller and the message queue are two independently running programs, developed and implemented using Node.js technology. The container controller subscribes to the contents of the message queue, and once the contents of the message queue change, it will actively notify the container controller, which can then perform the corresponding logical operations.
[0055] In step 210, when the container detects an abnormal state during self-checking, it sends a first message to the message queue, which carries the container's identifier.
[0056] In some embodiments, operations personnel can send start commands to the server for the container controller and message queue. In response to these commands, the server starts the container controller and message queue. After the container controller starts, containers can be started, and service instances can then run within these containers. The number of containers started can be determined based on business requirements.
[0057] The container startup process does not require manual intervention from operations personnel; it can be performed automatically by the container controller.
[0058] Optionally, the container can have a timed task for self-checking, whereby the container checks its own working status at preset intervals. The preset interval can be, for example, 10 seconds, 30 seconds, or 1 minute, and this application does not limit the setting of the preset interval.
[0059] The self-checks performed by the container can include memory checks and network latency checks. If the container's memory usage exceeds a first preset threshold, or if the container's network latency exceeds a second preset threshold, or if both of these conditions are met, the container can be considered to be in an abnormal state.
[0060] The first preset threshold can be a preset memory size, such as 2 gigabytes (GB), 3GB, or 4GB, or a preset percentage of total memory usage, such as 80%, 90%, or 95%. This application does not limit this.
[0061] When a container detects an abnormality in its own working state, it can send a first message to the message queue, which carries the container's identifier.
[0062] For example, if the container is identified as "Container 1", then the first message could be "Container 1". Alternatively, the first message could specify the specific type of the status exception, such as "Container 1, memory exception", "Container 1, network latency exception", or "Container 1, memory exception, network latency exception".
[0063] In step 220, the message queue sends a second message to the container controller, which carries the identifier of the container with the abnormal status.
[0064] After receiving the first message from the container, the message queue can send a second message to the container controller, which carries the identifier of the container in an abnormal state.
[0065] For example, if the container with the abnormal status is identified as "Container 1", then the second message can be "Container 1". Alternatively, the second message can specify the specific type of abnormal status, such as "Container 1, memory abnormality", "Container 1, network latency abnormality", or "Container 1, memory abnormality, network latency abnormality".
[0066] Optionally, multiple containers can run on the server, and the message queue can store the first message after receiving the first message from the container.
[0067] If the number of first messages stored in the message queue reaches a preset threshold, the message queue can send a second message to the container controller, which carries the identifier of the container in an abnormal state.
[0068] Accumulating multiple first messages in the message queue before sending the second message, compared to sending a second message every time a first message is received, helps prevent the container controller from being started frequently, reduces the frequency of container startup and destruction, and thus benefits the normal operation of the server.
[0069] For example, if the preset threshold for the number of first messages is 3, and the containers with abnormal states are identified as "container 1", "container 2", and "container 3", then the second message can be "container 1; container 2; container 3". Alternatively, the second message can specify the specific type of abnormal state, for example, the second message can be "container 1, memory abnormality; container 2, network latency abnormality; container 3, memory abnormality, network latency abnormality".
[0070] In step 230, the container controller responds to the second message and destroys the container in the abnormal state.
[0071] The container controller can destroy the corresponding container based on the identifier of the abnormal container carried in the second message.
[0072] For example, if the second message is "container 1; container 2; container 3", the container controller can destroy containers 1, 2, and 3 based on the identifier of the abnormal container carried in the second message.
[0073] Based on the container maintenance method provided in this application embodiment, when a container detects an abnormal state during self-checking, it sends a first message to a message queue, the first message carrying the container's identifier; the message queue sends a second message to the container controller, the second message carrying the identifier of the abnormal container; the container controller responds to the second message and destroys the abnormal container, thereby achieving automated container maintenance, which greatly reduces the workload of operation and maintenance personnel, improves the efficiency of maintaining abnormal containers, and also improves the accuracy of maintaining abnormal containers, which is conducive to ensuring service continuity.
[0074] Optionally, after the container controller destroys a container, it can also start new containers, with the number of new containers being greater than or equal to the number of containers destroyed.
[0075] The new container can be used to replace the previously destroyed container to run the service instances in the previously destroyed container, thereby ensuring the normal operation of the entire business.
[0076] Figure 3 This is another schematic flowchart of the container maintenance method provided in the embodiments of this application, which is described below in conjunction with... Figure 3 This document details the maintenance methods for this container.
[0077] In step 301, the operations and maintenance personnel send start commands for the container controller and message queue to the server. In response to the start commands, the server starts the container controller and message queue.
[0078] After the container controller and message queue are started, a message channel can be established between the container controller and the message queue. The container controller can subscribe to the contents of the message queue and receive messages from the message channel.
[0079] In step 302, after the container controller starts, the container can be started.
[0080] The number of containers launched can be determined based on business needs. Launching containers does not require manual intervention from operations personnel.
[0081] In step 303, the container checks its own working status every preset time interval.
[0082] The self-checks performed by the container can include memory checks and network latency checks. If the container's memory usage exceeds a first preset threshold, or if the container's network latency exceeds a second preset threshold, or if both of these conditions are met, the container can be considered to be in an abnormal state.
[0083] In step 304, if the container detects an abnormality in its own working state, it sends the first message to the message queue.
[0084] The container's identifier is carried in the first message.
[0085] In step 305, the message queue stores the first message received from the container.
[0086] Multiple containers can run on the server. After receiving the first message from a container, the message queue can store the first message.
[0087] In step 306, if the number of first messages stored in the message queue reaches a preset threshold, a second message is sent to the container controller.
[0088] The second message carries an identifier for the container in an abnormal state.
[0089] In step 307, the container controller responds to the second message by destroying the container in an abnormal state.
[0090] The container controller can destroy the corresponding container based on the identifier of the abnormal container carried in the second message.
[0091] In step 308, the container controller starts a new container.
[0092] The number of new containers is greater than or equal to the number of destroyed containers. New containers can be used to replace previously destroyed containers to run service instances within those containers, thus ensuring the normal operation of the entire business.
[0093] The container maintenance method provided in this application can be applied not only to situations where container operation is abnormal due to excessive memory consumption, but also to situations where container operation is abnormal due to various other reasons, such as container network latency issues. The container maintenance method provided in this application is a highly automated and efficient approach and implementation, with significant market potential.
[0094] Figure 4 This is a schematic block diagram of a container maintenance device provided in an embodiment of this application. The container maintenance device 400 is applied to a server, on which a container 410, a message queue 420, and a container controller 430 are running. The message queue 420 and the container controller 430 are built based on Node.js technology.
[0095] Container 410 is used to send a first message to a message queue when it detects an abnormal state during self-checking. The first message carries the identifier of the container. Message queue 420 is used to send a second message to the container controller. The second message carries the identifier of the container with the abnormal state. Container controller 430 is used to respond to the second message and destroy the container with the abnormal state.
[0096] Optionally, message queue 420 can also be used to store the first message in response to its receipt.
[0097] Optionally, message queue 420 can be used to send a second message to the container controller when the number of stored first messages reaches a preset threshold.
[0098] Optionally, the container controller 430 can also be used to start a corresponding number of new containers, the number of new containers being greater than or equal to the number of containers destroyed.
[0099] Optionally, message queue 420 and container controller 430 can also be used to start container controller and message queue in response to start instructions from container controller and message queue; container controller 430 can also be used to start containers, wherein the number of containers is determined according to business requirements.
[0100] Figure 5 This is another schematic block diagram of the container maintenance device provided in the embodiments of this application. For example... Figure 5 As shown, the container maintenance device 500 may include at least one processor 510, which can be used to implement the functions of the container maintenance device in the method provided in this application. See the detailed description in the method examples for further details, which will not be repeated here.
[0101] The container maintenance device 500 may further include a memory 520 for storing program instructions and / or data. The memory 520 is coupled to the processor 510. The coupling in this application is an indirect coupling or communication connection between devices, units, or modules, which may be electrical, mechanical, or other forms, for information exchange between devices, units, or modules. The processor 510 may operate in conjunction with the memory 520. The processor 510 may execute program instructions stored in the memory 520. At least one of the at least one memories may be included in the processor.
[0102] The container maintenance device 500 may also include a communication interface 530 for communicating with other devices via a transmission medium, thereby enabling communication between devices within the container maintenance device 500 and other devices. The communication interface 530 may be, for example, a transceiver, interface, bus, circuit, or a device capable of transmitting and receiving functions. The processor 510 may utilize the communication interface 530 to transmit and receive data and / or information, and to implement... Figure 2 or Figure 3 The container maintenance method described in the corresponding embodiment.
[0103] This application does not limit the specific connection medium between the processor 510, memory 520, and communication interface 530. Figure 5 The processor 510, memory 520, and communication interface 530 are connected via bus 540. Bus 540 is... Figure 5 The connections between other components are shown in bold and are for illustrative purposes only, not as limiting information. The bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.
[0104] In the embodiments of this application, the processor may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in this application can be directly manifested as being executed by a hardware processor, or executed by a combination of hardware and software modules within the processor.
[0105] According to the method provided in this application, this application also provides a computer-readable storage medium storing program code, which, when executed on a computer, causes the computer to perform... Figure 2 or Figure 3The container maintenance method described in the corresponding embodiment.
[0106] According to the method provided in this application, this application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to perform... Figure 2 or Figure 3 The container maintenance method described in the corresponding embodiment.
[0107] The technical solutions provided in this application can be implemented in whole or in part through software, hardware, firmware, or any combination thereof. When implemented using software, they can be implemented in whole or in part as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a terminal device, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired means, such as coaxial cable, optical fiber, digital subscriber line (DSL), or wireless means (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium such as a digital video disc (DVD), or a semiconductor medium, etc.
[0108] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A container maintenance method, characterized in that, Applied to a server, the server running multiple containers, a container controller, and a message queue, wherein the container controller and the message queue are built based on Node.js technology, the method includes: The container performs a self-check at preset intervals. When the container detects an abnormal state during the self-check, it sends a first message to the message queue, which carries the container's identifier. The message queue responds to receiving the first message and stores the first message; When the number of stored first messages reaches a preset threshold, the message queue sends a second message to the container controller, the second message carrying an identifier of the container with an abnormal status. The container controller responds to the second message by destroying the container in the abnormal state; The container controller starts a corresponding number of new containers, and the number of new containers is greater than or equal to the number of containers destroyed.
2. The method according to claim 1, characterized in that, The abnormal status includes: Memory usage exceeds a first preset threshold, and / or network latency exceeds a second preset threshold.
3. The method according to claim 1 or 2, characterized in that, The method further includes: In response to the start command of the container controller and the message queue, start the container controller and the message queue; The container controller starts containers, wherein the number of containers is determined according to business requirements.
4. A container maintenance device, said container maintenance device being used to implement the container maintenance method according to any one of claims 1-3, characterized in that, It is applied to a server, on which containers, a container controller, and a message queue are running, wherein the container controller and the message queue are built based on Node.js technology; The container is used to send a first message to the message queue when an abnormal state is detected by self-checking. The first message carries the container's identifier. The message queue is used to send a second message to the container controller, the second message carrying an identifier of the container with an abnormal state; The container controller is configured to destroy the container in the abnormal state in response to the second message.
5. A container maintenance device, characterized in that, Including memory and processor, among which, The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method as described in any one of claims 1 to 3.
6. A computer-readable storage medium, characterized in that, Includes a computer program that, when run on a computer, causes the computer to perform the method as described in any one of claims 1 to 3.
7. A computer program product, characterized in that, Includes a computer program that, when run, causes a computer to perform the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Container scheduling method and device, equipment and storage medium
CN114564281A