Hot updating method and device of server, server, storage medium and electronic equipment

By synchronizing static resources and memory states between servers and utilizing RDMA Write operations, the problem of long service interruption windows in server hot updates is solved, achieving an efficient, non-downtime hot update process and ensuring data consistency and reliability.

CN121187622BActive Publication Date: 2026-04-10GREE ELECTRIC APPLIANCE INC OF ZHUHAI +1
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-27
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as long service interruption windows, inefficient state migration, and difficulty in ensuring consistency during server hot updates. This is especially true when dealing with stateful services, which often require complex database synchronization or application-layer state export/import, leading to prolonged service interruptions.

Method used

By identifying the source and target servers, the static resources of the new version service are synchronized using data blocks. After the static resources are synchronized, the memory state of the source server is synchronized to the target server. Finally, the dynamic memory pages that the source server has not completed are processed on the target server. The RDMA Write operation is used to achieve efficient synchronization of static resources and memory state.

Benefits of technology

It enables non-stop updates, avoids long service interruptions, improves the efficiency of hot updates on the server, shortens the actual pause window to the millisecond level, and ensures data consistency and reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121187622B_ABST
    Figure CN121187622B_ABST
Patent Text Reader

Abstract

The application provides a hot updating method and device of a server, a server, a storage medium and an electronic device, and the method comprises the following steps: determining a source server and a target server to be hot updated, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service; synchronizing static resources of the new version service to the target server through data blocks; after the synchronization of the static resources is completed, synchronizing a memory state of the source server to the target server; after the synchronization of the memory state is completed, continuing to process a dynamic memory page that is not completed by the source server on the target server, and switching service traffic of the source server to the target server. By adopting the scheme of the embodiment, the technical problem of a long service interruption window during server hot updating in the prior art is solved, and the hot updating efficiency of the server is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of servers, in particular to a hot updating method and device of a server, a server, a storage medium and an electronic device. BACKGROUND

[0002] In the related art, a server needs to be updated due to expansion, failure and the like, and non-stop updating (also known as hot updating or rolling updating) of a service is the core of ensuring business continuity.

[0003] In the related art, the main schemes of non-stop updating are: blue-green deployment / A-B testing, deploying a brand new service (green zone), and then switching traffic through load balancing, the main problem is that for a stateful service (Stateful Service), how to efficiently and consistently migrate the "state" is a huge problem, and usually requires complex database synchronization or application layer state export / import, the process is slow and prone to errors, resulting in long service interruption; virtual machine / container live migration, such as VMware vMotion or KVM Live Migration, these technologies can migrate the entire operating system or container, but they are heavyweight, and they migrate the "environment" rather than the "service" itself, which is not fine-grained, and cannot handle the problem of incompatible memory layout caused by service code version changes, and the compatibility is poor; application layer hot updating, such as Erlang language which supports code hot loading by nature, but this requires the support of specific languages and frameworks, and does not have universality. The common shortcomings of the related art are that the efficiency and consistency of state migration are difficult to guarantee, and in the switching moment, the service is either temporarily frozen or some state data may be lost.

[0004] In view of the above problems in the related art, no efficient and accurate solution has been found. SUMMARY

[0005] The present application provides a hot updating method and device of a server, a server, a storage medium and an electronic device, to solve the technical problem of long service interruption window during server hot updating in the related art.

[0006] According to one embodiment of the present application, a hot updating method of a server is provided, comprising: determining a source server and a target server to be hot updated, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service; synchronizing static resources of the new version service to the target server through data blocks; after the synchronization of the static resources is completed, synchronizing a memory state of the source server to the target server; after the synchronization of the memory state is completed, continuing to process dynamic memory pages of the source server that are not completed on the target server, and switching service traffic of the source server to the target server.

[0007] Optionally, the synchronizing of the static resources of the new version service to the target server through data blocks comprises: sending a target data block list of the new version service to the target server, wherein the data block list comprises a plurality of target data blocks of the static resources of the new version service; generating a data block list between the old version service and the new version service based on the target data block list, wherein the data block list is used to store a plurality of static data blocks that are different between the old version service and the new version service; and writing resources belonging to the data block list in the target data block list to a target storage location of the target server using a remote direct memory write (RDMA Write) operation, so as to update the old version service locally running on the target server to the new version service.

[0008] Optionally, the generating of the data block list between the old version service and the new version service based on the target data block list comprises: reading a target hash value of each target data block in the target data block list; splitting a file of the old version service into a source data block list, and calculating a source hash value of each source data block in the source data block list; judging whether the source hash value is consistent with a corresponding target hash value; and if the source hash value is not consistent with the corresponding target hash value, adding a corresponding target data block in the target data block list to the data block list.

[0009] Optionally, the splitting of the file of the old version service into the source data block list comprises: parsing a tree structure of the old version service, and splitting a file of the old version service into a first source data block of a first level from a root node of the tree structure; calculating a first source hash value of the first source data block, and judging whether the first source hash value is consistent with a corresponding first target hash value; if the first source hash value is consistent with the corresponding first target hash value, determining that the splitting is completed; and if the first source hash value is not consistent with the corresponding first target hash value, continuing to split the first source data block into a plurality of second source data blocks of a second level.

[0010] Optionally, the synchronizing the memory state of the source server to the target server comprises: full-copying memory data in a key memory area of the source server to the target server by an RDMA Write operation; performing the following operations according to a period until the source server stops receiving external service requests: monitoring memory write operations of the source server and recording dynamic memory pages modified by the write operations; incrementally synchronizing the dynamic memory pages to corresponding memory locations of the target server by an RDMA Write operation.

[0011] Optionally, the continuing to process the unfinished dynamic memory pages of the source server on the target server comprises: judging whether memory layouts of the new version service and the old version service are adapted; if the memory layouts of the new version service and the old version service are adapted, controlling the target server to continue to process the unfinished dynamic memory pages of the source server based on the new version service; if the memory layouts of the new version service and the old version service are not adapted, controlling the target server to continue to process the dynamic memory pages by using a state migration function, wherein the state migration function is a memory patch program of the new version service.

[0012] Optionally, the controlling the target server to continue to process the dynamic memory pages by using the state migration function comprises: controlling the target server to call a preloaded state migration function; modifying source memory layout parameters of the dynamic memory pages to target memory layout parameters adapted to the new version service by using the state migration function to obtain intermediate memory pages; and controlling the target server to continue to process the intermediate memory pages based on the new version service.

[0013] According to another embodiment of the present application, a hot updating device of a server is provided, comprising: a determining module configured to determine a source server to be hot updated and a target server, wherein the source server is a server running an old version service and the target server is a server to be running a new version service; a synchronizing module configured to synchronize static resources of the new version service to the target server by data blocks; a synchronizing module configured to synchronize a memory state of the source server to the target server after the static resources are synchronized; and a switching module configured to continue to process unfinished dynamic memory pages of the source server on the target server after the memory state is synchronized, and switch service traffic of the source server to the target server.

[0014] Optionally, the first synchronization module comprises: a sending unit configured to send a target data block list of a new version service to the target server, wherein the data block list comprises a plurality of target data blocks of static resources of the new version service; a generating unit configured to generate a data block list between the old version service and the new version service based on the target data block list, wherein the data block list is used to store a plurality of static data blocks that are different between the old version service and the new version service; and a writing unit configured to write resources belonging to the data block list in the target data block list to a target storage location of the target server using a remote direct memory write (RDMA Write) operation, so as to update the old version service locally running on the target server to the new version service.

[0015] Optionally, the generating unit comprises: a reading subunit configured to read a target hash value of each target data block in the target data block list; a processing subunit configured to split a file of the old version service into a source data block list and calculate a source hash value of each source data block in the source data block list; a judging subunit configured to judge whether the source hash value is consistent with a corresponding target hash value; and an adding subunit configured to add a corresponding target data block in the target data block list to the data block list if the source hash value is not consistent with the corresponding target hash value.

[0016] Optionally, the processing subunit is further configured to: parse a tree structure of the old version service, split a file of the old version service into a first source data block of a first level from a root node of the tree structure; calculate a first source hash value of the first source data block and judge whether the first source hash value is consistent with a corresponding first target hash value; if the first source hash value is consistent with the corresponding first target hash value, determine that the splitting is completed; and if the first source hash value is not consistent with the corresponding first target hash value, continue to split the first source data block into a plurality of second source data blocks of a second level.

[0017] Optionally, the second synchronization module comprises: a copying unit configured to copy memory data in a key memory area of the source server to the target server by using an RDMA Write operation; and an operating unit configured to perform the following operations according to a period until the source server stops receiving external service requests: monitor a memory write operation of the source server and record a dynamic memory page modified by the write operation; and incrementally synchronize the dynamic memory page to a corresponding memory location of the target server by using an RDMA Write operation.

[0018] Optionally, the switching module comprises: a judging unit configured to judge whether the memory layout of the new version service is adapted to the memory layout of the old version service; and a control unit configured to control the target server to continue processing the dynamic memory page that is not completed by the source server based on the new version service if the memory layout of the new version service is adapted to the memory layout of the old version service, and control the target server to continue processing the dynamic memory page by using a state migration function if the memory layout of the new version service is not adapted to the memory layout of the old version service, wherein the state migration function is a memory patch program of the new version service.

[0019] Optionally, the control unit comprises: a calling subunit configured to control the target server to call the preloaded state migration function; a modifying subunit configured to modify the source memory layout parameter of the dynamic memory page into a target memory layout parameter that is adapted to the new version service by using the state migration function to obtain an intermediate memory page; and a processing subunit configured to control the target server to continue processing the intermediate memory page based on the new version service.

[0020] According to another embodiment of the present application, a server is provided, which comprises the hot updating device of the server as described in the above embodiments.

[0021] According to another aspect of the embodiments of the present application, a storage medium is also provided, which comprises a stored program, and the program performs the above steps when running.

[0022] According to another aspect of the embodiments of the present application, an electronic device is also provided, which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus; the memory is used to store a computer program; and the processor is used to execute the steps in the above method by running the program stored in the memory.

[0023] According to still another embodiment of the present application, a storage medium is also provided, which stores a computer program, and the computer program is set to execute the steps in any of the above device embodiments when running.

[0024] Through the embodiment of the present application, the source server and the target server to be subjected to hot update are determined, wherein the source server is a server running an old version service, and the target server is a server to be subjected to a new version service; the static resources of the new version service are synchronized to the target server through data blocks; after the synchronization of the static resources is completed, the memory state of the source server is synchronized to the target server; after the synchronization of the memory state is completed, the target server continues to process the dynamic memory pages that are not completed by the source server, the service traffic of the source server is switched to the target server, and the hot update of the service is decoupled into the synchronization of static resources and the synchronization of the memory state, so that the non-stop update of the source server is realized, the long-time interruption of the service caused by the hot update is avoided, the technical problem of a long service interruption window during the hot update of the server in the related art is solved, and the hot update efficiency of the server is improved. BRIEF DESCRIPTION OF DRAWINGS

[0025] The accompanying drawings, which are included to provide a further understanding of the present application and constitute a part of this application, illustrate certain illustrative embodiments of the present application and together with the description serve to explain the present application. In the drawings:

[0026] Figure 1 is a hardware structure block diagram of a server according to an embodiment of the present application;

[0027] Figure 2 is a flowchart of a hot update method of a server according to an embodiment of the present application;

[0028] Figure 3 is a tree structure diagram according to an embodiment of the present application;

[0029] Figure 4 is a hot update principle diagram based on RDMA and block version negotiation according to an embodiment of the present application;

[0030] Figure 5 is a structure block diagram of a hot update device of a server according to an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to enable persons skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by persons skilled in the art without creative labor should fall within the protection scope of the present application. It should be noted that, in the case of no conflict, the embodiments in the present application and the features in the embodiments can be combined with each other.

[0032] It should be noted that the terms "first", "second" and the like in the description and in the claims of the present application are used to distinguish between similar objects and not necessarily for describing a specific sequential or chronological order. It is to be understood that the use of these terms herein is to be construed as interchangeable in order to describe the embodiments of the present application that can be implemented in other than the illustrated or described order. Furthermore, the terms "comprise", "comprising", "include", "including" and the like used herein are specifically intended to be construed in an inclusive sense and not in an exclusive sense, that is, they specifically permit the inclusion of more than what is listed after the term in the claims.

[0033] Embodiment 1

[0034] The method provided by the embodiment of the present application can be executed in a server, a computer, a controller-like device management apparatus. Taking the case of running on a server, Figure 1 is a hardware structure block diagram of a server of an embodiment of the present application. As shown in Figure 1 , the server can include one or more (only one is shown in Figure 1 ) processor 102 (the processor 102 can include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the above-mentioned server can also include a transmission device 106 for communication function and an input and output device 108. Those skilled in the art can understand that Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned server. For example, the server can also include more or less components than those shown in Figure 1 , or have a different configuration from Figure 1 .

[0035] The memory 104 can be used to store server programs, such as software programs of application software and modules, such as the server program corresponding to the hot updating method of a server of an embodiment of the present application. The processor 102 performs various functional applications and data processing by running the server program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the server through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0036] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of a server. In an example, the transmission device 106 includes a network interface controller (NIC) configured to connect to other network devices via a base station and communicate with the Internet. In an example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet via a wireless manner.

[0037] A hot updating method of a server is provided in the embodiment, Figure 2 A flowchart of a hot updating method of a server according to an embodiment of the present application is shown in FIG. 2, which includes the following steps: Figure 2

[0038] In step S202, a source server and a target server to be hot updated are determined, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service.

[0039] The source server and the target server in the embodiment can be servers capable of processing the same service, such as a master server and a standby server, two servers in a distributed network architecture, etc. In the embodiment, the source server is node A, the target server is node B, the new version service is Service V2, the old version service is Service V1, the source server is an active node currently running the old version service and processing real-time service, the initial state of the target server is an idle state, and the target server is in a working state after the hot updating is completed.

[0040] The target server runs the old version service before the static resource synchronization of the new version service is completed, and runs the new version service after the static resource synchronization of the new version service is completed.

[0041] In step S204, the static resource of the new version service is synchronized to the target server through data blocks.

[0042] Optionally, the static resource is an executable code segment, a read-only constant, static data, a configuration file / template / script, metadata and a symbol table, etc. The static resource is data that is not modified during the running of the server and belongs to a "cold page".

[0043] In step S206, the memory state of the source server is synchronized to the target server after the static resource synchronization is completed.

[0044] ​Step S208, after the memory state synchronization is completed, the target server continues to process the dynamic memory pages that are not completed by the source server, and the service traffic of the source server is switched to the target server.

[0045] During the service empty window period of the source server, there is no new service request, the memory state synchronization of the historical time is completed, the source server stops receiving new external requests, the service traffic is switched to the target server, and the hot update switching is completed.

[0046] Through the above steps, the source server and the target server to be subjected to the hot update are determined, the source server is a server running an old version service, and the target server is a server to be subjected to a new version service; the static resources of the new version service are synchronized to the target server through data blocks; after the static resource synchronization is completed, the memory state of the source server is synchronized to the target server; after the memory state synchronization is completed, the target server continues to process the dynamic memory pages that are not completed by the source server, and the service traffic of the source server is switched to the target server. The hot update of the service is decoupled into static resource synchronization and memory state synchronization, non-downtime updating of the source server is implemented, service interruption caused by the hot update is avoided, the technical problem of a long service interruption window during server hot updating in the related art is solved, and the hot updating efficiency of the server is improved.

[0047] In one embodiment of the present embodiment, synchronizing the static resources of the new version service to the target server through data blocks comprises:

[0048] S11, a target data block list of a new version service is sent to the target server, wherein the data block list comprises a plurality of target data blocks of static resources of the new version service;

[0049] S12, a data block list between the old version service and the new version service is generated based on the target data block list, wherein the data block list is used to store a plurality of static data blocks that are different between the old version service and the new version service;

[0050] The target server performs self-difference analysis locally, and independently and quickly determines which code blocks that are already present in the local target server are inconsistent with the new version (Service V2), thereby generating a minimized PullList (data block list to be pulled).

[0051] The target data block in the target data block list of the embodiment refers to the minimum "cold data" unit necessary for the new version service to start, including executable code segments, read-only constants and static data, configuration files / templates / scripts, and metadata and symbol tables, which are not modified at runtime and belong to cold pages. Therefore, the target server can subsequently read and compare only, write the corresponding file mapping area or tmpfs (a memory-based temporary file system) of the target server by RDMA Write once.

[0052] The target data in the above target data block list is pre-cut into "blocks" with a fixed size (4KB / 64KB) and entered into the list.

[0053] S13, using the remote direct memory write RDMA Write operation to write the resources belonging to the data block list in the target data block list to the target storage location of the target server, to update the old version service running locally on the target server to the new version service.

[0054] The RDMA (Remote Direct Memory Access) Write of the embodiment can bypass the operating system kernel of both the source server and the target server during copying, change the data path from "traditional CPU intervention, kernel protocol stack" to "network card direct memory" zero-copy, kernel bypass mechanism, implement network card to network card remote DMA, allow the application program to directly read and write the memory of a remote machine without going through the operating system, CPU or GPU processing, thereby realizing the efficiency of data read and write.

[0055] In one example, generating the data block list between the old version service and the new version service based on the target data block list includes: reading the target hash value of each target data block in the target data block list; splitting the files of the old version service into a source data block list and calculating the source hash value of each source data block in the source data block list; determining whether the source hash value is consistent with the corresponding target hash value; if the source hash value is not consistent with the corresponding target hash value, adding the corresponding target data block in the target data block list to the data block list.

[0056] In the present example, the process of obtaining the PullList (list of data blocks) includes: the coordinator of the hot update (running on the source server or the target server, or a third-party controller) first issues the complete target data block list of Service V2 to node B, which includes the ID (hash value) of each target data block, the offset address of the target data block in the memory or disk, the block size and the block type (code segment, static resource or configuration segment, etc.); node B starts a lightweight differential analysis thread that does not interfere with the main service to scan the local existing Service V1 memory image or disk file, divides the file into the size of the blocks defined in the list and calculates the hash value of each block, compares the calculation result with the hash value of the corresponding block in the list, and if the hash value of a local block is inconsistent with the corresponding block in the list or the corresponding block does not exist locally, it is added to the PullList, and each item in the PullList includes the block ID (hash value), the target address (the write position in the memory of node B) and the source address (the position of node A, if node A does not have the data block, it is empty).

[0057] By using the scheme of the present embodiment, a content-addressed, verifiable and incremental code and resource synchronization mechanism is realized through the block synchronization mechanism, which is used for efficiently transmitting differential blocks in the hot update process. By cutting the service code and other static resources into content-addressed fixed-size blocks, combining the differential analysis of new and old versions of services and the RDMA zero-copy transmission, millisecond-level, verifiable and low-bandwidth hot update code synchronization is realized, which improves the transmission speed of static resources of the server in the hot update process and ensures the accuracy of the synchronization of static data.

[0058] In one implementation scenario, splitting the files of the old version of the service into a source data block list includes: parsing a tree structure of the old version of the service, and splitting files of the old version of the service into first source data blocks of a first level from a root node of the tree structure; calculating a first source hash value of the first source data blocks, and determining whether the first source hash value is consistent with a corresponding first target hash value; if the first source hash value is consistent with the corresponding first target hash value, determining that the splitting is completed; and if the first source hash value is inconsistent with the corresponding first target hash value, continuing to split the first source data blocks into second source data blocks of a second level.

[0059] Before splitting the file of the old version service into the source data block list, the total data amount of the target data block list can be read first, if the total data amount is small (less than a preset threshold, such as 1MB), the splitting into a preset number can be directly performed, if the total data amount is large (greater than or equal to the preset threshold), hierarchical splitting can be performed. For the old version service or the new version service with a large data amount, when the PullList is acquired, hierarchical differential detection (tree hash) can be used, the entire file is first divided into large blocks, quick comparison is performed, after inconsistency is found, the block is split into small blocks layer by layer for comparison, the difference is accurately located, and the amount of hash calculation is reduced. For example, the block cutting and the tree structure are first determined, the depth and granularity are fixed, each parent block saves a hash list of child blocks, and the leaf block retains the original data. Figure 3 is a tree structure diagram of an embodiment of the present application, including three levels L0-L2, the data block of the L0 level is a super block, the data block of the L1 level is a child block, and the data block of the L2 level is a leaf block. The data block of the L0-L2 level has a size of 4 MB, 64 KB, and 4 KB respectively. The tree structure of the Service V2 list is parsed to obtain the entire tree. The breadth-first comparison is performed from the root of the tree structure. The 4MB super block hash of the local corresponding L0 level is first calculated. If the hash is consistent with the list, no further comparison is performed. If the hash is inconsistent, the L0 is split to calculate the hash of all L1 level child blocks thereunder. The L1 child block that is still inconsistent is continuously split to the L2 level until the leaf node is located at the leaf level. Finally, only the 4KB leaf block ID that is truly different is added to the PullList. The hierarchical tree hash differential detection reduces the calculation amount of the full amount hash comparison, and reduces the time complexity from O(N) to O(logN).

[0060] By using the scheme of the present embodiment, the calculation amount of the full amount hash comparison is reduced by using hierarchical tree hash differential detection, and the time complexity and comparison time are reduced.

[0061] By using the scheme of the present embodiment, in the synchronization process of the static resource, the target server locally uses the hierarchical differential detection to calculate the data block list, and then completes the synchronization by using the RDMA operation. The target server uses the RDMA Write operation to directly write the data block located in the data block list and required by the target server into the target memory address or storage of the target server. The synchronization process of the static resource bypasses the operating system kernel of both parties, realizes zero copy, is extremely fast, is almost equivalent to local memory copy, the target server quickly builds the executable file and the static resource that are completely consistent with the new version service, avoids loading the complete new version service on the target server, and reduces the synchronization time of the static resource during the hot update of the new and old versions.

[0062] In one embodiment of the present embodiment, synchronizing the memory state of the source server to the target server comprises: full-copying the memory data in the key memory area of the source server to the target server through an RDMA Write operation; performing the following operations according to a period until the source server stops receiving external service requests: monitoring the memory write operation of the source server and recording the dynamic memory pages modified by the write operation; and incrementally synchronizing the dynamic memory pages to the corresponding memory location of the target server through an RDMA Write operation.

[0063] Optionally, the key memory area includes a Heap area and a data segment area of the memory, and the first full memory snapshot: the old version service of node A is still running, the coordinator commands node A to copy the data of the key memory area (such as Heap and data segment) of the service of node A to a reserved memory area of node B through an RDMA Write, which is equivalent to an efficient and real-time memory snapshot. During and after the first copying, the operating system (or a special runtime) of node A continuously tracks the write operation of the old version service of node A to the memory and records all the dynamic memory pages (i.e., dirty pages) modified thereby. Node A periodically and frequently synchronizes the latest content of the dirty pages to the corresponding memory location of node B through an RDMA Write incrementally. This process is repeated for multiple rounds, and the amount of data to be synchronized in each round becomes less and less until the source server stops receiving external service requests and no new dynamic memory page is generated within a certain time period, so that the switching between the source server and the target server can be realized.

[0064] When the switching is finally performed, an instruction is sent to node A to temporarily stop accepting new external service requests (service suspension window, usually in milliseconds). Node A performs the last dirty page synchronization (if there is a new dynamic memory page) and synchronizes all the memory changes from the suspension instant to the last synchronization to node B through an RDMA. After the final synchronization is completed, the service of the source server is stopped, all new service traffic is directed to node B through a load balancer or network routing, and the traffic switching from the source server to the target server is realized.

[0065] By synchronizing the dynamic memory pages of the source server, the scheme of the present embodiment can realize real non-downtime update, the actual service suspension window is shortened to milliseconds, the user is completely unaware, and the incrementally synchronized dynamic memory pages through an RDMA Write operation reduce the delay by several orders of magnitude, and the migration efficiency of the memory state is improved.

[0066] In one example of the embodiment, continuing processing of the dynamic memory page that the source server did not complete on the target server includes: determining whether the memory layout of the new version service and the old version service are compatible; if the memory layout of the new version service and the old version service are compatible, controlling the target server to continue processing the dynamic memory page that the source server did not complete based on the new version service; and if the memory layout of the new version service and the old version service are incompatible, controlling the target server to continue processing the dynamic memory page using a state migration function, wherein the state migration function is a memory patch program of the new version service.

[0067] Due to version upgrade, the memory layout of the new version service and the old version service can be different, and if there is a difference, the synchronized memory state cannot be directly processed on the target server, and needs to be adapted to the new memory layout first.

[0068] By using the scheme of the embodiment, when the memory layout of the new version service and the old version service are incompatible, it is determined whether the memory layout of the new version service and the old version service are compatible, and the synchronized dynamic memory page is processed accordingly, avoiding that the target server cannot continue processing the synchronized dynamic memory page, and improving the stability, smoothness, and data security of the hot update process.

[0069] Optionally, controlling the target server to continue processing the dynamic memory page using the state migration function includes: controlling the target server to call a preloaded state migration function; using the state migration function to modify the source memory layout parameter of the dynamic memory page to a target memory layout parameter compatible with the new version service to obtain an intermediate memory page; and controlling the target server to continue processing the intermediate memory page based on the new version service.

[0070] If the memory layout of Service V2 is different from V1, node B will execute a pre-defined, lightweight "state migration function" to quickly adjust the synchronized data structure in its own memory. The state migration function is a lightweight memory patch program written in advance for the service and released with the version, and its role is to locally rewrite the running-time data synchronized from node A according to the old version memory layout into the layout required by the new version in the local memory of node B, convert the dynamic memory page of the old memory layout into the format of the new memory layout, so that Service V2 can be directly used, and can seamlessly run without re-initialization. Service V2 of node B starts from the migrated memory state and directly enters the running state, instead of cold start.

[0071] By adopting the scheme of the embodiment, the source memory layout parameter of the dynamic memory page is modified into the target memory layout parameter adaptive to the new version service through the state migration function, and the compatibility of the target server to the source server is improved.

[0072] Figure 4 is a hot update principle diagram based on RDMA and block version negotiation in the embodiment of the application, node A is a source server, node B is a target server, a coordinator is a controller of the hot update (which can run on node A or node B, or be an independent server), and the hot update process includes stages one to three. Stage one includes: code and static resource synchronization, target data block list is issued, node B generates a PullList (data block list), and code blocks are transmitted through RDMA Write. Stage two includes: memory state synchronization. First, a full-amount memory snapshot is copied, then a plurality of rounds of incremental “dirty page” tracking and synchronization are performed, and incremental synchronization to the corresponding memory position of node B is performed through RDMA Write. After the plurality of rounds of synchronization are completed, stage three is entered. Stage three includes: suspending new requests of node A, performing the last dirty leaf synchronization, performing memory layout migration in node B, starting ServiceV2, switching traffic to node B, finally releasing resources of node A, and node B formally takes over the service. Node A can be released or used as a candidate node for the next update.

[0073] The scheme of the embodiment decouples the service update process into two parallel stages of “code synchronization” and “memory synchronization”, efficiently updates code and static resources by using the block synchronization model, and directly synchronizes the real-time memory state of the service between nodes at a speed close to the memory bus by using the RDMA technology. By adopting the scheme of the embodiment, the actual service suspension window is shortened to the millisecond level (the time of the final dirty page synchronization + traffic switching), the user is completely unaware, a real “non-downtime” update is realized, the speed of memory synchronization is increased from the “network speed” of the traditional TCP / IP to the “memory speed” by using the RDMA, the delay is reduced by several orders of magnitude, the efficiency bottleneck of state migration is perfectly solved, the scheme does not depend on a specific programming language or framework, can be applied to any service that can obtain its memory state, has extremely high universal value, code synchronization is based on hash block verification, memory synchronization is direct hardware-level memory copying, the whole process is accurate and reliable, and data consistency is guaranteed.

[0074] Those skilled in the art can clearly understand that the method according to the above-mentioned embodiments can be realized by means of software and necessary general hardware platform, of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application or the part of the prior art can be embodied in the form of software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a plurality of instructions to make a terminal device (may be mobile phone, computer, server, or network equipment, etc.) execute the method described in various embodiments of the present application.

[0075] Embodiment 2

[0076] In this embodiment, a server hot updating device and a server are also provided, which are used to realize the above-mentioned embodiments and preferred embodiments, and will not be described again. The term "module" as used below can be a combination of software and hardware that realizes the predetermined function. Although the device described in the following embodiments is preferably realized in software, the realization of hardware, or the combination of software and hardware can also be conceived.

[0077] Figure 5 is a structural block diagram of a server hot updating device according to an embodiment of the present application, as shown in Figure 5 , comprising:

[0078] A determining module 51 is configured to determine a source server and a target server to be hot updated, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service.

[0079] A first synchronizing module 52 is configured to synchronize static resources of the new version service to the target server through data blocks.

[0080] A second synchronizing module 53 is configured to synchronize a memory state of the source server to the target server after the synchronization of the static resources is completed.

[0081] A switching module 54 is configured to continue processing a dynamic memory page of the source server that is not completed on the target server after the synchronization of the memory state is completed, and switch a service flow of the source server to the target server.

[0082] Optionally, the first synchronization module comprises: a sending unit configured to send a target data block list of a new version service to the target server, wherein the data block list comprises a plurality of target data blocks of static resources of the new version service; a generating unit configured to generate a data block list between the old version service and the new version service based on the target data block list, wherein the data block list is used to store a plurality of static data blocks that are different between the old version service and the new version service; and a writing unit configured to write resources belonging to the data block list in the target data block list to a target storage location of the target server using a remote direct memory write (RDMA Write) operation, so as to update the old version service locally running on the target server to the new version service.

[0083] Optionally, the generating unit comprises: a reading subunit configured to read a target hash value of each target data block in the target data block list; a processing subunit configured to split a file of the old version service into a source data block list and calculate a source hash value of each source data block in the source data block list; a judging subunit configured to judge whether the source hash value is consistent with a corresponding target hash value; and an adding subunit configured to add a corresponding target data block in the target data block list to the data block list if the source hash value is not consistent with the corresponding target hash value.

[0084] Optionally, the processing subunit is further configured to: parse a tree structure of the old version service, split a file of the old version service into a first source data block of a first level from a root node of the tree structure; calculate a first source hash value of the first source data block and judge whether the first source hash value is consistent with a corresponding first target hash value; if the first source hash value is consistent with the corresponding first target hash value, determine that the splitting is completed; and if the first source hash value is not consistent with the corresponding first target hash value, continue to split the first source data block into a plurality of second source data blocks of a second level.

[0085] Optionally, the second synchronization module comprises: a copying unit configured to copy memory data in a key memory area of the source server to the target server by using an RDMA Write operation; and an operating unit configured to perform the following operations according to a period until the source server stops receiving external service requests: monitor a memory write operation of the source server and record a dynamic memory page modified by the write operation; and incrementally synchronize the dynamic memory page to a corresponding memory location of the target server by using an RDMA Write operation.

[0086] Optionally, the switching module comprises: a judging unit configured to judge whether the memory layout of the new version service is adapted to the memory layout of the old version service; and a control unit configured to control the target server to continue processing the dynamic memory page that is not completed by the source server based on the new version service if the memory layout of the new version service is adapted to the memory layout of the old version service, and control the target server to continue processing the dynamic memory page by using a state migration function if the memory layout of the new version service is not adapted to the memory layout of the old version service, wherein the state migration function is a memory patch program of the new version service.

[0087] Optionally, the control unit comprises: a calling subunit configured to control the target server to call the preloaded state migration function; a modifying subunit configured to modify the source memory layout parameter of the dynamic memory page into a target memory layout parameter that is adapted to the new version service by using the state migration function to obtain an intermediate memory page; and a processing subunit configured to control the target server to continue processing the intermediate memory page based on the new version service.

[0088] The embodiment of the present application also provides a server comprising the hot updating device of the server as described in the above embodiment.

[0089] It should be noted that the above modules can be realized by software or hardware, and for the latter, the following realization manners can be used, but are not limited to: the above modules are located in the same processor; or the above modules are located in different processors in any combination.

[0090] Embodiment 3

[0091] The embodiment of the present application also provides a storage medium in which a computer program is stored, wherein the computer program is set to execute the steps in any method embodiment described above when running.

[0092] Optionally, in the present embodiment, the storage medium can be set to store the computer program for execution.

[0093] S1, determining a source server and a target server to be subjected to hot updating, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service;

[0094] S2, synchronizing static resources of the new version service to the target server by using data blocks;

[0095] S3, synchronizing the memory state of the source server to the target server after the synchronization of the static resources is completed;

[0096] S4, after the memory state synchronization is completed, continuing to process the dynamic memory page that is not completed by the source server on the target server, and switching the service traffic of the source server to the target server.

[0097] Optionally, in the embodiment, the storage medium can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various computer program storage media.

[0098] The embodiment of the application further provides an electronic device including a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the method embodiments.

[0099] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the transmission device is connected with the processor, and the input / output device is connected with the processor.

[0100] Optionally, in the embodiment, the processor can be configured to execute the following steps through the computer program:

[0101] S1, determining a source server and a target server to be subjected to hot updating, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service;

[0102] S2, synchronizing static resources of the new version service to the target server through data blocks;

[0103] S3, after the static resource synchronization is completed, synchronizing the memory state of the source server to the target server;

[0104] S4, after the memory state synchronization is completed, continuing to process the dynamic memory page that is not completed by the source server on the target server, and switching the service traffic of the source server to the target server.

[0105] Optionally, specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.

[0106] The serial numbers of the above embodiments of the application are only for description, and do not represent the advantages and disadvantages of the embodiments.

[0107] In the above embodiments of the application, the description of each embodiment has its own emphasis, and the parts not described in detail in a certain embodiment can refer to the related description of other embodiments.

[0108] In several embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other manners. For example, the described embodiments of the apparatus are merely schematic, and the division of units is merely logical function division, and there can be other division manners in actual implementation. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some interfaces, and electrical or other forms.

[0109] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments.

[0110] In addition, each functional unit in the embodiments of the present application can be integrated in a processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware or in the form of a software functional unit.

[0111] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer program product readable by a computer. Based on such an understanding, the technical solutions of the present application essentially or the part contributing to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a controller, or a network device, etc.) to execute all or part of the steps of the methods in the embodiments of the present application. The foregoing storage medium includes: a U disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a mobile hard disk, a magnetic disk or an optical disk, and various other media that can store program codes.

[0112] The above are only the preferred embodiments of the present application, and it should be pointed out that, for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which should be considered as the protection scope of the present application.

Claims

1. A hot update method of a server, characterized by, The method comprises the following steps: determining a source server and a target server to be hot-updated, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service; synchronizing static resources of the new version service to the target server through data blocks; after the synchronization of the static resources is completed, synchronizing a memory state of the source server to the target server; after the synchronization of the memory state is completed, continuing to process dynamic memory pages that are not completed by the source server on the target server, and switching service traffic of the source server to the target server; wherein the synchronization of the memory state of the source server to the target server comprises: copying memory data in a key memory area of the source server to the target server through an RDMA Write operation; and performing the following operations according to a period until the source server stops receiving external service requests: monitoring memory write operations of the source server, and recording dynamic memory pages modified by write operations; and synchronizing the dynamic memory pages to corresponding memory positions of the target server through an RDMA Write operation.

2. The method of claim 1, wherein, The synchronization of the static resources of the new version service to the target server through data blocks comprises: sending a target data block list of the new version service to the target server, wherein the data block list comprises a plurality of target data blocks of the static resources of the new version service; generating a data block list between the old version service and the new version service based on the target data block list, wherein the data block list is used to store a plurality of static data blocks that are different between the old version service and the new version service; writing resources belonging to the data block list in the target data block list to a target storage position of the target server using an RDMA Write operation, so as to update the old version service locally running on the target server to the new version service.

3. The method of claim 2, wherein, The generation of the data block list between the old version service and the new version service based on the target data block list comprises: reading a target hash value of each target data block in the target data block list; splitting a file of the old version service into a source data block list, and calculating a source hash value of each source data block in the source data block list; determining whether the source hash value is consistent with the corresponding target hash value; if the source hash value is not consistent with the corresponding target hash value, adding the corresponding target data block in the target data block list to the data block list.

4. The method of claim 3, wherein, The splitting of the file of the old version service into the source data block list comprises: parsing a tree structure of the old version service, and splitting the file of the old version service into a first source data block of a first level from a root node of the tree structure; calculating a first source hash value of the first source data block, and determining whether the first source hash value is consistent with a corresponding first target hash value; If the first source hash value is consistent with the corresponding first target hash value, it is determined that the splitting is completed; if the first source hash value is inconsistent with the corresponding first target hash value, the first source data block is continuously split into a plurality of second source data blocks of a second level.

5. The method of claim 1, wherein, Continuing to process the dynamic memory page not completed by the source server on the target server includes: determining whether the memory layout of the new version service and the old version service is adapted; if the memory layout of the new version service and the old version service is adapted, controlling the target server to continue to process the dynamic memory page not completed by the source server based on the new version service; if the memory layout of the new version service and the old version service is not adapted, controlling the target server to continue to process the dynamic memory page by using a state migration function, wherein the state migration function is a memory patch program of the new version service.

6. The method of claim 5, wherein, Controlling the target server to continue to process the dynamic memory page by using a state migration function includes: controlling the target server to call the preloaded state migration function; modifying the source memory layout parameter of the dynamic memory page to a target memory layout parameter adapted to the new version service by using the state migration function, to obtain an intermediate memory page; controlling the target server to continue to process the intermediate memory page based on the new version service.

7. A hot update apparatus of a server, characterized by comprising: comprises: a determining module configured to determine a source server and a target server to be subjected to hot updating, wherein the source server is a server running an old version service, and the target server is a server to be running a new version service; a first synchronizing module configured to synchronize static resources of the new version service to the target server through data blocks; a second synchronizing module configured to, after the synchronization of the static resources is completed, synchronize a memory state of the source server to the target server; a switching module configured to, after the synchronization of the memory state is completed, continue to process a dynamic memory page not completed by the source server on the target server, and switch service traffic of the source server to the target server; wherein the second synchronizing module comprises: a copying unit configured to copy, through an RDMA Write operation, memory data in a key memory area of the source server to the target server in full; and an operating unit configured to, until the source server stops receiving external service requests, monitor a memory write operation of the source server and record a dynamic memory page modified by the write operation, and synchronize the dynamic memory page to a corresponding memory location of the target server through an RDMA Write operation in increments.

8. A server, characterized by The hot updating device of the server of claim 7.

9. A storage medium, characterized by A storage medium has stored therein a computer program, wherein the computer program is configured to execute the steps of the hot updating method of the server of any one of claims 1 to 6 when running.

10. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein, A processor, a communication interface, and a memory complete communication with each other through a communication bus; wherein: the memory is configured to store a computer program; and A processor for executing the steps of the hot update method of the server of any one of claims 1 to 6 by running a program stored on a memory.

Citation Information

Patent Citations

  • Information processing apparatus and control method

    US20150278333A1