Stateful application live migration method based on local storage and related device

By implementing data synchronization and Pod migration technology in Kubernetes cluster, the problem that the existing technology cannot support stateful application hot migration is solved, smooth migration and data persistence of applications in cloud-native environments are realized, and the application scope of local storage is expanded. .

CN118963673APending Publication Date: 2024-11-15ASIAINFO TECH CHINA INC
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411143243.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-20
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing local storage-based solutions cannot support hot migration of stateful applications, limiting the application and deployment of local storage in cloud-native environments.

Method used

By implementing data synchronization and Pod migration technologies in Kubernetes clusters, data synchronization and migration between the master and slave nodes are leveraged to ensure persistence of application data and business continuity.

Benefits of technology

It realizes smooth migration of applications in cloud-native environments, makes full use of the high-performance advantages of local storage, ensures continuous data availability and business continuity, and expands the application and deployment of local storage in cloud-native architecture.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963673A_ABST
    Figure CN118963673A_ABST
Patent Text Reader

Abstract

The invention discloses a stateful application live migration method based on local storage and a related device, and the method comprises the steps that a main replica node in a Kubernetes cluster responds to a volume creation request for an application pod of a stateful application, creates a local volume on the main replica node, and establishes an association relationship between the local volume and the application pod; the master replica node stores persistent data of the application pod to a local volume during operation of the application pod, and synchronizes the persistent data to a data volume of each slave replica node in the at least one slave replica node; the master replica node responds to a migration request for the application pod and determines a destination node according to the migration request, and the destination node is from at least one slave replica node; and the primary replica node synchronizes the temporary data of the application pod on the primary replica node to the destination node so as to complete migration of the application pod.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a stateful application hot migration method based on local storage and related devices. Background Art

[0002] With the rapid development of cloud computing technology, cloud-native architecture has gradually become an important cornerstone of enterprise digital transformation. In a cloud-native environment, applications are designed as microservices that are elastically scalable, highly automated, and self-healing, which greatly improves the flexibility and reliability of applications. However, for stateful applications, how to achieve data persistence while maintaining high performance has become a problem that needs to be solved in cloud-native architecture.

[0003] Currently, stateful applications face two main choices for data persistence: local storage and distributed storage. Local storage provides excellent storage performance for applications with its low latency and high throughput. By directly utilizing the storage resources on the host, local storage can minimize the network overhead of data access, thereby significantly improving the response speed and throughput of applications.

[0004] However, most existing local storage solutions only support data backup and cannot support hot migration of applications, that is, migrating applications and their data from one node to another without interrupting services. This limitation restricts the wider application of local storage in cloud-native environments. Summary of the invention

[0005] In view of the above problems, this application provides a method and related devices for hot migration of stateful applications based on local storage, so as to not only fully utilize the high performance advantages of local storage, but also solve the problem of limited application of local storage in cloud native environment through data synchronization and Pod migration technology, so that local storage can be more widely used and deployed in cloud native architecture. The specific scheme is as follows:

[0006] The first aspect of the present application provides a method for hot migration of stateful applications based on local storage, comprising:

[0007] A master replica node in a Kubernetes cluster responds to a volume creation request for an application pod of a stateful application by creating a local volume on the master replica node and establishing an association relationship between the local volume and the application pod;

[0008] During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0009] The master replica node determines, in response to a migration request for the application pod, a destination node according to the migration request, where the destination node is from the at least one slave replica node;

[0010] The primary replica node synchronizes the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

[0011] In a possible implementation, after creating a local volume on the primary replica node and establishing an association relationship between the local volume and the application pod, the method further includes:

[0012] The master replica node receives metadata information; the metadata information includes: the address and status of the master replica node; and the address and status of each slave replica node;

[0013] The master replica node sends the volume creation request to the corresponding slave replica node based on the metadata information, so that the slave replica node creates a data volume.

[0014] In a possible implementation, the master replica node stores persistent data of the application pod in the local volume during the running of the application pod, and synchronizes the persistent data to a data volume of each slave replica node in at least one slave replica node, including:

[0015] The master replica node receives an IO write request during the operation of the application pod, and synchronizes the IO write request to at least one slave replica node based on the metadata information local to the master replica node;

[0016] The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request;

[0017] The master replica node records a synchronization log of the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request;

[0018] After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates a corresponding slave replica completion mark in the synchronization log;

[0019] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0020] In a possible implementation, the method further includes:

[0021] Based on the at least one slave replica completion marker, determining the number of slave replica nodes that have completed synchronization;

[0022] If the master replica node has completed the storage of the persistent data, the master replica node adds the number of slave replica nodes that have completed synchronization to itself to determine the total number of replicas that have completed storage;

[0023] If the total number of copies that have completed storage reaches the set number threshold, an IO write success message is returned.

[0024] In a possible implementation, the method further includes:

[0025] After the master replica node is restarted, reloading the metadata information and the synchronization log;

[0026] The master replica node determines, according to the completion mark of the synchronization log, a slave replica node that has not completed synchronization among the at least one slave replica node;

[0027] Based on the metadata information, the persistent data in the IO write request is resynchronized to the slave replica node that has not completed synchronization.

[0028] In a possible implementation, the method further includes:

[0029] If the master replica node receives a synchronization request from the new master replica node, it synchronizes the synchronization log on the master replica node and the persistent data in the IO write request that has not completed synchronization to the new master replica node, so that the new master replica node replaces the master replica node as the source of data synchronization;

[0030] The master replica node is downgraded to a slave replica node, and its local metadata information is updated.

[0031] In another aspect of the present application, a stateful application hot migration device based on local storage is provided, comprising:

[0032] A creation module, configured to create a local volume on the primary replica node in response to a volume creation request for an application pod of a stateful application, and establish an association relationship between the local volume and the application pod;

[0033] A first synchronization module, configured to store persistent data of the application pod to the local volume and synchronize the persistent data to a data volume of each slave replica node in at least one slave replica node during the operation of the application pod;

[0034] A determination module, configured to respond to a migration request for the application pod and determine a destination node according to the migration request, wherein the destination node is from the at least one slave replica node;

[0035] The second synchronization module is used to synchronize the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

[0036] In a third aspect of the present application, a master replica node is provided, comprising: a processor and a memory connected to the processor, wherein:

[0037] The memory is used to store computer programs;

[0038] The processor is used to execute the computer program so that the master replica node can implement the following steps:

[0039] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0040] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0041] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0042] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0043] In a fourth aspect of the present application, a stateful application hot migration system based on local storage is provided, comprising:

[0044] A master replica node and at least one slave replica node in the Kubernetes cluster;

[0045] The master replica node is used to:

[0046] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0047] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0048] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0049] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0050] In a fifth aspect of the present application, a computer storage medium is provided, wherein the storage medium carries one or more computer programs, and when the one or more computer programs are executed by a master replica node, the master replica node can implement the following steps:

[0051] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0052] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0053] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0054] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0055] In the present application, the master replica node in the Kubernetes cluster responds to the volume creation request for the application pod of the stateful application, creates a local volume on the master replica node, and establishes an association relationship between the local volume and the application pod. During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node, so as to achieve real-time synchronization of the persistent data of the application pod. This synchronization mechanism can ensure that even if the master replica node fails, the data of the application pod can be recovered from the slave replica node, thereby ensuring the continuous availability of data and business continuity. On this basis, the master replica node responds to the migration request for the application pod, and determines the destination node according to the migration request. The destination node comes from at least one slave replica node. The master replica node synchronizes the temporary data of the application pod on the master replica node to the destination node. This process realizes the smooth migration of the application pod without interrupting the service, thereby ensuring the continuity of the business and the seamless experience of the user.

[0056] Through the above mechanism, the Kubernetes cluster not only fully utilizes the high performance advantages of local storage, but also solves the problem of limited application of local storage in cloud-native environments through data synchronization and Pod migration technologies, enabling local storage to be more widely used and deployed in cloud-native architectures. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the accompanying drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale.

[0058] Figure 1 A flowchart of a method for hot migration of stateful applications based on local storage provided in this application;

[0059] Figure 2 A schematic diagram of the interaction between the master replica node and the slave replica node provided in this application;

[0060] Figure 3 A flowchart of another method for hot migration of stateful applications based on local storage provided by this application;

[0061] Figure 4 Another interactive schematic diagram of the master replica node and the slave replica node provided for this application;

[0062] Figure 5A flowchart of another method for hot migration of stateful applications based on local storage provided by the present application;

[0063] Figure 6 A schematic diagram of the structure of a stateful application hot migration device based on local storage provided in this application. DETAILED DESCRIPTION

[0064] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0065] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0066] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0067] The present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0068] Reference Figure 1 , is a flow chart of a method for hot migration of stateful applications based on local storage provided in Example 1 of the present application, such as Figure 1 As shown, the method may include but is not limited to the following steps:

[0069] Step S101: In response to a volume creation request for an application pod of a stateful application, a master replica node in a Kubernetes cluster creates a local volume on the master replica node and establishes an association relationship between the local volume and the application pod.

[0070] In this embodiment, a stateful application can be understood as a microservice that needs to store persistent data.

[0071] In this embodiment, the application management and scheduling platform in the Kubernetes cluster (abbreviated as k8s) can pre-deploy the application hot migration controller, Agent, and k8s local volume CSI plug-in.

[0072] At the same time, you can create a corresponding storageclass according to actual needs. The storageclass can define how to dynamically create a local volume, including size, type, mount options, etc.

[0073] When creating a stateful application in a Kubernetes cluster, you can specify that the application needs to use a local volume storageclass for data storage. And specify the application's deployment strategy, including selecting a node as the primary replica node to deploy the application Pod for the first time, and specifying at least one other node as a secondary replica node for subsequent data synchronization and possible Pod migration.

[0074] The k8s local volume CSI plug-in can provide a standard CSI interface so that the storage gateway in the replica node (such as the master replica node or the slave replica node) can be connected to Kubernetes.

[0075] When Kubernetes needs to create a storage volume for a stateful application Pod, the application management and scheduling platform can send a volume creation request to the storage gateway of the primary and replica nodes through the CSI interface. The storage gateway of the primary and replica nodes can respond to the volume creation request and create a local volume on the local storage resources of the primary and replica nodes according to the StorageClass.

[0076] Once the local volume is created successfully and is ready to be mounted, the storage gateway will notify the application management and scheduling platform through the CSI interface, and the application management and scheduling platform can then mount the local volume to the specified directory of the Pod.

[0077] Step S102: During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node.

[0078] Persistent data is persistent during the life cycle of the Pod. Even if the Pod is deleted or rescheduled, the data will be retained as long as the local volume is not deleted.

[0079] In this embodiment, the storage gateway of the master replica node can store the persistent data of the application pod in the local volume, and synchronize the persistent data to the data volume of each slave replica node in at least one slave replica node. Figure 2As shown, the storage gateway in the master replica node A can simultaneously and synchronously send the persistent data to the storage gateways of the slave replica nodes B and C. The storage gateway of the slave replica node B stores the received persistent data in the data volume of the slave replica node B, and the storage gateway of the slave replica node C stores the received persistent data in the data volume of the slave replica node C.

[0080] Step S103: The master replica node responds to the migration request for the application pod and determines a destination node according to the migration request, where the destination node comes from the at least one slave replica node.

[0081] In this embodiment, the application management and scheduling platform may send a migration request for the application pod to the application hot migration controller. The application hot migration controller may specify a slave replica node from at least one slave replica node as the destination node, or may not specify a node and select a node with the lowest storage load from at least one slave replica node as the destination node.

[0082] The application hot migration controller can send migration requests to the agent of the master replica node and the agent of the slave replica node.

[0083] Step S104: The primary replica node synchronizes the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

[0084] Temporary data is different from persistent data. Temporary data is temporary data generated when the application is running, such as memory data and running status data.

[0085] The agent of the master replica node can save the temporary data of the application pod to the local volume.

[0086] The agent of the master replica node communicates with the agent of the destination node to synchronize the temporary data (such as memory data and running status data) of the master replica node to the destination node.

[0087] The destination node can start the application pod, mount the data volume of the destination node, and maintain the following state: receiving memory data and running status data sent by the primary replica node.

[0088] The master replica node can determine whether the sent memory data and running status data have reached a preset threshold. If so, it is marked as a hot migration state to be terminated.

[0089] The master replica node can send incremental memory data and running status data to the destination node. After receiving the data, the destination node can send a hot migration end notification to the master replica node. The destination node can restore the running status of the application pod based on the memory data and running status data and the data volume of the destination node.

[0090] When the application pod of the destination node is started and running stably, the master replica node can destroy the application pod and downgrade to a slave replica node.

[0091] In this embodiment, the master replica node in the Kubernetes cluster responds to the volume creation request for the application pod of the stateful application, creates a local volume on the master replica node, and establishes an association relationship between the local volume and the application pod. During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node, so as to achieve real-time synchronization of the persistent data of the application pod. This synchronization mechanism can ensure that even if the master replica node fails, the data of the application pod can be recovered from the slave replica node, thereby ensuring the continuous availability of data and business continuity. On this basis, the master replica node responds to the migration request for the application pod, and according to the migration request, determines the destination node, the destination node comes from the at least one slave replica node, and the master replica node synchronizes the temporary data of the application pod on the master replica node to the destination node. This process realizes the smooth migration of the application pod without interrupting the service, thereby ensuring the continuity of the business and the seamless experience of the user.

[0092] Through the above mechanism, the Kubernetes cluster not only fully utilizes the high performance advantages of local storage, but also solves the problem of limited application of local storage in cloud-native environments through data synchronization and Pod migration technologies, enabling local storage to be more widely used and deployed in cloud-native architectures.

[0093] As another optional embodiment of the present application, refer to Figure 3 , is a flow chart of a method for hot migration of stateful applications based on local storage provided in Example 2 of the present application, such as Figure 3 As shown, the method may include but is not limited to the following steps:

[0094] Step S201: In response to a volume creation request for an application pod of a stateful application, a master replica node in a Kubernetes cluster creates a local volume on the master replica node and establishes an association relationship between the local volume and the application pod.

[0095] The detailed process of step S201 can refer to the relevant introduction of step S101 in embodiment 1, which will not be repeated here.

[0096] Step S202: The master replica node receives metadata information.

[0097] In this embodiment, the application management and scheduling platform can send metadata information to the storage gateway of the primary and replica nodes through the CSI interface.

[0098] The metadata information may include: the address and status of the master replica node; and the address and status of each slave replica node; the status of the master replica node and each slave replica node may be used to distinguish the master replica node from each slave replica node.

[0099] For example, Figure 4 As shown, the master replica node can send metadata information to the storage gateway of each other slave replica node, so that each slave replica node also has the metadata information.

[0100] Step S203: The master replica node sends the volume creation request to the corresponding slave replica node based on the metadata information, so that the slave replica node creates a data volume.

[0101] Step S204: During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0102] Step S205: The master replica node responds to the migration request for the application pod and determines a destination node according to the migration request, where the destination node is from the at least one slave replica node;

[0103] Step S206: The primary replica node synchronizes the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

[0104] The detailed process of steps S204-S206 can refer to the relevant introduction of steps S102-S104 in Example 1, which will not be repeated here.

[0105] In this embodiment, after creating a local volume on the master replica node and establishing an association between the local volume and the application pod, the master replica node receives the slave replica node information, and the master replica node sends the volume creation request to the corresponding slave replica node based on the slave replica node information, so that the slave replica node creates a data volume, so as to centrally manage the volume creation requests on the master replica node and automatically distribute them to the slave replica nodes by the master replica node, thereby simplifying the data volume management process.

[0106] As another optional embodiment of the present application, refer to Figure 5 , is a flow chart of a method for hot migration of stateful applications based on local storage provided in Example 3 of the present application. This example is mainly an implementation method of step S102 in Example 1, such as Figure 5 As shown, step S102 may include but is not limited to the following steps:

[0107] Step S1021: During the operation of the application pod, the master replica node receives an IO write request, and synchronizes the IO write request to at least one slave replica node based on the local metadata information of the master replica node.

[0108] The metadata information can be found in the related introduction in Example 2, which will not be repeated here.

[0109] In this embodiment, the storage gateway of the master replica node may synchronously send the IO write request to the storage gateway of each slave replica node in at least one slave replica node based on the local metadata information of the master replica node.

[0110] Step S1022: The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request.

[0111] Step S1023: The primary replica node records a synchronization log of the IO write request.

[0112] The synchronization log may include: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset, and at least one completion mark from the replica.

[0113] At least one slave replica completion marker corresponds to at least one slave replica node, and each slave replica node corresponds to a slave replica completion marker.

[0114] The slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request. For example, when the slave replica node has not completed synchronization, the slave replica completion mark can be 0, indicating that the slave replica node has not completed synchronization.

[0115] Step S1024: After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates the corresponding slave replica completion mark in the synchronization log.

[0116] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0117] For example, after the master replica node receives a completion message from the at least one slave replica node, the corresponding slave replica completion flag can be updated from 0 to 1, indicating that the slave replica node has completed synchronization, that is, the persistent data in the IO write request sent by the master replica node is stored in the data volume of the slave replica node.

[0118] In this embodiment, after receiving the IO write request, the master replica node can synchronize the request to the slave replica node based on the local metadata information (including address parameters and status parameters). This synchronization mechanism can ensure that all related replica nodes can receive the same IO write request, thereby maintaining data consistency and integrity.

[0119] In addition, the master replica node records detailed synchronization logs, including the IO write request number, data location, offset, and slave replica completion mark, which helps to quickly locate problems and optimize performance. By recording detailed synchronization logs, more flexible data management strategies can be supported. For example, data distribution can be dynamically adjusted according to the performance status of the slave replica node to optimize the overall performance of the system.

[0120] As another optional embodiment of the present application, a flow chart of a stateful application hot migration method based on local storage is provided in Embodiment 4 of the present application. This embodiment is mainly an implementation method of step S102 in Embodiment 1. Step S102 may include but is not limited to the following steps:

[0121] Step S1021: During the operation of the application pod, the master replica node receives an IO write request, and based on the local metadata information of the master replica node, synchronizes the IO write request to at least one slave replica node; the metadata information includes: multiple address parameters and multiple status parameters, the multiple address parameters represent the host where the master replica node is located and the hosts where each slave replica node is located; the multiple status parameters are used to distinguish the master replica node from each slave replica node.

[0122] Step S1022: The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request.

[0123] Step S1023, the master replica node records the synchronization log of the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request.

[0124] Step S1024: After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates the corresponding slave replica completion mark in the synchronization log.

[0125] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0126] Step S1025: Based on the at least one slave replica completion mark, determine the number of slave replica nodes that have completed synchronization.

[0127] In this embodiment, the number of marks indicating that synchronization has been completed in at least one slave replica completion mark may be counted as the number of slave replica nodes that have completed synchronization.

[0128] Step S1026: If the master replica node has completed the storage of the persistent data, the master replica node adds the number of slave replica nodes that have completed synchronization to itself to determine the total number of replicas that have completed storage.

[0129] Step S1027: If the total number of copies that have been stored reaches a set number threshold, an IO write success message is returned.

[0130] The quantity threshold can be set as needed and is not limited in this application.

[0131] When the number threshold is set to a small value, it means that as long as a small number of replica nodes successfully complete the IO write, the entire write operation is considered successful. In the event of a node failure, since the number threshold is set to a small value, it is possible to switch to other healthy replica nodes more quickly to continue providing services, reducing the service interruption time caused by node failure. At the same time, since the synchronization log records detailed IO information, it is possible to quickly identify failed nodes and unfinished IO operations, and take corresponding recovery measures.

[0132] Also, since fewer replica nodes are required to complete the write to confirm success, the overall write latency is reduced accordingly.

[0133] As another optional embodiment of the present application, a flow chart of a method for hot migration of stateful applications based on local storage is provided in Embodiment 5 of the present application. This embodiment is mainly an implementation method of step S102 in Embodiment 1. Step S102 may include but is not limited to the following steps:

[0134] Step S1021: During the operation of the application pod, the master replica node receives an IO write request, and based on the local metadata information of the master replica node, synchronizes the IO write request to at least one slave replica node; the metadata information includes: multiple address parameters and multiple status parameters, the multiple address parameters represent the host where the master replica node is located and the hosts where each slave replica node is located; the multiple status parameters are used to distinguish the master replica node from each slave replica node.

[0135] Step S1022: The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request.

[0136] Step S1023, the master replica node records the synchronization log of the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request.

[0137] Step S1024: After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates the corresponding slave replica completion mark in the synchronization log.

[0138] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0139] Step S1028: After the primary replica node is restarted, reload the metadata information and the synchronization log.

[0140] When the master replica node restarts for any reason (such as system maintenance, fault recovery, etc.), it first needs to reload the previously saved metadata information and synchronization log. The synchronization log records the detailed information of all IO operations, including which operations have been successfully synchronized to which replica nodes, which operations have not been completed, etc.

[0141] By reloading this information, the master replica node can restore its previous state and understand the current data synchronization status, preparing for subsequent data recovery and synchronization operations.

[0142] Step S1029: The master replica node determines, according to the completion mark of the synchronization log, a slave replica node among the at least one slave replica node that has not completed synchronization.

[0143] After reloading the metadata information and the synchronization log, the master replica node can traverse the completion markers in the synchronization log to determine which slave replica nodes have successfully completed the synchronization of a specific IO operation and which nodes have not yet completed.

[0144] Through step S1029, the master replica node can identify all slave replica nodes that have not completed synchronization and determine targets for subsequent data synchronization operations.

[0145] Step S10210: Based on the metadata information, resynchronize the persistent data in the IO write request to the slave replica node that has not completed synchronization.

[0146] After re-receiving the persistent data in the IO write request, the slave replica node may verify, process, and store the data to ensure the integrity and consistency of the data.

[0147] In this embodiment, steps S1028-S10210 can ensure that data can be correctly restored and synchronized to all slave replica nodes even when the master replica node is restarted or fails.

[0148] As another optional embodiment of the present application, a flow chart of a method for hot migration of stateful applications based on local storage is provided in Embodiment 6 of the present application. This embodiment is mainly an implementation method of step S102 in Embodiment 1. Step S102 may include but is not limited to the following steps:

[0149] Step S1021: During the operation of the application pod, the master replica node receives an IO write request, and based on the local metadata information of the master replica node, synchronizes the IO write request to at least one slave replica node; the metadata information includes: multiple address parameters and multiple status parameters, the multiple address parameters represent the host where the master replica node is located and the hosts where each slave replica node is located; the multiple status parameters are used to distinguish the master replica node from each slave replica node.

[0150] Step S1022: The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request.

[0151] Step S1023, the master replica node records the synchronization log of the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request.

[0152] Step S1024: After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates the corresponding slave replica completion mark in the synchronization log.

[0153] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0154] Step S1028: After the primary replica node is restarted, reload the metadata information and the synchronization log.

[0155] Step S1029: The master replica node determines, according to the completion mark of the synchronization log, a slave replica node among the at least one slave replica node that has not completed synchronization.

[0156] Step S10210: Based on the metadata information, resynchronize the persistent data in the IO write request to the slave replica node that has not completed synchronization.

[0157] Step S10211: If the master replica node receives a synchronization request from a new master replica node, it synchronizes the synchronization log on the master replica node and the persistent data in the IO write request that has not been synchronized to the new master replica node, so that the new master replica node replaces the master replica node as the source of data synchronization.

[0158] The application management and scheduling platform can be configured to send IO (input / output) write requests specifically to the node determined as the primary replica. When a replica node (which may be a primary replica node or a secondary replica node) receives an IO write request from the application management and scheduling platform, the node will confirm that it is currently set as the primary replica node of the system and update the status in its local metadata information accordingly. The updated status is used to indicate that the node is the primary replica node.

[0159] The new master replica node can recount the numbers in the synchronization log and establish connections with other slave replica nodes to initiate synchronization.

[0160] When the new master replica node receives the persistent data from the original master replica node, it can update the conflict-free part according to its existing synchronization log and synchronize the persistent data to other unfinished slave replica nodes.

[0161] When receiving a synchronization request from the new master replica node, the slave replica node may update its local metadata information so that the updated metadata information corresponds to the new master replica node and the latest slave replica node.

[0162] When a slave replica node receives a synchronization request from the original master replica node, it does not need to process it.

[0163] Step S10212: The master replica node is downgraded to a slave replica node, and its local metadata information is updated.

[0164] The master replica node is downgraded to a slave replica node, and its local metadata information is updated. The updated metadata information corresponds to the new master replica node and the latest slave replica node.

[0165] In this embodiment, the synchronization log on the master replica node and the persistent data in the IO write request that has not completed synchronization are synchronized to the new master replica node, thereby ensuring the continuity and consistency of data during the node switching process. This helps prevent data loss or inconsistency, especially when the master replica node fails or needs to be transferred.

[0166] By downgrading the original master replica node to a slave replica node and updating its local metadata information so that the updated metadata information can accurately reflect the current node role and status, it helps to avoid confusion and conflicts between nodes.

[0167] Next, a stateful application hot migration device based on local storage provided in the present application is introduced. The stateful application hot migration device based on local storage introduced below and the stateful application hot migration method based on local storage introduced above can refer to each other.

[0168] Reference Figure 6 The local storage-based stateful application hot migration device includes: a creation module 100, a first synchronization module 200, a determination module 300 and a second synchronization module 400.

[0169] A creation module 100, configured to create a local volume on the primary replica node in response to a volume creation request for an application pod of a stateful application, and to establish an association relationship between the local volume and the application pod;

[0170] A first synchronization module 200 is used to store the persistent data of the application pod to the local volume during the operation of the application pod, and synchronize the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0171] A determination module 300, configured to respond to a migration request for the application pod and determine a destination node according to the migration request, wherein the destination node is from the at least one slave replica node;

[0172] The second synchronization module 400 is used to synchronize the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

[0173] The stateful application hot migration device based on local storage may also include:

[0174] A first receiving module is used to receive metadata information; the metadata information includes: the address and status of the master replica node; and the address and status of each slave replica node;

[0175] The first sending module is used to send the volume creation request to the corresponding slave replica node based on the metadata information, so that the slave replica node creates a data volume.

[0176] The first synchronization module 200 may be specifically used for:

[0177] During the operation of the application pod, receiving an IO write request, and synchronizing the IO write request to at least one slave replica node based on the metadata information local to the master replica node;

[0178] In response to the IO write request, storing the persistent data in the IO write request to the local volume;

[0179] A synchronization log recording the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset, and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request;

[0180] After receiving a completion message from a slave replica node in the at least one slave replica node, updating a corresponding slave replica completion mark in the synchronization log;

[0181] After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

[0182] The first synchronization module 200 may also be used for:

[0183] Based on the at least one slave replica completion marker, determining the number of slave replica nodes that have completed synchronization;

[0184] If the master replica node has completed the storage of the persistent data, the number of slave replica nodes that have completed synchronization is added to itself to determine the total number of replicas that have completed storage;

[0185] If the total number of copies that have completed storage reaches the set number threshold, an IO write success message is returned.

[0186] The first synchronization module 200 may also be used for:

[0187] After the master replica node is restarted, reloading the metadata information and the synchronization log;

[0188] Determine, according to the completion mark of the synchronization log, a slave replica node that has not completed synchronization among the at least one slave replica node;

[0189] Based on the metadata information, the persistent data in the IO write request is resynchronized to the slave replica node that has not completed synchronization.

[0190] The first synchronization module 200 may also be used for:

[0191] If a synchronization request from a new master replica node is received, the synchronization log on the master replica node and the persistent data in the IO write request that has not completed synchronization are synchronized to the new master replica node, so that the new master replica node replaces the master replica node as the source of data synchronization;

[0192] The master replica node is downgraded to a slave replica node, and its local metadata information is updated.

[0193] In an embodiment of the present application, a master replica node is further provided. The master replica node may include: a processor and a memory connected to the processor, wherein:

[0194] The memory is used to store computer programs;

[0195] The processor is used to execute the computer program to enable the master replica node to implement the following steps:

[0196] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0197] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0198] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0199] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0200] In an embodiment of the present application, a computer-readable storage medium is further provided, the storage medium carrying one or more computer programs, and when the one or more computer programs are executed by the master replica node, the master replica node can implement the following steps:

[0201] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0202] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0203] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0204] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0205] The embodiment of the present application also provides a stateful application hot migration system based on local storage, including:

[0206] A master replica node and at least one slave replica node in the Kubernetes cluster;

[0207] The master replica node is used to:

[0208] In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod;

[0209] During the operation of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node;

[0210] In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node;

[0211] The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

[0212] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0213] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0214] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0215] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A method for hot migration of stateful applications based on local storage, characterized in that: include: A master replica node in a Kubernetes cluster responds to a volume creation request for an application pod of a stateful application by creating a local volume on the master replica node and establishing an association relationship between the local volume and the application pod; During the operation of the application pod, the master replica node stores the persistent data of the application pod in the local volume, and synchronizes the persistent data to the data volume of each slave replica node in at least one slave replica node; The master replica node determines, in response to a migration request for the application pod, a destination node according to the migration request, where the destination node is from the at least one slave replica node; The primary replica node synchronizes the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

2. The method according to claim 1, characterized in that After creating a local volume on the primary replica node and establishing an association relationship between the local volume and the application pod, the method further includes: The master replica node receives metadata information; the metadata information includes: the address and status of the master replica node; and the address and status of each slave replica node; The master replica node sends the volume creation request to the corresponding slave replica node based on the metadata information, so that the slave replica node creates a data volume.

3. The method according to claim 1, characterized in that: The master replica node stores persistent data of the application pod in the local volume during the operation of the application pod, and synchronizes the persistent data to a data volume of each slave replica node in at least one slave replica node, including: The master replica node receives an IO write request during the operation of the application pod, and synchronizes the IO write request to at least one slave replica node based on the metadata information local to the master replica node; The primary replica node stores the persistent data in the IO write request to the local volume in response to the IO write request; The master replica node records a synchronization log of the IO write request; the synchronization log includes: the number of the IO write request, the starting position of the persistent data in the local volume, the occupied offset and at least one slave replica completion mark; the slave replica completion mark is used to indicate whether the slave replica node has completed the processing of the corresponding IO write request; After receiving a completion message from a slave replica node among the at least one slave replica node, the master replica node updates a corresponding slave replica completion mark in the synchronization log; After receiving the IO write request, each slave replica node in the at least one slave replica node stores the persistent data in the IO write request to its own data volume and returns a completion message.

4. The method according to claim 3, characterized in that The method further comprises: Based on the at least one slave replica completion marker, determining the number of slave replica nodes that have completed synchronization; If the master replica node has completed the storage of the persistent data, the master replica node adds the number of slave replica nodes that have completed synchronization to itself to determine the total number of replicas that have completed storage; If the total number of copies that have completed storage reaches the set number threshold, an IO write success message is returned.

5. The method according to claim 3, characterized in that: The method further comprises: After the master replica node is restarted, reloading the metadata information and the synchronization log; The master replica node determines, according to the completion mark of the synchronization log, a slave replica node that has not completed synchronization among the at least one slave replica node; Based on the metadata information, the persistent data in the IO write request is resynchronized to the slave replica node that has not completed synchronization.

6. The method according to claim 5, characterized in that The method further comprises: If the master replica node receives a synchronization request from the new master replica node, it synchronizes the synchronization log on the master replica node and the persistent data in the IO write request that has not completed synchronization to the new master replica node, so that the new master replica node replaces the master replica node as the source of data synchronization; The master replica node is downgraded to a slave replica node, and its local metadata information is updated.

7. A stateful application hot migration device based on local storage, characterized in that: include: A creation module, configured to create a local volume on the primary replica node in response to a volume creation request for an application pod of a stateful application, and establish an association relationship between the local volume and the application pod; A first synchronization module, configured to store persistent data of the application pod to the local volume and synchronize the persistent data to a data volume of each slave replica node in at least one slave replica node during the operation of the application pod; A determination module, configured to respond to a migration request for the application pod and determine a destination node according to the migration request, wherein the destination node is from the at least one slave replica node; The second synchronization module is used to synchronize the temporary data of the application pod on the primary replica node to the destination node to complete the migration of the application pod.

8. A master replica node, characterized in that: include: A processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program so that the master replica node can implement the following steps: In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod; During the running of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node; In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node; The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

9. A stateful application hot migration system based on local storage, characterized in that: include: A master replica node and at least one slave replica node in the Kubernetes cluster; The master replica node is used to: In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod; During the running of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node; In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node; The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.

10. A computer storage medium, characterized in that: The storage medium carries one or more computer programs, and when the one or more computer programs are executed by the master replica node, the master replica node can implement the following steps: In response to a volume creation request for an application pod of a stateful application, create a local volume on the primary replica node, and establish an association relationship between the local volume and the application pod; During the running of the application pod, storing the persistent data of the application pod in the local volume, and synchronizing the persistent data to the data volume of each slave replica node in at least one slave replica node; In response to a migration request for the application pod, determining a destination node according to the migration request, the destination node being from the at least one slave replica node; The temporary data of the application pod on the primary replica node is synchronized to the destination node to complete the migration of the application pod.