A method and device for implementing a state synchronization middleware for stateful services
By deploying state synchronization middleware in a distributed cluster of Raft protocol, the problem of microservice gateway lacking state synchronization function is solved, and state synchronization of state services and horizontal expansion of distributed microservices is achieved.
Patent Information
- Application Number
- CN202211649903.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2042-12-21
AI Technical Summary
The existing microservice gateway lacks state synchronization between services, resulting in the implementation of highly available distributed services that require the microservices to achieve stateless, idempotence and reliability, and the horizontal expansion of distributed microservices cannot be achieved under certain design patterns.
Deploy the state synchronization middleware in a distributed cluster based on the Raft protocol. By creating a state synchronization packet, receiving identity information of the service node, registering to a synchronous state packet, sending heartbeat interface requests, electing a Leader node, forwarding client operation requests, and synchronizing the operation log of the Leader node.
The state synchronization function of stateful services is realized, and the horizontal expansion capacity of distributed microservices is expanded to minimize changes to existing services or systems.
Smart Images

Figure CN115955504B_ABST
Abstract
Description
Technical Field
[0001] The present specification relates to the field of computer software technology, and in particular to a method, device, electronic device and storage medium for implementing state synchronization middleware for stateful services. Background Art
[0002] At present, most microservice gateways do not provide inter-service state synchronization functions, which means that in order to achieve highly available distributed services, the microservices themselves need to achieve statelessness, idempotence, and reliability. However, when some special design patterns cannot meet these conditions, it is impossible to achieve the horizontal expansion capabilities of distributed microservices. And in the original system, it often requires a lot of development work to achieve horizontal expansion and state synchronization alone. Raft, as an important protocol for solving the consistency problem of distributed systems, can effectively solve the state synchronization problem. However, the direct application of the Raft protocol requires relatively complex changes to the service or system. Therefore, how to use the advantages of the Raft protocol in solving the consistency of distributed systems to achieve state synchronization of stateful services is a technical problem that needs to be solved urgently. Summary of the invention
[0003] The purpose of the embodiments of this specification is to provide a method, device, electronic device and storage medium for implementing state synchronization middleware for stateful services in order to solve the above problems.
[0004] To solve the above technical problems, the embodiments of this specification are implemented as follows:
[0005] In a first aspect, a method for implementing a state synchronization middleware for a stateful service is proposed. The state synchronization middleware is deployed in a distributed cluster based on the Raft protocol. The state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes, including:
[0006] Creating a state synchronization group and receiving the identity information of the service node and registering it to the synchronization state group; wherein the state synchronization group includes a state operation interface definition and / or a heartbeat interface definition, and the service node provides an interface implementation method corresponding to the corresponding operation interface definition of the state synchronization group;
[0007] In the current Raft term, a heartbeat interface request is sent to the service nodes in the state synchronization group, and a leader node is selected from the service nodes that successfully return the request based on the time sequence of the service nodes returning the request;
[0008] When receiving the operation request of the client, forward the operation request to the Leader node, so that the Leader node performs the status operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes within the status synchronization group.
[0009] Further, the service nodes include stateful backend services, applications, and / or systems; the clients include users, applications, and / or systems that obtain services from the service nodes.
[0010] Further, the service nodes within the status synchronization group establish network connections according to the status synchronization requirements.
[0011] Further, the definition of the status operation interface at least includes the interface definitions corresponding to the operations of adding, deleting, modifying, and / or querying the status.
[0012] Further, the sending of the heartbeat interface request to the service nodes within the status synchronization group includes sending a heartbeat interface request to the service nodes within the status synchronization group according to a preset heartbeat monitoring request period.
[0013] Further, it also includes: when the heartbeat interface monitoring feedback of the Leader node cannot be received, a new Raft term is generated and a Leader node is elected.
[0014] In a second aspect, a state synchronization middleware implementation device for stateful services is proposed. The state synchronization middleware is deployed in a distributed cluster based on the Raft protocol. The state synchronization middleware is used to receive client requests and implement state synchronization among stateful service nodes, and includes:
[0015] A first module capable of creating a status synchronization group, receiving the identity information of the service nodes, and registering it to the synchronization status group; wherein, the status synchronization group includes the definition of the status operation interface and / or the definition of the heartbeat interface, and the service nodes provide the interface implementation methods corresponding to the corresponding operation interface definitions of the status synchronization group.
[0016] A second module capable of, in the current Raft term, sending a heartbeat interface request to the service nodes within the status synchronization group, and, among the service nodes that return a successful request, electing a Leader node based on the time sequence of the requests returned by each service node.
[0017] A third module, which is capable of forwarding the operation request to the Leader node when receiving the operation request from the client, so that the Leader node performs a status operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes within the status synchronization group.
[0018] Further, it further includes:
[0019] A fourth module, which is capable of generating a new Raft term and electing a Leader node when the heartbeat interface monitoring feedback of the Leader node cannot be received.
[0020] In a third aspect, an electronic device is provided, which is characterized by including:
[0021] A processor; and
[0022] A memory arranged to store computer-executable instructions, and when the executable instructions are executed, the processor executes the method for implementing a status synchronization middleware for stateful services described in the first aspect.
[0023] In a fourth aspect, a computer-readable storage medium is provided, which is characterized in that the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including a plurality of application programs, the electronic device executes the method for implementing a status synchronization middleware for stateful services described in the first aspect.
[0024] This specification can achieve at least the following technical effects:
[0025] Under the premise of minimizing changes to the existing services or systems, the solution of the present invention can establish a mapping relationship by defining a status synchronization interface and an existing status operation interface in the existing service system, and can implement the status synchronization function of stateful services or systems, thereby expanding capabilities such as horizontal expansion of distributed microservices. Description of the Drawings
[0026] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in this specification. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0027] Figure 1 It is one of the schematic diagrams of the method for implementing a status synchronization middleware for stateful services provided by the embodiments of this specification.
[0028] Figure 2Schematic diagram 2 of the state synchronization middleware implementation method for stateful services provided by the embodiments of this specification.
[0029] Figure 3 Schematic diagram 1 of the state synchronization middleware implementation device for stateful services provided by the embodiments of this specification.
[0030] Figure 4 Schematic diagram 2 of the state synchronization middleware implementation device for stateful services provided by the embodiments of this specification.
[0031] Figure 5 Schematic diagram of the structure of an electronic device provided by an embodiment of this specification. Detailed implementation manners
[0032] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of this specification, rather than all the embodiments. Based on the embodiments in this specification, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.
[0033] Key terms
[0034] Stateful services and stateless services: Services are generally divided into stateful services and stateless services. The difference between them is whether context needs to be associated when the service runs on the server side after a request is initiated. For stateful services, the server side needs to save the information of the request, and other requests can also use the saved information. For stateless services, all the data required in the server-side processing logic comes from the information carried in this request. Although the server side also saves some information, this information is either irrelevant to the request or can be shared by all requests. Stateful services can implement transactions. Simply put, a transaction is a set composed of multiple things. The set is considered completed only when everything in the set is completed correctly. If one of the things in the set is not completed, even if other things are completed, the relevant data of the completed things has to be restored to the original state, that is, rollback. Generally, in scenarios where horizontal expansion is not considered and transactions are required, stateful services are used; for horizontal expansion, stateless services are generally used. To implement transactions in stateless services, means such as session and hidden forms can be used to complete the implementation of transactions.
[0035] Raft Protocol: A widely used distributed protocol with strong consistency, decentralization, and high availability. Essentially, it is a consensus algorithm, which means that multiple nodes reach a consensus on something, even in the case of partial node failures, network delays, and network partitions. The Raft protocol is a Leader-based consensus algorithm, so its core actually consists of these three sub-problems: Leader election, Log replication, and Safety. These three parts together implement the core consensus and fault tolerance mechanisms of Raft. For the election process, which node becomes the Leader is voted on by everyone. Each Leader node works for a period of time, and then a new Leader node is elected to continue to be responsible. This is very similar to the elections in a democratic society. Each new term of office is called a term. Therefore, the Raft protocol strongly relies on the Leader node to ensure the consistency of cluster data, that is, the data sent by the client first reaches the Leader node.
[0036] The following details an implementation solution of a state synchronization middleware for stateful services involved in this specification through a specific example.
[0037] Example 1
[0038] The focus of the present invention is how to use the advantages of the Raft protocol in solving the consistency of distributed systems to solve the state synchronization problem of stateful services. In terms of distributed systems, for stateful services, it is the session synchronization problem among multiple servers. However, there are a series of problems, such as a large amount of data synchronization wasting bandwidth, the existence of the same session replicas in multiple servers wasting a large amount of memory, data loss may occur when a stateful service crashes, and for highly available services, there will be a cold start problem when there is a rapid expansion of stateful services. It is necessary to load data first to provide services externally. In the existing solutions, a dedicated session server is used to store sessions, and when the client logs in, it will go to the session server to obtain information. However, in this way, for application servers, all accesses become stateless. Therefore, in addition to the above existing solutions to solve the state synchronization problem of stateful services, it is also necessary to further consider whether the consistency protocol used in the distributed system environment also has a similar working mechanism and can be improved to achieve the state synchronization function of stateful services.
[0039] Therefore, the technical idea of the state synchronization middleware solution for stateful services in the embodiments of the present invention is to deploy the state synchronization middleware in a distributed cluster based on the Raft protocol. By abstracting and inverting the control of the key behaviors in the Raft consensus protocol, the state synchronization middleware reversely calls and elects the operations of actively sending heartbeats and voting by nodes in the standard Raft protocol, so as to achieve the expansion and synchronization of the original system with little or no modification. This middleware can implement a distributed cluster under the standard Raft protocol, thus ensuring the high availability of the middleware itself. By registering a group in the middleware and defining the state structure information to be synchronized and the operation behaviors that can be performed on this state, service nodes running stateful services register in the group of the middleware, and establish a corresponding relationship between the existing APIs of the service nodes and the state operation APIs in this group. Therefore, the service nodes registered in this middleware can form a distributed network that meets the Raft protocol, and elect a Leader node through an improved Raft election method, and then realize the state synchronization of the service nodes in the group. For this purpose, as Figure 1 The following shows an implementation method of a state synchronization middleware for stateful services in the embodiments of the present invention. The state synchronization middleware is deployed in a distributed cluster based on the Raft protocol, and the state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes. The method includes:
[0040] S1: Create a state synchronization group, receive the identity information of the service node, and register it to the synchronization state group; wherein, the state synchronization group includes a state operation interface definition and / or a heartbeat interface definition, and the service node provides an interface implementation method corresponding to the corresponding operation interface definition of the state synchronization group. Further, the service node includes a stateful backend service, an application, and / or a system; the client includes a user, an application, and / or a system that obtains services from the service node. Further, the service nodes in the state synchronization group establish network connections according to state synchronization requirements. Further, the state operation interface definition includes at least interface definitions corresponding to operations of adding, deleting, modifying, and / or querying the state.
[0041] It should be noted here that the reason for establishing the heartbeat interface definition is that the election process of the Raft protocol itself is based on a heartbeat mechanism. When each node in the cluster is just started, it has the equal identity of a Follower node. The Leader will periodically send heartbeat packets to all nodes to maintain its authority. In the election process of the first Leader, if a Follower node does not receive any heartbeat packets within a certain period of time, that is, the election timeout occurs, then it will subjectively consider that there is no available Leader in the system and initiate a new election. However, in the solution of the present invention, the heartbeat mechanism is actively initiated by the middleware.
[0042] S2: In the current Raft term, send a heartbeat interface request to the service nodes in the state synchronization group, and among the service nodes that return the request successfully, elect a Leader node based on the time sequence of the requests returned by each service node.
[0043] Furthermore, when electing a Leader node based on the time sequence of the requests returned by each service node, the service node that returns the request first can be elected as the Leader node; since being able to return the request first usually indicates that the network latency between this service node and the client is relatively low, or the system performance of this service node is better than other service nodes, therefore, electing the service node that can return the request first can overall reduce the network latency or improve the system execution efficiency.
[0044] It can be understood that in addition to the above election method, other methods such as randomly selecting from the first N nodes that return the requests (N is a positive integer that can be customized) can also be selected. Those skilled in the art can design according to specific business requirements, and this specification does not need to list or limit all of them.
[0045] Furthermore, the sending of the heartbeat interface request to the service nodes in the state synchronization group includes sending a heartbeat interface request to the service nodes in the state synchronization group according to a preset heartbeat monitoring request period.
[0046] S3: When receiving the operation request of the client, forward the operation request to the Leader node, so that the Leader node performs the state operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes in the state synchronization group.
[0047] As Figure 2 shown, another implementation manner of the method for implementing a state synchronization middleware for stateful services according to an embodiment of the present invention further includes:
[0048] S4: When the heartbeat interface monitoring feedback of the Leader node cannot be received, a new Raft term is generated and a Leader node is elected.
[0049] Under the premise of minimizing changes to the existing services or systems, the solution of the present invention realizes the establishment of a mapping relationship by defining a state synchronization interface and an existing state operation interface in the existing service system, and can realize the state synchronization function of stateful services or systems, thereby expanding the capabilities such as horizontal expansion of distributed microservices.
[0050] Embodiment 2
[0051] Figure 3 FIG. is a schematic structural diagram of a state synchronization middleware implementation device 300 for stateful services provided by an embodiment of this specification. Please refer to Figure 3 , in a state synchronization middleware implementation device 300 for stateful services in an implementation manner, a state synchronization middleware is deployed in a distributed cluster based on the Raft protocol, and the state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes, including:
[0052] The first module 301 is capable of creating a state synchronization group, receiving the identity information of the service node, and registering it to the synchronization state group; wherein, the state synchronization group includes a state operation interface definition and / or a heartbeat interface definition, and the service node provides an interface implementation method corresponding to the corresponding operation interface definition of the state synchronization group;
[0053] The second module 302 is capable of, in the current Raft term, sending a heartbeat interface request to the service nodes in the state synchronization group, and, among the service nodes that return a successful request, electing a Leader node based on the time sequence of the requests returned by each service node;
[0054] The third module 303 is capable of, when receiving the operation request of the client, forwarding the operation request to the Leader node, so that the Leader node executes the state operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes in the state synchronization group.
[0055] As Figure 4 shown, in another implementation manner of the state synchronization middleware implementation device 300 for stateful services according to the embodiment of the present invention, it further includes:
[0056] The fourth module 304 is capable of, when the heartbeat interface monitoring feedback of the Leader node cannot be received, generating a new Raft term and electing a Leader node.
[0057] It should be understood that the state synchronization middleware implementation device 300 for stateful services in the embodiments of this specification can also execute Figures 1 to 2 the method executed by the state synchronization middleware implementation device (or equipment) for stateful services in Figures 1 to 2 and implement the functions of the state synchronization middleware implementation device (or equipment) in the
[0058] Embodiment III
[0059] Figure 5 is a schematic structural diagram of an electronic device according to an embodiment of this specification. Please refer to Figure 5 , at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Among them, the memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory, etc. Of course, the electronic device may also include other hardware required for other services.
[0060] The processor, network interface, and memory can be interconnected through an internal bus, and the internal bus can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 5 only a bidirectional arrow is used in
[0061] but it does not mean that there is only one bus or one type of bus.
[0062] The memory is used to store programs. Specifically, the program may include program code, and the program code includes computer operation instructions. The memory can include a memory and a non-volatile memory, and provide instructions and data to the processor.
[0063] Deploy a state synchronization middleware in a distributed cluster based on the Raft protocol, and the state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes, including:
[0064] Create a status synchronization group, receive the identity information of the service nodes, and register them to the synchronization status group; wherein, the status synchronization group includes a status operation interface definition and / or a heartbeat interface definition, and the service nodes provide interface implementation methods corresponding to the corresponding operation interface definitions of the status synchronization group;
[0065] In the current Raft term, send a heartbeat interface request to the service nodes in the status synchronization group, and among the service nodes that return a successful request, elect a Leader node based on the time sequence of the requests returned by each service node;
[0066] When receiving an operation request from the client, forward the operation request to the Leader node, so that the Leader node performs a status operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes in the status synchronization group.
[0067] The above as described in this specification Figures 1 to 2The method for implementing a state synchronization middleware for stateful services disclosed in the illustrated embodiments can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, the steps of the above method can be completed by the integrated logic circuit in the hardware of the processor or instructions in software form. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this specification. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of this specification can be directly embodied as being executed and completed by a hardware decoding processor, or executed and completed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. This storage medium is located in the memory, and the processor reads the information in the memory and combines its hardware to complete the steps of the above method.
[0068] Of course, in addition to the software implementation, the electronic devices in the embodiments of this specification do not exclude other implementation methods, such as logical devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logical unit, and can also be hardware or logical devices.
[0069] Embodiment 4
[0070] The embodiments of this specification also propose a computer-readable storage medium that stores one or more programs. The one or more programs include instructions that, when executed by a portable electronic device including multiple application programs, can enable the portable electronic device to execute Figures 1 to 2 the method for implementing a state synchronization middleware for stateful services shown in the illustrated embodiments, and specifically used to execute the following method:
[0071] Deploy a state synchronization middleware in a distributed cluster based on the Raft protocol. The state synchronization middleware is used to receive client requests and implement state synchronization among stateful service nodes, including:
[0072] Create a state synchronization group, receive the identity information of the service nodes, and register it in the state synchronization group; wherein, the state synchronization group includes a state operation interface definition and / or a heartbeat interface definition, and the service nodes provide interface implementation methods corresponding to the corresponding operation interface definitions of the state synchronization group;
[0073] In the current Raft term, send a heartbeat interface request to the service nodes in the state synchronization group, and among the service nodes that return a successful request, elect a Leader node based on the time sequence of the requests returned by each service node;
[0074] When receiving the operation request of the client, forward the operation request to the Leader node, so that the Leader node executes the state operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes in the state synchronization group.
[0075] In summary, the above are only the preferred embodiments of this specification and are not intended to limit the protection scope of this specification. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of this specification shall be included in the protection scope of this specification.
[0076] The systems, devices, modules, or units described in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or any combination of these devices.
[0077] A computer-readable medium includes both permanent and non-permanent, removable and non-removable media that can implement information storage by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transitory medium that can be used to store information accessible by a computing device. As defined herein, a computer-readable medium does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0078] It should also be noted that the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0079] Each embodiment in this specification is described in a progressive manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for the relevant content.
Claims
1. A method for implementing a state synchronization middleware for stateful services, characterized in that, deploy a state synchronization middleware in a distributed cluster based on the Raft protocol, the state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes, including: create a state synchronization group and receive the identity information of the service nodes and register them to the state synchronization group; wherein, the state synchronization group includes a state operation interface definition and / or a heartbeat interface definition, and the service nodes provide interface implementation methods corresponding to the corresponding operation interface definitions of the state synchronization group; in the current Raft term, send a heartbeat interface request to the service nodes in the state synchronization group, and among the service nodes that return a successful request, elect a Leader node based on the time sequence of the requests returned by each service node; when receiving the operation request of the client, forward the operation request to the Leader node, so that the Leader node executes the state operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes in the state synchronization group.
2. The method for implementing a state synchronization middleware for stateful services according to claim 1, characterized in that, the service nodes include stateful backend services, applications and / or systems; the clients include users, applications and / or systems that obtain services from the service nodes.
3. The method for implementing a state synchronization middleware for stateful services according to claim 2, characterized in that, the service nodes in the state synchronization group establish network connections according to state synchronization requirements.
4. The method for implementing a state synchronization middleware for stateful services according to claim 3, characterized in that, the state operation interface definition at least includes interface definitions corresponding to operations of adding, deleting, modifying and / or querying the state.
5. The method for implementing a state synchronization middleware for stateful services according to claim 4, characterized in that, sending the heartbeat interface request to the service nodes in the state synchronization group includes sending a heartbeat interface request to the service nodes in the state synchronization group according to a preset heartbeat monitoring request period.
6. The method for implementing a state synchronization middleware for stateful services according to claim 1, characterized in that, further includes: when the heartbeat interface monitoring feedback of the Leader node cannot be received, generate a new Raft term and elect a Leader node.
7. A device for implementing a state synchronization middleware for stateful services, characterized in that, deploy a state synchronization middleware in a distributed cluster based on the Raft protocol, the state synchronization middleware is used to receive client requests and implement state synchronization between stateful service nodes, including: The first module is capable of creating a status synchronization group, receiving the identity information of the service nodes, and registering it to the status synchronization group; wherein, the status synchronization group includes a status operation interface definition and / or a heartbeat interface definition, and the service nodes provide interface implementation methods corresponding to the corresponding operation interface definitions of the status synchronization group; The second module is capable of, during the current Raft term, sending a heartbeat interface request to the service nodes within the status synchronization group, and, among the service nodes that return a successful request, electing a Leader node based on the time sequence of the requests returned by each service node; The third module is capable of, when receiving an operation request from the client, forwarding the operation request to the Leader node, so that the Leader node performs a status operation corresponding to the operation request and synchronizes the operation log of the Leader node to other service nodes within the status synchronization group.
8. The apparatus for implementing a status synchronization middleware for a stateful service according to claim 7, wherein, it further includes: The fourth module is capable of generating a new Raft term and electing a Leader node when the heartbeat interface monitoring feedback of the Leader node cannot be received.
9. An electronic device, wherein, it includes: a processor; and a memory arranged to store computer-executable instructions, and the executable instructions, when executed, cause the processor to execute the method for implementing a status synchronization middleware for a stateful service according to any one of claims 1 to 6.
10. A computer-readable storage medium, wherein, the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including a plurality of application programs, the electronic device is caused to execute the method for implementing a status synchronization middleware for a stateful service according to any one of claims 1 to 6.
Citation Information
Patent Citations
Method for realizing global ordered replaying under micro-service architecture
CN107181805A
Data consistency method for distributed service discovery cluster in micro-service architecture
CN110661841A