Container application migration method and system and storage medium
Through script identification and replacement of dependency information, compiling and reconstructing container images, and adapting system calls, the stability and efficiency problems of container applications in X86 architecture to ARM architecture migration are solved, and efficient operation on ARM architecture is achieved.
Patent Information
- Application Number
- CN202510668398.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-23
- Publication Date
- 2025-07-04
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
When the prior art migrates container applications of X86 architecture to ARM architecture, it is difficult to ensure that container applications operate efficiently and stably under the new architecture environment, and relying on manual dependency analysis is prone to missed system calls and dependencies.
Identify the current architecture type through scripts, extract the dependency manifest and call information, compile it into an executable file under the target architecture, replace the dependency library file, reconstruct the container image using the basic image of the target architecture, and adapt the system calls through the LD_PRELOAD mechanism, and replace the instruction set with the cross-compilation toolchain.
Ensure that container applications operate efficiently and stably on the target architecture, reduce the possibility of dependency omissions, and improve the accuracy and efficiency of migration.
Smart Images

Figure CN120255903A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software engineering, and particularly to a method, system, and storage medium for migrating container applications. Background Art
[0002] In the context of the rapid development of containerization technology, many applications are deployed in a containerized manner on different hardware architectures. When it is necessary to migrate a container application based on the X86 architecture to the ARM architecture, the container application migration solutions involved in related technologies usually only solve some basic compatibility problems and are difficult to ensure the efficient and stable operation of the container application in the new architecture environment. In addition, when performing the migration operation, the container application migration method in related technologies often relies on manual labor to perform dependency analysis and generate a dependency list. Due to the lack of automated analysis means, this method is prone to missing system calls, library files, and other dependencies necessary for the operation of the container application, resulting in the container application being unable to start and run normally on the target architecture (ARM architecture), or having unstable running performance. Summary of the Invention
[0003] The present invention provides a method, system, and storage medium for migrating container applications, aiming to solve at least one of the technical problems existing in the prior art.
[0004] The technical solution of the present invention is a method for migrating container applications, including: Identifying the current architecture type of the container application through a script; If the current architecture type is different from the target architecture type, extracting a dependency list and call information through the script; Compiling the source code of the current architecture of the container application into an executable file under the target architecture; Replacing the dependency library files of the container application under the current architecture with the dependency library files under the target architecture; Based on the dependency list and the call information, reconstructing the container image using the base image of the target architecture to ensure that the container application can run on the target architecture; Intercepting and redirecting system calls through the LD_PRELOAD mechanism to make the system calls adapt to the target architecture; Replacing the instruction set of the current architecture with the instruction set of the target architecture by using a cross-compilation toolchain; Performing a migration operation on the container application.
[0005] According to some embodiments of the present invention, the call information includes system call information and dependency library call information; Extracting call information through the script includes: In the script, the strace command is used to extract the system call information; The ltrace command is used to extract the dependency library call information of the container application.
[0006] According to some embodiments of the present invention, the dependency list includes a dependency library list and a binary file type list; By means of a script, the current architecture type of the container application is identified, and a dependency list is extracted, including: In the script, the file command is used to identify the current architecture type of the container application and extract the binary file type list; The readelf command and the ldd command are used to extract the dependency library list.
[0007] According to some embodiments of the present invention, the source code of the current architecture of the container application is compiled into an executable file under the target architecture; the dependency library files under the current architecture of the container application are replaced with the dependency library files under the target architecture; based on the dependency list and the call information, the container image is reconstructed using the base image of the target architecture to ensure that the container application can run on the target architecture, including: Configure the cross-compilation toolchain; Through the cross-compilation toolchain, the source code of the current architecture of the container application is compiled into the executable file under the target architecture; Install the dependency library files under the target architecture through apt-get; Specify the base image of the target architecture, copy the dependency library files and binary files to the target architecture platform based on the dependency library list and the binary file type list, specify the command that the container application executes by default when starting, and reconstruct the container image based on the base image of the target architecture through the docker tool; Check whether the container image contains all the required resources and files according to the dependency library files, the binary files and the call information.
[0008] According to some embodiments of the present invention, after the migration operation of the container application, the container application migration method further includes: Use sar and dstat to collect the first performance data of the container application before migration, and generate a performance baseline according to the first performance data; When the container application is started for the first time on the target architecture platform, control the container application to be preheated, check the performance of the container application to obtain a performance result, and obtain a performance bottleneck based on the performance result and the performance baseline; When the container application runs on the target architecture platform, kernel events are traced through eBPF, and bpftrace is used to capture the performance bottleneck; An alarm is triggered for the performance bottleneck to notify relevant personnel, and a resource adjustment operation is triggered based on the performance bottleneck.
[0009] According to some embodiments of the present invention, generating a performance baseline based on the first performance data includes: Cleaning and structuring the first performance data in a time series to extract key metrics; Calculating the mean, maximum, minimum, and standard deviation of each key metric; Based on the mean, the maximum, the minimum, and the standard deviation, obtaining a benchmark interval for each key metric, and obtaining the performance baseline according to the benchmark interval.
[0010] According to some embodiments of the present invention, after performing the migration operation on the container application, the container application migration method further includes: Through a prediction model, predicting the load value in the next time period according to the historical running load data, and reserving resources according to the predicted load value in the next time period to facilitate the completion of the resource adjustment operation; Through a reinforcement learning model, obtaining a reward according to the environmental state and decision-making actions, and iterating out a better decision-making action according to the second performance data, the decision-making actions, and the reward of the migrated container application collected in real time; Issuing an action instruction based on the better decision-making action to complete the resource adjustment operation.
[0011] The technical solution of the present invention also relates to a container application migration system for executing a container application migration method as described above. The container application migration system includes: A container analysis module for identifying the current architecture type of the container application and extracting a dependency list and call information; An architecture conversion module for compiling the source code of the current architecture of the container application into an executable file under the target architecture, replacing the dependency library file under the current architecture of the container application with a dependency library file under the target architecture, and reconstructing the container image; the container analysis module is connected to the architecture conversion module; A compatibility optimization module for adapting system calls to the target architecture and replacing the instruction set of the current architecture with the instruction set of the target architecture; the architecture conversion module is connected to the compatibility optimization module; A migration module for performing a container application migration operation; the compatibility optimization module is connected to the migration module.
[0012] According to some embodiments of the present invention, the container application migration system further includes: A performance guarantee module, configured to detect performance bottlenecks, trigger an alarm for the performance bottlenecks to notify relevant personnel, and trigger a resource adjustment operation based on the performance bottlenecks; An intelligent scheduling module, configured to iterate out an optimal decision action, issue an action instruction based on the optimal decision action to complete the resource adjustment operation; the performance guarantee module is connected to the intelligent scheduling module.
[0013] The technical solution of the present invention also relates to an electronic device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements a container application migration method as described above.
[0014] The technical solution of the present invention also relates to a storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements a container application migration method as described above.
[0015] The beneficial effects of the present invention include: identifying the current architecture type of the container application through a script to determine whether the current architecture type is different from the target architecture type. If the current architecture type is different from the target architecture type, extracting the dependency list and call information through the script, then compiling the source code of the current architecture of the container application into an executable file under the target architecture, replacing the dependency library file under the current architecture of the container application with the dependency library file under the target architecture, and reconstructing the container image based on the dependency list and call information using the base image of the target architecture to ensure that the container application can run on the target architecture. Through the LD_PRELOAD mechanism, intercepting and redirecting system calls to make the system calls adapt to the target architecture, and by using a cross-compilation toolchain, replacing the instruction set of the current architecture with the instruction set of the target architecture to perform a migration operation on the container application. Extracting the dependency list and call information through the script reduces the possibility of missing the dependency list and call information required for the container application to run, which is beneficial to ensuring the efficient and stable operation of the container application on the target architecture. Compiling the source code of the current architecture of the container application into an executable file under the target architecture, replacing the dependency library file under the current architecture of the container application with the dependency library file under the target architecture, and reconstructing the container image are beneficial to ensuring the efficient and stable operation of the container application on the target architecture.
[0016] In addition, additional aspects and advantages of the present invention will be given in part in the following description, will become apparent in part from the following description, or will be understood through the practice of the present invention. Description of the Drawings
[0017] Figure 1It is an alternative flowchart of a container application migration method in an embodiment of the present invention.
[0018] Figure 2 It is an alternative flowchart of a container application migration method in an embodiment of the present invention.
[0019] Figure 3 It is a schematic diagram of a container application migration system in an embodiment of the present invention. Detailed implementation manners
[0020] The following will clearly and completely describe the concept, specific structure and technical effects of the present invention in combination with embodiments and drawings, so as to fully understand the purpose, solution and effects of the present invention. It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.
[0021] It should be noted that, unless otherwise specified, when a certain feature is referred to as "fixed" or "connected" to another feature, it can be directly fixed or connected to the other feature, or indirectly fixed or connected to the other feature. In addition, the up, down, left, right, top, bottom, etc. used in the present invention are only relative to the mutual positional relationship of the components of the present invention in the drawings.
[0022] In addition, unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the technical field of the present invention. The terms used in the specification of the present invention are only for describing specific embodiments, rather than for limiting the present invention. The term "and / or" used herein includes any combination of one or more related listed items.
[0023] It should be understood that although the terms first, second, third, etc. may be used in the present invention to describe various elements, these elements should not be limited to these terms. These terms are only used to distinguish elements of the same type from each other. For example, without departing from the scope of the present invention, the first element may also be referred to as the second element, and similarly, the second element may also be referred to as the first element.
[0024] Refer to Figure 1 , in some embodiments, the technical solution of the present invention is a container application migration method, including but not limited to steps S101 to S108, and each step will be introduced in turn below.
[0025] Step S101: Identify the current architecture type of the container application through a script.
[0026] Specifically, identify the current architecture type of the container application through a script to determine whether the current architecture type is different from the target architecture type.
[0027] Specifically, a containerized application is an application that runs in a container environment. A container is a lightweight and portable software runtime environment that packages an application and its dependencies together, ensuring that the application runs consistently in any environment that supports the container runtime. The core of container technology is to provide an independent runtime environment for applications through isolation and resource management.
[0028] In a specific embodiment, the current architecture type is the X86 architecture, and the target architecture type is the ARM architecture.
[0029] Step S102: If the current architecture type is different from the target architecture type, extract the dependency list and call information through a script.
[0030] It should be understood that a comprehensive analysis of the source container application is carried out to extract information such as the dependency relationships, system calls, and resource requirements of the container, providing accurate reference data for the subsequent migration process.
[0031] In some embodiments, the dependency list includes a dependency library list and a binary file type list; the current architecture type of the container application is identified through a script, and the dependency list is extracted through the script, including: In the script, the file command is used to identify the current architecture type of the container application and extract the binary file type list; The readelf command and the ldd command are used to extract the dependency library list.
[0032] Specifically, the file command is used to check the binary file type and the current architecture type inside the container. An example is as follows: file / usr / bin / myapp Output: ELF 64-bit LSB executable, x86-64, indicating that this container application is an executable file of the X86 architecture.
[0033] Specifically, the readelf command is used to extract the ELF file header and dependency information. An example is as follows: readelf -d / path / to / application Output example: Dynamic section at offset 0x2f0 contains 31 entries: Tag Value DT_NEEDED libssl.so.1.1 DT_NEEDED libc.so.6 Indicates that this container application depends on two dependent library files, namely libssl.so.1.1 and libc.so.6.
[0034] Specifically, use the ldd command to list the dependency library list. The example is as follows: ldd / path / to / application It should be noted that an executable file is a file that can be loaded and executed by the operating system. A dependency library is a dynamic dependency library, and a Dynamic Dependency Library is a shared library file that a program needs to load during runtime.
[0035] It should be understood that capture the system call information emitted by the container application during runtime to identify potential performance bottlenecks and dependencies.
[0036] In some embodiments, the call information includes system call information and dependent library call information; extract the call information through a script, including: In the script, use the strace command to extract system call information; Use the ltrace command to extract the dependent library call information of the container application.
[0037] Specifically, use the strace command to trace system call information. The example is as follows: strace -f -e trace=open,read,write / path / to / application Recorded system call log: open(" / etc / ssl / certs / ca-certificates.crt", O_RDONLY) = 3 read(3, ...) = 4096 Indicates that the container application accessed the file system during runtime and read the ca-certificates.crt file.
[0038] Specifically, use ltrace to trace the dependent library call information of the container application. The example is as follows: ltrace / path / to / application Output: Displays the call of the container application to libssl.so.1.1.
[0039] In a specific embodiment, after extracting the dependency list and call information through a script, it further includes: converting the dependency list and call information into the JSON format. Specifically, JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy to read and write, and is also easy for machines to parse and generate.
[0040] It should be understood that analyzing the dependency list and call information to generate a report on the dependencies and resource requirements of the container application is convenient for use in the subsequent migration process.
[0041] Specifically, convert the collected dependency list and call information into a structured JSON format. An example is as follows: { "architecture": "x86_64", "libraries": ["libssl.so.1.1", "libc.so.6"], "syscalls": ["open", "read", "write"], "resources": { "cpu": "low", "network_ports": [80, 443] } } Step S103: Compile the source code of the container application in the current architecture into an executable file in the target architecture.
[0042] It should be understood that converting the container application and its dependencies in the X86 architecture into a format compatible with the ARM architecture and generating a new container image.
[0043] Step S104: Replace the dependency library files of the container application in the current architecture with the dependency library files in the target architecture.
[0044] In a specific embodiment, use abidiff to check whether there is an ABI difference between the dependency library files in the current architecture and the dependency library files in the target architecture. If there is an ABI difference, install the dependency library files in the target architecture to adapt the dependency libraries.
[0045] It can be understood that replacing the dynamic dependency libraries of the container application in the X86 architecture with the dynamic dependency libraries in the ARM platform is beneficial to ensuring the compatibility of the container application after migration.
[0046] Specifically, abidiff is a tool used to compare the ABIs of two shared libraries or executable files in the ELF (Executable and Linkable Format). The ABI (Application Binary Interface) is the binary interface of software components such as library files, including function call conventions, data types, symbol tables, etc. If the ABIs of two library files are incompatible, it may cause errors during program execution.
[0047] Specifically, check the versions of the library files, as shown in the following examples: abidiff libssl_x86.so libssl_arm.so Replace incompatible dynamic dependency libraries, as shown in the following examples: sudo apt-get install libssl1.1:arm64 Step S105: Based on the dependency manifest and call information, reconstruct the container image using the base image of the target architecture to ensure that the container application can run on the target architecture.
[0048] In some embodiments, compile the source code of the container application in the current architecture into an executable file in the target architecture; replace the dependency library files of the container application in the current architecture with those in the target architecture; based on the dependency manifest and call information, reconstruct the container image using the base image of the target architecture to ensure that the container application can run on the target architecture, including: Configure the cross-compilation toolchain; Compile the source code of the container application in the current architecture into an executable file in the target architecture through the cross-compilation toolchain; Install the dependency library files in the target architecture through apt-get; Specify the base image of the target architecture, copy the dependency library files and binary files to the target architecture platform based on the dependency library manifest and binary file type manifest, specify the command to be executed by default when the container application starts, and reconstruct the container image based on the base image of the target architecture through the docker tool; Check whether the container image contains all the required resources and files according to the dependency library files, binary files, and call information.
[0049] It should be noted that the cross-compilation toolchain is a set of tools used to compile executable files suitable for another architecture on a computer of one architecture. Docker is an open-source containerization platform that allows developers to package an application and its dependencies into an independent container, thus ensuring that the application runs consistently in any environment that supports Docker. apt-get is a command-line tool for managing software packages in Debian and its derivative distributions (such as Ubuntu, Linux Mint, etc.) and is part of the APT (Advanced Package Tool) toolset. apt-get is one of the core tools for software installation, upgrade, uninstallation, etc. in the Linux system.
[0050] Specifically, the configuration of the cross-compilation toolchain is as follows: export CC=arm-linux-gnueabihf-gcc cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-arm.cmake.. make Among them, the toolchain-arm.cmake file specifies the compiler and target architecture settings required for cross-compilation.
[0051] Specifically, the source code of the container application in the current architecture is compiled into a binary file for the ARM platform, that is, an executable file under the ARM architecture, as follows: arm-linux-gnueabihf-gcc -o myapp_arm myapp.c Specifically, dynamic dependency libraries are installed on the ARM platform through apt-get, as follows: sudo apt-get install libssl1.1:arm64 sudo apt-get install libc6:arm64 It should be understood that the container image is reconstructed using the base image of the ARM architecture to ensure that the container application can run on the ARM architecture.
[0052] Specifically, Docker and Dockerfile are used to create a container image for the ARM architecture. Dockerfile is a text file containing a series of instructions for defining how to build a Docker image. As follows: Dockerfile example: Specify the base image. Here, the official Ubuntu 20.04 image for the ARM64 architecture is used as the base image, which ensures that the generated container image is suitable for ARM architecture hardware: FROM arm64v8 / ubuntu:20.04 Copy the local file myapp_arm to the specified path / usr / local / bin / myapp inside the container: COPY . / build / myapp_arm / usr / local / bin / myapp Specify the command to be executed by default when the container starts. Here, when the container starts, it will run / usr / local / bin / myapp, which is the executable file copied into the container before: CMD [" / usr / local / bin / myapp"] Build the container image for the ARM architecture. Here, "." represents the current directory, and Docker will look for the Dockerfile in the current directory and use it to build the image: docker buildx build --platform linux / arm64 -t myapp-arm. Step S106: Intercept and redirect system calls through the LD_PRELOAD mechanism to make the system calls adapt to the target architecture.
[0053] Specifically, LD_PRELOAD (Dynamic Link Library Preloading) is an environment variable in the Linux system that allows users to preload specified shared libraries when a program runs. These shared libraries are loaded before other dependent libraries of the program, so that functions in the program can be overwritten or replaced. It should be understood that through the adaptation layer, the differences in the system call interfaces between the X86 and ARM architectures are resolved.
[0054] Specifically, intercept and redirect system calls through the LD_PRELOAD mechanism. The example is as follows: int open(const char* path, int flags) { if (strcmp(path, " / dev / random") == 0) return real_open(" / dev / urandom", flags); return real_open(path, flags); } In a specific embodiment, the system calls of the container application after migration are adapted according to the system call information.
[0055] Step S107: By using a cross-compilation toolchain, replace the instruction set of the current architecture with the instruction set of the target architecture.
[0056] Specifically, the purpose of instruction set replacement is to solve the differences in instruction sets between different architectures (such as the X86 architecture and the ARM architecture). SSE (Streaming SIMD Extensions) is the SIMD instruction set in the X86 architecture. NEON (ARM SIMD Extensions) is the SIMD instruction set in the ARM architecture. It should be understood that the SSE instruction set of the X86 architecture is replaced with the NEON instruction set of the ARM architecture. An example is as follows: Replace the SSE code of X86: __m128 a = _mm_set1_ps(3.14); with the NEON code of ARM: float32x4_t a = vdupq_n_f32(3.14); Step S108: Perform a migration operation on the container application.
[0057] Refer to Figure 2 , in some embodiments, after performing the migration operation on the container application, the container application migration method further includes but is not limited to the following steps 201 to 204.
[0058] Step 201: Use sar and dstat to collect the first performance data of the container application before migration, and generate a performance baseline based on the first performance data.
[0059] Step 202: When the container application is started for the first time on the target architecture platform, control the container application to warm up, check the performance of the container application to obtain a performance result, and obtain a performance bottleneck based on the performance result and the performance baseline.
[0060] Step 203: When the container application is running on the target architecture platform, use eBPF to trace kernel events and use bpftrace to capture performance bottlenecks.
[0061] Step 204: Trigger an alarm for the performance bottleneck to notify relevant personnel, and trigger a resource adjustment operation based on the performance bottleneck.
[0062] Specifically, sar is a System Activity Reporter tool used to collect, report, or save system activity information. Dstat is a tool for generating system resource statistics that can display system performance data in real time; it provides detailed statistical information on resources such as CPU, memory, disk, and network. Performance Baseline is the expected performance level of a system or application under specific conditions; it is usually used to evaluate and compare the performance of a system under different conditions, helping to identify performance bottlenecks and optimization opportunities. Bpftrace is an advanced dynamic tracing tool based on eBPF that provides a declarative scripting language similar to awk for writing tracing scripts. eBPF (Extended BPF) is an extended Berkeley Packet Filter technology that was initially used to optimize packet filter processing and later extended to a general-purpose kernel technology that can execute more general programs on any event.
[0063] It should be understood that it is necessary to ensure that the container application can maintain performance comparable to that of the X86 architecture on the ARM architecture, and monitor and adjust the performance in real time during the actual operation process to avoid performance degradation. Establish a baseline performance model for the migration process as a reference for subsequent comparison and adjustment. The first performance data includes CPU usage, memory usage, disk I / O read and write rates, and network bandwidth, etc. The Central Processing Unit (CPU) is the operation and control core of a computer system and is the final execution unit for information processing and program operation. TPS (Transactions Per Second) is an abbreviation for "Transactions Per Second" and is used to measure the number of transactions that a system can process per unit time.
[0064] Specifically, use performance monitoring tools sar and dstat to record the first performance data (such as TPS, response time, CPU occupancy, etc.) on the X86 architecture and generate a performance baseline. The example is as follows: sar -u 1 dstat -cdnm It should be understood that performance preheating and self-checking are performed when the ARM platform is first started to ensure that the performance meets the expectations.
[0065] Specifically, use a stress testing tool (such as wrk) for preheating. Before officially conducting performance tests, preheating can bring system resources (such as CPU, memory, disk, etc.) into a stable state. The example is as follows: wrk -t4 -c100 -d30s http: / / 127.0.0.1:8080 It should be understood that eBPF is used to track kernel events to locate performance bottlenecks.
[0066] Use bpftrace to capture performance bottlenecks. The example is as follows: bpftrace -e 'kprobe:sys_read { @[comm] = count();}' In some embodiments, generating a performance baseline according to the first performance data includes: Cleaning and structuring the first performance data in a time series to extract key metrics; Calculating the mean, maximum, minimum, and standard deviation of each key metric; Based on the mean, maximum, minimum, and standard deviation, obtaining the baseline interval for each key metric, and obtaining the performance baseline according to the baseline interval.
[0067] It should be noted that the Baseline Interval is a time range used to describe the reference performance level in performance testing or monitoring.
[0068] Specifically, the first performance data is cleaned and structured in a time series to extract key metrics (such as CPU utilization, memory occupancy, disk throughput, etc.). Calculate statistics such as the mean, maximum, minimum, and standard deviation for each key metric to form a basic model describing the performance upper and lower limits and stability. Based on the statistical results, set the baseline interval for each key metric. For example, the average value ± standard deviation is used to obtain the baseline interval, which is used as the performance baseline determination range for subsequent performance comparison and alarm. The obtained performance baseline is output in JSON, YAML, or other machine-readable formats for real-time comparison and reference on the target platform after migration. YAML (YAML Ain't Markup Language) is a lightweight data serialization format commonly used in configuration files and data exchange. The example output format is as follows: { "cpu": { "avg": 42.3, "max": 85.1, "std": 12.7}, "memory": { "avg": 2.1, "max": 3.8, "std": 0.5}, "disk_io": { "read_avg": 120, "write_avg": 90}, "network": { "bandwidth_avg": 450, "peak": 680} } In some embodiments, after performing the migration operation on the container application, the container application migration method further includes: Using a prediction model, predicting the load value for the next time period based on the historical load data of the operation, and reserving resources according to the predicted load value for the next time period to facilitate the completion of the resource adjustment operation; Using a reinforcement learning model, obtaining a reward based on the environmental state and decision-making actions, and iterating out an optimal decision-making action according to the second performance data, decision-making actions, and rewards of the migrated container application collected in real time; Issuing an action instruction based on the optimal decision-making action to complete the resource adjustment operation.
[0069] Specifically, the prediction model is used to predict the load value for the next time period, and the reinforcement learning model is used to iterate out an optimal decision-making action. It can be understood that through the prediction model and the reinforcement learning model, dynamic resource scheduling and real-time performance optimization can be achieved to ensure that the container application can maintain the expected performance on the new platform.
[0070] It should be understood that the short-term load change trend is predicted based on the historical load data (CPU / memory / I / O, etc.) to provide the "prophetic" ability.
[0071] Specifically, using a prediction model, predicting the load value for the next time period based on the historical load data of the operation, and reserving resources according to the predicted load value for the next time period to facilitate the completion of the resource adjustment operation; among them, the prediction model uses a long short-term memory network to process multi-dimensional index data with time series characteristics to predict the load value for the next time period. The example is as follows: Time series input dimension: CPU occupancy rate (0~1) Memory usage percentage Number of container requests Time window length: 10~30 steps (by minute) Implementation of the prediction model (based on Keras): from keras.models import Sequential from keras.layers import LSTM, Dense model = Sequential() model.add(LSTM(64, input_shape=(10, 3))) # 10 steps, 3 dimensions per step model.add(Dense(1)) # Output 1 prediction value (such as future CPU utilization) model.compile(loss='mse', optimizer='adam') Example: Input 10X = np.array([[[0.5, 0.6, 30], ..., [0.7, 0.8, 40]]]) # 10 rows and 3 columns y_pred = model.predict(X) Predict the next minute based on the historical CPU load in the last minute: X = np.array([[[0.5, 0.6, 30], ..., [0.7, 0.8, 40]]]) # 10 rows and 3 columns y_pred = model.predict(X) For example, a predicted value of 0.82 means that it is expected that the CPU will be occupied by 82% in the next minute, and resources need to be reserved.
[0072] It should be understood that according to the current system state, "dynamic resource allocation" decisions (such as increasing CPU, reducing memory, horizontal scaling, etc.) are made through the reinforcement learning model. Reinforcement learning (RL) is to achieve optimization by allowing the agent to interact with the environment, obtain feedback, and update its policy according to the feedback. The goal of reinforcement learning is to automatically adjust the resource allocation of the container through learning and decision-making to improve the performance of the container and the system efficiency.
[0073] Specifically, through the reinforcement learning model, where the reinforcement learning model adopts the Q-learning or DeepQ Network (DQN) reinforcement learning method, obtains rewards according to the environmental state and decision-making actions, and iteratively obtains better decision-making actions according to the second performance data, decision-making actions, and rewards of the migrated container applications collected in real time. The decision-making actions are sent to the container orchestration system in real time to complete the resource adjustment operation.
[0074] It should be noted that the state space is a description of the environment, and the agent in reinforcement learning makes decisions based on the state space. The state space includes the CPU utilization rate, memory usage, network bandwidth consumption, current number of requests, and response time of the migrated container application, etc. The action space is all the actions that the agent can choose. The reward is used to feedback the quality of the actions executed by the agent. The design of the reward must ensure that the agent can learn the optimization goal, for example, improving performance, reducing resource waste, etc. If the container application performs better after completing the resource adjustment operation, the reward will increase, such as an increase in throughput and a shortening of the response time. If the performance of the container application deteriorates after completing the resource adjustment operation, the reward will decrease, such as too high CPU occupancy and a lengthening of the response time. The reinforcement learning model prefers a lower resource cost while the system response time decreases, and in this case, the reward will be higher.
[0075] Specifically, the state space is defined according to the second performance data (such as CPU utilization rate, memory usage, network bandwidth consumption, current number of requests, and response time, etc.) of the migrated container application collected in real time, and the action space is defined. The agent will select a decision-making action from the action space for execution according to the current environment (container application) state and reward in the state space.
[0076] After executing the decision-making action, the environment (container application) will generate a new state according to the new resource configuration. This new state reflects whether the resource usage has changed after the container application is scheduled. The new state will be collected again and used as the input for the agent to select the decision-making action next time.
[0077] In Q-learning, the agent learns the optimal policy by updating the Q-table (state-action value table). The Q-value represents the expected return of executing a certain action in a given state. As the learning progresses, the agent will continuously update the Q-value so that it can select the action with the highest return in the future.
[0078] Example state space: { "cpu_util": 0.75, / / CPU utilization rate "mem_util": 0.65, / / Memory utilization rate "tps": 2500, / / Transactions per second "response_time": 200, / / Response time (milliseconds) "pending_requests": 100 / / Number of pending requests } Example action space: ["scale_cpu_up", "scale_cpu_down", "scale_mem_up", "replica_add", "do_nothing"] Example rewards: reward = -response_time_penalty + tps_reward - cost_penalty Example reinforcement learning model structure (TensorFlow): model = tf.keras.Sequential( tf.keras.layers.Dense(64, activation='relu'), tf.keras.layers.Dense(32, activation='relu'), tf.keras.layers.Dense(len(actions), activation='linear') ) Decision actions in the example action space: Increase CPU quota: Increase the CPU limit of the container.
[0079] Decrease CPU quota: Decrease the CPU limit of the container.
[0080] Increase memory allocation: Allocate more memory resources to the container.
[0081] Decrease memory allocation: Reduce the memory resources of the container.
[0082] Increase the number of replicas: Expand the number of container replicas to handle more load.
[0083] Decrease the number of replicas: Reduce the number of container replicas and release resources.
[0084] Specifically, when the decision action is to increase the CPU quota of the container, the actual operation is to perform resource adjustment operations through Kubernetes (container orchestration system) or Docker. Example commands: kubectl set resources deployment myapp --limits=cpu=2 kubectl scale deployment myapp --replicas=4 Specifically, the resource adjustment operation is completed using the Kubernetes API. Among them, the CPU usage is limited to 2 CPU cores, the memory usage is limited to 1 GiB (Gigabyte), and the number of container replicas is set to 3. The Application Programming Interface (API) is a definition and protocol specification that allows software applications or components to interact and exchange data. The examples are as follows: Resource limit adjustment: kubectl set resources deployment myapp \ --limits=cpu=2,memory=1Gi Horizontal replica scaling: kubectl scale deployment myapp --replicas=3 Specifically, the resource adjustment operation is completed using the Docker API. Among them, the CPU limit of the container is set to 2.0 CPU cores, and the memory limit of the container is set to 1 GiB. The examples are as follows: Update the resource limits of running containers: docker update --cpus=2.0 --memory=1g myapp_container Specifically, use a script to automatically adjust the resource limits of Kubernetes Deployment. By passing in different cpu parameters and mem parameters, the resource limits can be dynamically adjusted without manually executing command-line operations. The examples are as follows: import subprocess def set_k8s_resource(cpu, mem): cmd = f"kubectl set resources deployment myapp --limits=cpu={cpu},memory={mem}" subprocess.run(cmd, shell=True) In a specific embodiment, the resource consumption of the container is monitored in real time, and performance metrics such as CPU, memory, disk, and network are collected for further analysis and processing. Among them, Prometheus is used to periodically collect the third performance data of the container from the Node Exporter endpoint and the cAdvisor endpoint. Prometheus is an open-source system monitoring and alerting toolkit. Node Exporter is a tool provided by Prometheus official for collecting hardware and operating system metrics at the operating system level. It can provide detailed information about resources such as system load, memory, network, and disk. cAdvisor (Container Advisor) is a container monitoring tool provided by Google for analyzing the resource usage inside the container (such as CPU, memory, I / O, network, etc.). It can collect and provide metrics at the container level. The example is as follows: scrape_configs: - job_name: 'container_metrics' static_configs: - targets: ['localhost:8080'] metrics_path: / metrics Example performance metrics: container_cpu_usage_seconds_total: Records the total time (in seconds) that the container consumes CPU. This metric is used to measure the CPU usage of the container.
[0085] container_memory_usage_bytes: Records the total amount of memory currently used by the container (in bytes). This metric is used to measure the memory usage of the container.
[0086] Analyze the third performance data to obtain potential performance bottlenecks, trigger alarms for potential performance bottlenecks to notify relevant personnel, and trigger resource adjustment operations based on potential performance bottlenecks. Among them, set thresholds for the performance metrics in the third performance data. When the performance metrics exceed the thresholds, trigger alarms and trigger resource adjustment operations. When Prometheus discovers that a certain performance metric exceeds the threshold, it will push the alarm information to the configured alarm system (such as Alertmanager), and send alarm notifications via email, Slack, Webhook, etc. The example is as follows: Example alarm rule configuration: groups: - name: container-alerts rules: - alert: HighCPUUsage expr: avg(container_cpu_usage_seconds_total[1m]) > 0.9 for: 5m labels: severity: critical annotations: description: "CPU usage has been above 90% for more than 5minutes" summary: "CPU usage is high on container." - alert: HighMemoryUsage expr: container_memory_usage_bytes > 4e+9 # 4GB for: 5m labels: severity: high annotations: description: "Memory usage has exceeded the limit for morethan 5 minutes." summary: "Memory usage is too high on container." Among them, the HighCPUUsage alert rule monitors the CPU usage rate of the container. If the average CPU usage rate for 1 minute exceeds 90% and lasts for more than 5 minutes, an alarm will be triggered. The HighMemoryUsage alert rule monitors the memory usage of the container. If the memory usage exceeds 4GB and lasts for more than 5 minutes, an alarm will be triggered.
[0087] When the performance metrics exceed the threshold, a scheduling feedback request is sent down. The scheduling execution module responsible for performing resource adjustment operations receives the scheduling feedback request through the interface and optimizes the resources of the container.
[0088] Send a scheduling feedback request (i.e., the aforementioned action instruction) to the scheduling execution module through the REST API, instructing it to perform specific resource adjustment operations (such as increasing CPU quotas, expanding container replicas, etc.). After receiving the scheduling feedback request, the scheduling execution module performs the corresponding resource adjustment operations and returns the results. The REST API (Representational State Transfer Application Programming Interface) is a network application programming interface based on the REST (Representational State Transfer) architectural style. The example is as follows: Send a scheduling feedback request: curl -X POST http: / / scheduler / api -d '{"action":"scale_up","target":"app"}' Among them, the action field represents the operation to be performed, which is "scale_up" here, that is, to expand the number of container replicas. The target field represents the target container or service name, which is "app" here, that is, the container or service that needs to be expanded.
[0089] The scheduling execution module receives the scheduling feedback request: The scheduling execution module will perform corresponding operations according to the action and target fields in the scheduling feedback request, such as expanding the number of container replicas, increasing CPU or memory quotas, etc.
[0090] Specifically, resource adjustment in Kubernetes can be completed through commands such as kubectl scale or kubectl set resources. Resource adjustment in Docker can be achieved through the docker update command or Docker Swarm service expansion operations.
[0091] In a specific embodiment, each link of the container application migration method is carried out by automated means, reducing labor costs and operation errors, and improving migration efficiency and accuracy. Among them, each link of the container application migration method is implemented through scripts.
[0092] It can be seen that by using a script to identify the current architecture type of a container application to determine whether the current architecture type is different from the target architecture type. If the current architecture type is different from the target architecture type, the dependency list and call information are extracted through the script, the source code of the current architecture of the container application is compiled into an executable file under the target architecture, the dependency library files under the current architecture of the container application are replaced with the dependency library files under the target architecture, and based on the dependency list and call information, the container image is reconstructed using the base image of the target architecture to ensure that the container application can run on the target architecture. Through the LD_PRELOAD mechanism, system calls are intercepted and redirected to make the system calls adapt to the target architecture. By using a cross-compilation toolchain, the instruction set of the current architecture is replaced with the instruction set of the target architecture, thereby performing a migration operation on the container application. Extracting the dependency list and call information through the script reduces the possibility of missing the dependency list and call information required for the container application to run, which is beneficial to ensuring the efficient and stable operation of the container application on the target architecture. Compiling the source code of the current architecture of the container application into an executable file under the target architecture, replacing the dependency library files under the current architecture of the container application with the dependency library files under the target architecture, and reconstructing the container image are beneficial to ensuring the efficient and stable operation of the container application on the target architecture.
[0093] Referring to Figure 3 , the embodiment of the present invention also provides a container application migration system for executing the above-mentioned container application migration method. The container application migration system includes: A container analysis module for identifying the current architecture type of the container application and extracting the dependency list and call information; An architecture conversion module for compiling the source code of the current architecture of the container application into an executable file under the target architecture, replacing the dependency library files under the current architecture of the container application with the dependency library files under the target architecture, and reconstructing the container image; the container analysis module is connected to the architecture conversion module; A compatibility optimization module for adapting the system calls to the target architecture and replacing the instruction set of the current architecture with the instruction set of the target architecture; the architecture conversion module is connected to the compatibility optimization module; A migration module for performing a migration operation on the container application; the compatibility optimization module is connected to the migration module.
[0094] Specifically, the container analysis module is used to identify the current architecture type of the container application through a script to determine whether the current architecture type is different from the target architecture type, and extract the dependency list and call information through the script. The architecture conversion module is used to compile the source code of the current architecture of the container application into an executable file under the target architecture, replace the dependency library files under the current architecture of the container application with the dependency library files under the target architecture, and reconstruct the container image based on the dependency list and call information using the base image of the target architecture to ensure that the container application can run on the target architecture. The compatibility optimization module is used to intercept and redirect system calls through the LD_PRELOAD mechanism to make the system calls adapt to the target architecture, and replace the instruction set of the current architecture with the instruction set of the target architecture by using a cross-compilation toolchain. The migration module is used to perform a migration operation on the container application.
[0095] In some embodiments, the container application migration system further includes: A performance guarantee module, which is used to detect performance bottlenecks, trigger an alarm for the performance bottlenecks to notify relevant personnel, and trigger a resource adjustment operation based on the performance bottlenecks; An intelligent scheduling module, which is used to iterate out a better decision action, issue an action instruction based on the better decision action to complete the resource adjustment operation; the performance guarantee module is connected to the intelligent scheduling module.
[0096] Specifically, the performance guarantee module is used to collect the first performance data of the container application before migration using sar and dstat, generate a performance baseline based on the first performance data. When the container application is first started on the target architecture platform, it controls the container application to be preheated, checks the performance of the container application to obtain a performance result, obtains a performance bottleneck based on the performance result and the performance baseline. When the container application is running on the target architecture platform, it traces kernel events through eBPF, captures the performance bottleneck using bpftrace, triggers an alarm for the performance bottleneck to notify relevant personnel, and triggers a resource adjustment operation based on the performance bottleneck. The intelligent scheduling module is used to predict the load value of the next time period according to the historical running load data through a prediction model, reserve resources to facilitate the completion of the resource adjustment operation according to the predicted load value of the next time period, obtain a reward according to the environmental state and decision action through a reinforcement learning model, and iterate out a better decision action based on the second performance data, decision action and reward of the migrated container application collected in real time, and issue an action instruction based on the better decision action to complete the resource adjustment operation.
[0097] In some embodiments, the container application migration system further includes: A scheduling execution module, which is used to receive a scheduling feedback request and execute the resource adjustment operation; the intelligent scheduling module is connected to the scheduling execution module; A performance monitoring feedback module, which is used to periodically collect the third performance data of the container, analyze the third performance data to obtain potential performance bottlenecks, trigger an alarm for the potential performance bottlenecks to notify relevant personnel, and trigger a resource adjustment operation based on the potential performance bottlenecks; the scheduling execution module is connected to the performance monitoring feedback module.
[0098] An embodiment of the present invention further provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the above-mentioned method for migrating container applications is implemented. The electronic device can be any intelligent terminal including a computer, etc.
[0099] An embodiment of the present invention further provides a storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned method for migrating container applications is implemented.
[0100] It should be recognized that the method steps in the embodiments of the present invention can be implemented or implemented by computer hardware, a combination of hardware and software, or computer instructions stored in a non-transitory computer-readable memory. The method can use standard programming techniques. Each program can be implemented in a high-level procedural or object-oriented programming language to communicate with the computer system. However, if necessary, the program can be implemented in assembly or machine language. In any case, the language can be a compiled or interpreted language. In addition, for this purpose, the program can run on a dedicated integrated circuit programmed for this purpose.
[0101] In addition, the operations of the processes described herein can be performed in any suitable order, unless otherwise indicated herein or otherwise clearly contradicted by the context. The processes described herein (or variations and / or combinations thereof) can be executed under the control of one or more computer systems configured with executable instructions, and can be implemented as code (e.g., executable instructions, one or more computer programs, or one or more applications) executed commonly on one or more processors, by hardware, or a combination thereof. The computer program includes multiple instructions executable by one or more processors.
[0102] Further, the method may be implemented in any type of computing platform operatively connected to a suitable one, including but not limited to personal computers, minicomputers, mainframes, workstations, network or distributed computing environments, separate or integrated computer platforms, or communicating with charged particle tools or other imaging devices, etc. Aspects of the present invention may be implemented in machine-readable code stored on a non-transitory storage medium or device, whether removable or integrated into the computing platform, such as a hard disk, optical read and / or write storage medium, RAM, ROM, etc., such that it is readable by a programmable computer and, when read by the storage medium or device, can be used to configure and operate the computer to perform the processes described herein. Additionally, the machine-readable code, or portions thereof, may be transmitted via wired or wireless networks. When such media include instructions or programs that implement the above-described steps in conjunction with a microprocessor or other data processor, the invention described herein includes these and other different types of non-transitory computer-readable storage media. When programmed according to the methods and techniques of the present invention, the present invention may also include the computer itself.
[0103] A computer program can be applied to input data to perform the functions described herein, thereby transforming the input data to generate output data stored in non-volatile memory. The output information can also be applied to one or more output devices such as a display. In a preferred embodiment of the present invention, the transformed data represents physical and tangible objects, including a specific visual depiction of the physical and tangible objects produced on the display.
[0104] As described above, these are only the preferred embodiments of the present invention. The present invention is not limited to the above-described embodiments. As long as the same means are used to achieve the technical effects of the present invention, any modifications, equivalent replacements, improvements, etc., made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention. Within the scope of protection of the present invention, its technical solutions and / or implementation manners may have various different modifications and changes.
Claims
1. A method for migrating container applications, characterized in that, Including: Identify the current architecture type of the container application through a script; If the current architecture type is different from the target architecture type, extract the dependency list and call information through the script; Compile the source code of the current architecture of the container application into an executable file under the target architecture; Replace the dependency library files under the current architecture of the container application with the dependency library files under the target architecture; Based on the dependency list and the call information, use the base image of the target architecture to reconstruct the container image to ensure that the container application can run on the target architecture; Through the LD_PRELOAD mechanism, intercept and redirect system calls to make the system calls adapt to the target architecture; By using a cross-compilation toolchain, replace the instruction set of the current architecture with the instruction set of the target architecture; Perform a migration operation on the container application.
2. The method for migrating a container application according to claim 1, wherein The call information includes system call information and dependency library call information; Extract call information through the script, including: In the script, use the strace command to extract the system call information; Use the ltrace command to extract the dependency library call information of the container application.
3. A method for migrating a container application according to claim 1, characterized in that, The dependency list includes a dependency library list and a binary file type list; Identify the current architecture type of the container application through a script, and extract the dependency list through the script, including: In the script, use the file command to identify the current architecture type of the container application and extract the binary file type list; Use the readelf command and the ldd command to extract the dependency library list.
4. The method for migrating a container application according to claim 3, wherein Compile the source code of the current architecture of the container application into an executable file under the target architecture; replace the dependency library files under the current architecture of the container application with the dependency library files under the target architecture; Based on the dependency list and the call information, use the base image of the target architecture to reconstruct the container image to ensure that the container application can run on the target architecture, including: Configure the cross-compilation toolchain; Compile the source code of the current architecture of the container application into the executable file under the target architecture through the cross-compilation toolchain; Install the dependency library files under the target architecture through apt-get; Specify the base image of the target architecture, copy the dependency library files and binary files to the target architecture platform based on the dependency library list and the binary file type list, specify the command that is executed by default when the container application starts, and reconstruct the container image based on the base image of the target architecture through the docker tool; Check whether the container image contains all the required resources and files according to the dependency library files, the binary files and the call information.
5. A method for migrating container applications according to claim 1, characterized in that, After performing the migration operation on the container application, the container application migration method further includes: Use sar and dstat to collect the first performance data of the container application before migration, and generate a performance baseline according to the first performance data; When the container application is started for the first time on the target architecture platform, control the container application to perform warm-up, check the performance of the container application to obtain a performance result, and obtain a performance bottleneck based on the performance result and the performance baseline; When the container application is running on the target architecture platform, trace kernel events through eBPF and use bpftrace to capture the performance bottleneck; Trigger an alarm for the performance bottleneck to notify relevant personnel, and trigger a resource adjustment operation based on the performance bottleneck.
6. A method for migrating container applications according to claim 5, characterized in that, Generate a performance baseline according to the first performance data, including: Clean and structure the first performance data in a time series to extract key metrics; Calculate the mean, maximum value, minimum value, and standard deviation of each key metric; Based on the mean, the maximum value, the minimum value, and the standard deviation, obtain a baseline interval for each key metric, and obtain the performance baseline according to the baseline interval.
7. A method for migrating container applications according to claim 1, characterized in that, After performing the migration operation on the container application, the container application migration method further includes: Through a prediction model, predict the load value for the next time period according to the historical running load data, and reserve resources according to the predicted load value for the next time period to facilitate the completion of the resource adjustment operation; Through a reinforcement learning model, obtain a reward according to the environmental state and decision actions, and iterate out an optimal decision action according to the second performance data, the decision actions, and the reward of the migrated container application collected in real time; Issue an action instruction based on the optimal decision action to complete the resource adjustment operation.
8. A container application migration system for performing a container application migration method as described in any one of claims 1 to 7, characterized in that, The container application migration system includes: A container analysis module, configured to identify the current architecture type of the container application, and extract a dependency list and call information; An architecture conversion module, configured to compile the source code of the current architecture of the container application into an executable file under the target architecture, replace the dependency library file under the current architecture of the container application with a dependency library file under the target architecture, and reconstruct the container image; the container analysis module is connected to the architecture conversion module; A compatibility optimization module, configured to adapt system calls to the target architecture and replace the instruction set of the current architecture with the instruction set of the target architecture; the architecture conversion module is connected to the compatibility optimization module; A migration module, configured to perform a container application migration operation; the compatibility optimization module is connected to the migration module.
9. A container application migration system according to claim 8, characterized in that The container application migration system further includes: A performance guarantee module, configured to detect a performance bottleneck, trigger an alarm for the performance bottleneck to notify relevant personnel, and trigger a resource adjustment operation based on the performance bottleneck; An intelligent scheduling module, configured to iterate out an optimal decision action, and issue an action instruction based on the optimal decision action to complete the resource adjustment operation; the performance guarantee module is connected to the intelligent scheduling module.
10. A storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements a container application migration method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Binary file detection method in Linux system
CN114238153A
Source code credential migration system and method
CN116450213A
Server application architecture migration method and device and storage medium
CN119645610A
Cited By
Method for realizing AGV cross compiling based on docker
CN121187594A