Synchronization methods, apparatus, processing equipment and storage media
By marking memory variables and using APIs and reflection to synchronize variable values in microservice programs, the problem of globally unified synchronization of memory data in distributed microservice deployments is solved, achieving value synchronization and data consistency across service nodes, and improving the system's flexibility and efficiency.
Patent Information
- Application Number
- CN202410354603.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-26
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-03-26
AI Technical Summary
In the distributed deployment of microservices, existing technologies struggle to achieve global unified synchronization of in-memory data. Furthermore, the synchronization process relies on a central node, lacks scalability and automation capabilities, resulting in high coupling and an inability to meet the needs of various business scenarios.
By marking variables in memory that need to be modified, receiving client request information using the Application Programming Interface (API), and modifying the values of memory variables based on the entry parameters, the variable values are synchronized during the execution of the microservice program using reflection, achieving value synchronization across service nodes. Combined with a registry center and encryption processing, data consistency and timeliness are ensured.
It achieves global unified synchronization of variable values in the memory of different service nodes, reduces dependence on the central node, improves the scalability and automation of synchronization, reduces coupling, and meets the needs of various business scenarios.
Smart Images

Figure CN120711024B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to, but is not limited to, the fields of cloud computing and edge computing technology, and particularly to a synchronization method, apparatus, processing device, and storage medium. Background Technology
[0002] Microservices is an emerging technology trend that breaks down an application into multiple independent, deployable small services. Each service maintains lightweight communication. This service architecture improves the maintainability, testability, and deployability of the application, while also increasing development efficiency and flexibility. For distributed deployments of multiple microservices, it is necessary to achieve global data consistency and reduce in-memory data operations and interactions. Among related technologies, memory (or in-memory data) synchronization is a key consideration in distributed microservice deployments. Summary of the Invention
[0003] In view of this, the present invention discloses a synchronization method, apparatus, processing device and storage medium.
[0004] According to a first aspect of the present invention, a synchronization method is provided, the method being executed by a first service node, the method comprising: Mark the variables in memory that need to be modified, where the memory is the memory that needs to be used during the execution of the microservice program, and the first service node is the service node associated with the execution of the microservice program; The system receives a first request message sent by the client through a first application programming interface (API). The first request message is used to request modification of the value of a first variable in memory. The first request message includes an input parameter for modifying the value of the first variable. If the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter; In response to receiving the first request information, a second request information is sent to the second service node associated with the microservice program via the second API. The second request information is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request information includes the entry parameter.
[0005] In some embodiments, the variables in memory that need to be modified include: Use annotations from the native programming language to mark variables in memory that need to be modified.
[0006] In some embodiments, the input parameters include the key information of the first variable and / or the modified value.
[0007] In some embodiments, before receiving the first request information sent by the client via the first application programming interface (API), the method further includes: Expose the first information to the client; The first information includes information about the first API.
[0008] In some embodiments, the method further includes: Register the address information of the first service node to the registration center; The registry center stores the address information of the service nodes associated with the microservice program.
[0009] In some embodiments, the method further includes: Once the first request information is received, the address information of the service node associated with the microservice program is obtained from the registry center; The address information includes the address of the second service node.
[0010] In some embodiments, before sending the second request information to the second service node associated with the microservice program via the second API, the method further includes: The input parameters are encrypted.
[0011] In some embodiments, modifying the value of the first variable in memory based on the entry parameter includes: If the microservice program is an object-oriented program, the value of the first variable in the memory of the first service node is modified using reflection based on the entry parameter.
[0012] In some embodiments, the method further includes: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the first database of the first service node; The first database contains data for starting the microservice program.
[0013] According to a second aspect of the present invention, a synchronization method is provided, the method being performed by a second service node, the method comprising: Mark the variables in memory that need to be modified, where the memory is the memory that needs to be used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; The second API receives a second request message sent by a first service node associated with the microservice program. The second request message is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request message includes the entry parameter. If the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter.
[0014] In some embodiments, the variables in memory that need to be modified include: Use annotations from the native programming language to mark variables in memory that need to be modified.
[0015] In some embodiments, the input parameters include the key information of the first variable and / or the modified value.
[0016] In some embodiments, the method further includes: Register the address information of the second service node to the registration center; The registry center stores the address information of the service nodes associated with the microservice program.
[0017] In some embodiments, the method further includes: The encrypted entry parameters in the second request information are decrypted to obtain the decrypted entry parameters.
[0018] In some embodiments, modifying the value of the first variable in memory based on the entry parameter includes: If the microservice program is an object-oriented program, the value of the first variable in the memory of the second service node is modified using reflection based on the entry parameter.
[0019] In some embodiments, the method further includes: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the second database of the second service node; The second database contains data used to start the microservice program.
[0020] According to a third aspect of the present invention, a synchronization device is provided, the device comprising: The first marking module is configured to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; The first transceiver module is configured to receive a first request message sent by a client through a first application programming interface (API), wherein the first request message is used to request modification of the value of a first variable in memory, and the first request message includes an input parameter for modifying the value of the first variable. The first modification module is configured to: if the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter; The first transceiver module is further configured to: in response to receiving the first request information, send a second request information to a second service node associated with the microservice program via a second API, wherein the second request information is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node, and the second request information includes the entry parameter.
[0021] According to a fourth aspect of the present invention, a synchronization device is provided, the device comprising: The second marking module is configured to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; The second transceiver module is configured to receive, via a second API, a second request message sent by a first service node associated with the microservice program. The second request message is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request message includes the entry parameter. A second modification module is configured to: if the marked variable includes the first variable, modify the value of the first variable in memory based on the input parameter. According to a fifth aspect of the present invention, a processing apparatus is provided, the processing apparatus comprising: Memory, used to store executable programs; A processor, when executing an executable program stored in the memory, implements any of the methods described in this invention.
[0022] According to a sixth aspect of the present invention, a computer storage medium is provided, the computer storage medium storing an executable program, which, when executed by a processor, implements any of the methods described in the present invention.
[0023] In this invention, variables in memory that need to be modified are marked. The memory used during the execution of the microservice program is the memory itself, and the first service node is a service node associated with the execution of the microservice program. Thus, since the variables in memory that need modification are marked, they can be modified during the execution of the microservice program. A first request message sent by a client is received through a first application programming interface (API). This first request message requests modification of the value of a first variable in memory and includes an entry parameter for modifying the value of the first variable. Thus, the first request message sent by the client can be received through the first API, thereby triggering the first service node to modify the value of the first variable in memory. If the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter. Therefore, the value of the first variable in memory is modified based on the entry parameter only if the marked variable includes the first variable. In response to receiving the first request message, a second request message is sent through a second API to a second service node associated with the microservice program. This second request message requests modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node, and includes the entry parameter. In this way, after receiving the first request information, the first service node can promptly send a second request information to the second service node to request modification of the value of the first variable in memory, thereby achieving synchronous modification of the value of the first variable in memory in the second service node and realizing global uniformity of the value of the variable in memory of different service nodes. Attached Figure Description
[0024] Figure 1 This is a flowchart illustrating a synchronization method according to the first embodiment; Figure 2 This is a flowchart illustrating a synchronization method according to the second embodiment; Figure 3 This is a flowchart illustrating a synchronization method according to the third embodiment; Figure 4 This is a flowchart illustrating a synchronization method according to the fourth embodiment; Figure 5 This is a flowchart illustrating a synchronization method according to the fifth embodiment; Figure 6 This is a flowchart illustrating a synchronization method according to the sixth embodiment; Figure 7 This is a flowchart illustrating a synchronization method according to the seventh embodiment; Figure 8This is a flowchart illustrating a synchronization method according to the eighth embodiment; Figure 9 This is a flowchart illustrating a synchronization method according to the ninth embodiment; Figure 10 This is a flowchart illustrating a synchronization method according to the tenth embodiment; Figure 11 This is a flowchart illustrating a synchronization method according to the eleventh embodiment; Figure 12 This is a flowchart illustrating a synchronization method according to the twelfth embodiment; Figure 13 This is a flowchart illustrating a synchronization method according to the thirteenth embodiment; Figure 14 This is a flowchart illustrating a synchronization method according to the fourteenth embodiment; Figure 15 This is a schematic diagram of a synchronization device according to the fifteenth embodiment; Figure 16 This is a schematic diagram of a synchronization device according to the sixteenth embodiment. Detailed Implementation
[0025] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on the present invention. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0026] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0027] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of the invention described herein can be implemented in an order other than that illustrated or described herein.
[0028] In the following description, the terms "greater than" and "less than" are used. It should be noted that in this disclosure, "greater than" can be used to indicate "greater than" or "equal to"; and "less than" can be used to indicate "less than" or "equal to".
[0029] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.
[0030] To better understand this invention, the application scenarios of the technical solutions disclosed herein will first be described: In some application scenarios, please refer to Figure 1 This paper demonstrates a mesh interaction architecture based on Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) for decentralized communication, which can actively select scheduling nodes or pre-configure communication information between nodes (service nodes MEMNODE).
[0031] In some application scenarios, please refer to Figure 2 It adopts a centralized (CacheCenter) memory management and synchronization architecture, with upstream and downstream systems synchronizing data as needed.
[0032] In some embodiments, a method is provided to distribute parameters to downstream service systems via a central control. This type of method manages parameters through a registry management page, publishes notifications to service nodes, and then updates them in local memory, fulfilling the basic idea of broadcasting parameters from the central control to downstream systems. However, the data source for this type of method is manual input, and the push relies entirely on the registry and its additional parameter configuration capabilities. The triggering and distribution of parameters are all on the central side, lacking scalability, loose coupling, proactive synchronization, and full automation capabilities for development, thus limiting its use cases.
[0033] In some embodiments, by sharing storage through a database or data storage server, the system can achieve convenient data location, data acquisition and data sharing among heterogeneous cloud service applications, realizing distributed data storage and synchronization; however, the data destination in this method is a database or data storage server, which is mainly used for rapid deployment scenarios of cloud services, and is not for memory synchronization for development.
[0034] In some embodiments, in distributed Java Virtual Machine (JVM) memory synchronization scenarios, application systems should minimize coupling with middleware to avoid middleware becoming a constraint and bottleneck for the system. Related solutions generally lack low-level automated memory synchronization; they are mostly based on specific data synchronization for business scenarios and typically rely on the middleware's native functions for transmission and distribution, or direct data migration and storage. The data sources, usage scenarios, data storage methods, and implementation methods differ from the solution in this application. In microservice distributed JVM memory synchronization scenarios, it is necessary to accurately synchronize the memory changes of a single node to the required nodes, and to ensure data consistency, timeliness, and accuracy. However, in related technologies, synchronization requires passive or manual triggering; most synchronization solutions require coupling with specific middleware, or are designed specifically for a particular middleware; and most synchronization solutions heavily rely on a central node. The central node has full control over all node information, data distribution, and data storage capabilities. This results in heavy business capabilities and high coupling; it is designed to address specific business scenarios and does not consider general applicability.
[0035] like Figure 3 As shown, this invention provides a synchronization method, which is executed by a first service node, and the method includes: Step S301: Mark the variables in memory that need to be modified, where the memory is the memory that needs to be used during the operation of the microservice program, and the first service node is the service node associated with the operation of the microservice program; Step S302: Receive a first request message sent by the client through the first application programming interface (API). The first request message is used to request modification of the value of the first variable in memory. The first request message includes an input parameter for modifying the value of the first variable. Step S303: If the marked variable includes the first variable, modify the value of the first variable in memory based on the entry parameter; Step S304: In response to receiving the first request information, a second request information is sent to the second service node associated with the microservice program through the second API. The second request information is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request information includes the entry parameter.
[0036] In some embodiments, the function of a microservice program may be to implement microservices. The service nodes associated with the operation of the microservice program may be nodes directly or indirectly associated with the implementation of the microservice function, and this is not limited thereto.
[0037] In some embodiments, the memory is the memory space required during the execution of the microservice program, and the memory space may store at least two variables (e.g., global variables) or data required by the microservice.
[0038] In some embodiments, annotations in a native programming language can be used to mark variables that need to be modified in memory during the execution of the microservice application. These marked variables may be dynamically modified and / or globally synchronized during the microservice application's execution. For example, the native programming language could be Java.
[0039] In some embodiments, the name used to label a variable is globally unique.
[0040] In some embodiments, the first service node may (e.g., using a management module) manage memory by scanning native Java annotation information.
[0041] In some embodiments, when a microservice starts, the management module can scan all tagged variables. The management module can retrieve the previously stored values of the tagged variables from the persistence module and copy the tagged variables. The management module can maintain an in-memory dictionary recording the tagged variables.
[0042] In some embodiments, native Java annotations are used to mark variables in memory that need to be modified; the marked variables in memory are those used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; a first request message sent by a client is received through a first application programming interface (API), the first request message being used to request modification of the value of a first variable in memory, the first request message containing an entry parameter for modifying the value of the first variable; if the marked variables include the first variable, the value of the first variable in memory is modified based on the entry parameter; a second request message is sent to a second service node associated with the microservice program through a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message containing the entry parameter.
[0043] In some embodiments, the input parameters include the key information of the first variable and / or the modified value.
[0044] In some embodiments, when a microservice starts, the management module scans all variables that are marked with annotation information and need to be dynamically modified and synchronized.
[0045] For example, the name of the tagged variable is composed by default using the project group identifier ID (e.g., groupId), environment name, microservice name, object name, and / or variable name separated by a delimiter. The delimiter can be any common delimiter, such as "-" or "_". The purpose is to form a globally unique tag variable name key.
[0046] For example, if the default project group ID is "default", the development environment is "dev", the user microservice is "user", the user service object (fully qualified name of the object class) is "userService", and the variable is "age", then the globally unique identifier variable name key = default_dev_user_userService_age. Here, the project group ID, development environment, and microservice name are environment variables for the microservice runtime and can be directly obtained from the microservice application startup context; the object name and variable name are names defined in the daily business logic code. The globally unique identifier variable name key is generated by the memory synchronization component by default in the usage context, requiring no additional business code implementation.
[0047] In some embodiments, the value object, in addition to the variable's value, also includes a version field. The version field value is atomically auto-incrementing, incrementing by 1 whenever the field value is updated. If the ability to manage keys by group is provided, a field indicating the group to which the key belongs can be added.
[0048] In some embodiments, after scanning and obtaining all tagged variable names, the processing module is called to initialize and assign values to these variables. If the persistence module can find a value corresponding to the tagged variable name key, the value is assigned to the corresponding variable; otherwise, if the persistence module cannot find a value corresponding to the key, the value defined in the business application (or microservice) code is used.
[0049] In some embodiments, the service address of the service node that has loaded the memory synchronization component is found from the registry center, and the value object of all memory key values is requested from these addresses through the synchronization API. If the local variable version is less than the variable version value in the synchronization request response, it is automatically updated; otherwise, no action is taken.
[0050] In some embodiments, after the variable is assigned a value, a data dictionary mapping the key to its corresponding object is maintained in memory using Java's native HashMap object, which facilitates quick location of the variable when dynamically updating the variable at runtime.
[0051] For example, please see Figure 4This illustrates a synchronization method, including: Step S401: Start the microservice (program); Step S402: Scan all marked variables; Step S403: Use the name of the marked variable to call the processing module to obtain the corresponding value from the persistence layer (persistence processing module); Step S404: Determine whether there is a marked variable and its corresponding value; if there is, proceed to step S405; if not, proceed to step S406. Step S405: Update the value of the marked variable; proceed to step S407. Step S406: Use the default values of variables in the business program; Step S407: Record the memory dictionary corresponding to the marked variable; Step S408, End.
[0052] In some embodiments, see Figure 5 Before receiving the first request information sent by the client through the first application programming interface (API), the method further includes: step S501, exposing first information to the client; wherein the first information is used to instruct the first API.
[0053] In some embodiments, the microservice application exposes an external standard Java API interface to dynamically modify the flag variable at runtime. The client passes in the flag variable name and the value to be modified, and the management module updates and synchronizes the value of the specified memory variable.
[0054] In some embodiments, since some elements of the globally unique identifier variable name key can be directly obtained from the microservice's environment variables, the exposed API interface only needs to pass in the object name, variable name, and the value to be modified.
[0055] In some embodiments, variables in memory that need to be modified are marked, wherein the memory is memory used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; first information is exposed to the client; wherein the first information includes information of the first API; a first request message sent by the client is received through the first API, the first request message being used to request modification of the value of the first variable in memory, the first request message including an entry parameter for modifying the value of the first variable; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter; a second request message is sent to a second service node associated with the microservice program through a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter.
[0056] In some embodiments, the first API may be an API for a modifiable, tagged variable. After exposing first information indicating the first API to the client, the first request information sent by the client can be received through the first API.
[0057] In some embodiments, variables in memory that need to be modified are marked, where the memory is memory used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; the address information of the first service node is registered with a registry center; wherein, the registry center stores the address information of service nodes associated with the microservice program; a first request message sent by a client is received through a first API, the first request message being used to request modification of the value of a first variable in memory, the first request message including an entry parameter for modifying the value of the first variable; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter; it is determined that the first request message has been received, and the address information of the service node associated with the microservice program is obtained from the registry center; wherein, the address information includes the address of the second service node; based on the address information, a second request message is sent to the second service node associated with the microservice program through a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter.
[0058] In some embodiments, when a service node registers a service with the registry center, it sends a third request message to the registry center, which carries a sync-memory flag.
[0059] In some embodiments, a service node may send a fourth request message to the registry center. The fourth request message contains address information (e.g., an address list) of service instances used for synchronizing memory. The address information is used for synchronizing and updating parameters or data in memory.
[0060] In some embodiments, the registry center may update the list of service addresses contained in memory based on the health status of the microservices.
[0061] In some embodiments, the registry center can determine whether to filter the list of sync addresses based on whether group management results are provided. For example, if group management is provided, a tag like `groupUser` can be added to filter the list of sync addresses, eliminating the need for a full update.
[0062] In some embodiments, see Figure 6 The method further includes: step S601, encrypting the input parameters.
[0063] In some embodiments, variables in memory that need to be modified are marked, wherein the memory is memory used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; a first request message sent by a client is received through a first API, the first request message being used to request modification of the value of a first variable in memory, the first request message including an entry parameter for modifying the value of the first variable; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter; the entry parameter is encrypted; a second request message is sent through a second API to a second service node associated with the microservice program, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter.
[0064] In some embodiments, after receiving the first request information, the management module generates a globally unique tag variable name key according to rules (which may be initialization tag variable rules), and checks whether the key exists in the data dictionary that maps the key to its associated object. If it does not exist, the process ends directly. If it exists, the key and the value to be updated are encrypted according to the configured encryption rules.
[0065] In some embodiments, since memory synchronization between nodes prioritizes timeliness, complex encryption and decryption algorithms can incur performance overhead. Therefore, simple symmetric encryption algorithms are chosen, primarily to prevent unauthorized external access.
[0066] In some embodiments, after the input parameters (or data) are encrypted, the management module obtains the location information of all nodes deployed for this microservice through the registry center. The node location information includes the Internet Protocol address (IP) and / or port that uniquely identifies each node. Based on the node location information, the management module sends the encrypted data to be modified to each microservice node.
[0067] In some embodiments, the management module also exposes a Hypertext Transfer Protocol (HTTP) API interface (corresponding to the second API) for internal synchronization notifications. This interface defines a method for specifying node IP addresses and ports for invocation, facilitating accurate notification to designated nodes.
[0068] In some embodiments, after the notification is sent, the globally unique identifier variable name key and its corresponding value are updated in the persistence module, depending on whether persistence is configured in the configuration file.
[0069] For example, please see Figure 7 A synchronization method is provided, the method comprising: Step S701: Receive the first request information sent by the client for modifying parameters in memory; Step S702: Obtain the name of the marked variable; Step S703: Determine if the marked variable exists; if it exists, proceed to step S704; if it does not exist, proceed to step S707. Step S704: Encrypt the content associated with synchronization; Step S705: Obtain the address information of all service nodes that need to be synchronized from the registration center; Step S706: Send the encrypted content that needs to be synchronized to each service node respectively; Step S707, End.
[0070] In some embodiments, variables in memory that need to be modified are marked, where the memory is memory used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; a first request message sent by a client is received through a first application programming interface (API), the first request message being used to request modification of the value of a first variable in memory, the first request message including an entry parameter for modifying the value of the first variable; if the marked variable includes the first variable, and if the microservice program is an object-oriented program, the value of the first variable in the memory of the first service node is modified using reflection based on the entry parameter; a second request message is sent to a second service node associated with the microservice program through a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter.
[0071] In some embodiments, the first node can be established by obtaining the unique name and modified value of the tagged variable, finding the corresponding object and variable in the memory dictionary by the unique name, and updating the variable value through reflection. Reflection only updates the variable in a specified memory location, resulting in a small scope and not refreshing all data in memory.
[0072] In some embodiments, see Figure 8 The method further includes: step S801, in response to the successful modification of the first variable in memory, storing the modified value of the first variable in a second database in the second service node; wherein the second database contains data for starting the microservice program.
[0073] In some embodiments, variables in memory that need to be modified are marked, where the memory is memory used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program; a first request message sent by a client is received through a first application programming interface (API), the first request message being used to request modification of the value of a first variable in memory, the first request message including an entry parameter for modifying the value of the first variable; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter; a second request message is sent to a second service node associated with the microservice program through a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter; in response to successful modification of the first variable in memory, the modified value of the first variable is stored in a second database in the second service node; wherein, the data in the second database is used for the startup process of the microservice program.
[0074] In some embodiments, all operations for persisting information about variables in memory are performed through a persistence module. Whether to persist and what type of persistence to use can be specified through a configuration file. The persistence type can be any persistence component (or module) that supports key-value pairs; it is not strictly dependent on the type of persistence component. It can be any relational database such as a pure relational database (MySQL) or an object-relational database (PostgreSQL); it can also be an in-memory database such as a remote dictionary service (Redis); or it can be a plain text file, etc. The persisted content is stored in a key-value format, where the key is a globally unique name that identifies the in-memory variable, and the value is the value of the variable.
[0075] For example, the value of the age variable in the above text is now 20. Please refer to Table 1, which stores the data using a relational database table: Table 1: key value default_dev_user_userService_age 20 Stored using a Redis database: default_dev_user_userService_age=20 For example, please see Figure 9 A synchronization method is provided, the synchronization method comprising: Step S901: Persist the marked variables; Step S902: Read the configuration information related to persistence processing; Step S903: Determine whether persistence processing is required. If yes, proceed to step S904; otherwise, proceed to step S906. Step S904: Select the type of persistence processing to perform; Step S905: Store the persistent data processing data to the hard disk; Step S906, End.
[0076] In some embodiments, configuration files can be pre-configured. Standard Java configuration files can be used to configure strategies such as persistence, persistence address, and / or encryption method. By deploying microservices in a stateless manner, the configuration memory across each microservice node can be the same, ensuring consistency of critical strategies such as persistence and encryption / decryption across all nodes.
[0077] In this invention, variables in memory that need to be modified are marked. The memory used during the execution of the microservice program is the memory itself, and the first service node is a service node associated with the execution of the microservice program. Thus, since the variables in memory that need modification are marked, they can be modified during the execution of the microservice program. A first request message sent by a client is received through a first application programming interface (API). This first request message requests modification of the value of a first variable in memory and includes an entry parameter for modifying the value of the first variable. Thus, the first request message sent by the client can be received through the first API, thereby triggering the first service node to modify the value of the first variable in memory. If the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter. Therefore, the value of the first variable in memory is modified based on the entry parameter only if the marked variable includes the first variable. A second request message is sent to a second service node associated with the microservice program through a second API. This second request message requests modification of the value of the first variable in memory and includes the entry parameter. In this way, after the first service node modifies the value of the first variable in memory, it can promptly send a second request message to the second service node to request modification of the value of the first variable in memory, thereby achieving synchronous modification of the value of the first variable in memory in the second service node and realizing global uniformity of the value of the variable in different service nodes.
[0078] like Figure 10 As shown, this invention provides a synchronization method, which is executed by a second service node, and the method includes: Step S1001: Mark the variables in memory that need to be modified, where the memory is the memory that needs to be used during the operation of the microservice program, and the second service node is the service node associated with the operation of the microservice program; Step S1002: Receive second request information sent by the first service node associated with the microservice program through the second API. The second request information is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request information includes the entry parameter. Step S1003: If the marked variable includes the first variable, modify the value of the first variable in memory based on the entry parameter.
[0079] It should be noted that, since the second service node is the peer node of the first service node and is a similar node, the methods for each step in this synchronization method can be referred to... Figure 3 Some of the implementation examples are executed accordingly.
[0080] In some embodiments, annotation information from a native programming language is used to mark variables in memory that need to be modified. This memory is the memory used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program. A second request message is received via a second API from the first service node associated with the microservice program. This second request message requests modification of the value of the first variable in memory and includes the input parameter. If the marked variable includes the first variable, the value of the first variable in memory is modified based on the input parameter. The native programming language can be native Java.
[0081] In some embodiments, the input parameters include the key information of the first variable and / or the modified value.
[0082] In some embodiments, after receiving a change notification (second request information) from another node, the management module of the second service node decrypts it according to a pre-defined method. If decryption fails, the process ends directly. If decryption is successful, it obtains the globally unique identifier variable name (key) and the value to be modified. It then searches for the key in a data dictionary containing the mapping relationship between the key and its associated object. If the key does not exist, the process ends directly. If the key exists, it calls the processing module to update the value of the marked variable.
[0083] For example, please see Figure 11 A synchronization method is provided, including: Step S1101: Receive memory synchronization notification (e.g., second request information) sent by other nodes (e.g., the first service node). Step S1102: Decrypt the marked variable name and modified value according to the agreed algorithm; Step S1103: Determine whether the decryption was successful. If successful, proceed to step S1104; if unsuccessful, proceed to step S1107. Step S1104: Determine whether the marked variable exists. If it exists, proceed to step S1105; if it does not exist, proceed to step S1107. Step S1105: Call the processing module to update the value of the marked variable; Step S1106: Notify the caller that the variable has been successfully modified; Step S1107, End.
[0084] In some embodiments, variables in memory that need to be modified are marked, where the memory is the memory used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; the address information of the second service node is registered with a registry center; wherein, the registry center stores the address information of service nodes associated with the microservice program; a second request message is received from the first service node associated with the microservice program via a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter.
[0085] In some embodiments, a variable in memory that needs to be modified is marked, wherein the memory is the memory required during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; a second request message is received from the first service node associated with the microservice program via a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message containing the entry parameter; the encrypted entry parameter in the second request message is decrypted to obtain the decrypted entry parameter; if the marked variable contains the first variable, the value of the first variable in memory is modified based on the entry parameter.
[0086] In some embodiments, a variable in memory that needs to be modified is marked, wherein the memory is the memory required during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; a second request message is received from the first service node associated with the microservice program via a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter; if the marked variable includes the first variable, and if the microservice program is an object-oriented program, the value of the first variable in the memory of the second service node is modified using reflection based on the entry parameter.
[0087] In some embodiments, variables in memory that need to be modified are marked, where the memory is memory used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program; a second request message is received from the first service node associated with the microservice program via a second API, the second request message being used to request modification of the value of the first variable in memory, the second request message including the entry parameter; if the marked variable includes the first variable, the value of the first variable in memory is modified based on the entry parameter; in response to successful modification of the first variable in memory, the modified value of the first variable is stored in a second database in the second service node; wherein, the second database contains data for starting the microservice program.
[0088] To better understand the present invention, the following two exemplary embodiments further illustrate the technical solutions disclosed herein: Example 1: Please see Figure 12 A microservice system includes a tagging module, a management module, and a processing module; In some embodiments, during the coding phase, business users provide Java annotations to mark variable names that need to be modified at runtime using the scheme disclosed herein.
[0089] In some embodiments, during the business application startup phase, the packaged components are automatically loaded, and the management module exposes the standard HTTP API interface for receiving internal notifications and modifying variables provided by this scheme.
[0090] In some embodiments, during the business program startup phase, in a multi-node business program model, each node of the same business program registers its own address information with the registration center. The registration center stores the address information of each node. For example: appA:[192.168.1.1:8080, 192,168.1.2:8080, 192,168.1.3:8080].
[0091] In some embodiments, during the business program execution phase, the variable values of the marked variables are modified.
[0092] In some embodiments, during the business program execution phase, the standard interface exposed by the management module to modify variable values is called, with input parameters including the key of the variable to be modified and the modified value.
[0093] In some embodiments, during the business program execution phase, after receiving a modification request, the management module calls the interface provided by the registry center to obtain the service address list of multiple nodes under the same business program. For example, calling the registry center's interface to obtain the address information list of application A's registration will return the address list information of 192.168.1.1:8080, 192,168.1.2:8080, and 192,168.1.3:8080.
[0094] In some embodiments, during the business program execution phase, after the data to be modified is processed (such as encrypted), the internal variable modification standard HTTP API interface exposed by the management module in the aforementioned business application node is called respectively. For example, in the above scenario, the internal variable modification interface of 192.168.1.3:8080, the internal variable modification interface of 192.168.1.2:8080, and so on would be called respectively.
[0095] In some embodiments, during the business program execution phase, after receiving an internal request to modify variables, the management modules of each node call their respective processing modules according to the rules to modify the variables to the required values.
[0096] In some embodiments, during the business application runtime phase, the processing module uses Java reflection when modifying the value of a corresponding variable. For object-oriented programs, variables are generally attributes of an object; therefore, reflection allows for precise modification of a specific attribute without refreshing or rebuilding the entire object, minimizing the need to update variable values quickly.
[0097] In some embodiments, during the post-update persistence phase, after updating memory, the latest variable values can be persisted to the database as needed. This allows the updated variable values to be retrieved directly from the database the next time the program starts.
[0098] Example 2: Please see Figure 13 This illustrates the interaction architecture.
[0099] Combination Figure 13 Please see Figure 14 A synchronization method is provided, the method comprising: Step S1401: Define a variable and assign it the initial set of blacklisted user IDs, and mark this variable as dynamically controllable. @DyncValue String blackList = "1001,1002,1003"; When using this feature, determine whether the current user is on the blacklist: if (isContain(blackList, currentUserId)) / / Logic for users on the blacklist else / / Normal user logic After the program starts and runs normally, I want to add userId=1004 to the blacklist as well.
[0100] Step S1402: Call the provided API interface and set the variables of blackList to "1001,1002,1003,1004".
[0101] Step S1403: Call the registry center's capabilities to obtain the address information of other nodes that need to be synchronized.
[0102] Step S1404: After a series of processes (e.g., encryption), the memory synchronization component notifies other nodes to update the marked memory.
[0103] Step S1405: After receiving the update notification, each node updates the value of the marker memory variable.
[0104] In this way, the data in memory of a distributed application can be dynamically modified without restarting the microservice.
[0105] This invention supports both proactive and manual information synchronization triggering. It's not simply about broadcasting parameters, but rather a more fundamental JVM memory synchronization mechanism. Its essence is to address system performance bottlenecks, not just parameter synchronization. The weakly centralized approach makes middleware dependencies more flexible. It's not limited to a single middleware (such as NACOS or Consul), nor does it heavily rely on the data delivery extension capabilities specifically provided by certain middleware. It reduces dependence on specific functions of centralized middleware, relying only on the registry's most basic addressing capabilities. Core business functions such as data communication, data updates, and data persistence are decentralized to business nodes, achieving the goal of weakening centralization. It has a certain storage mechanism, which can flexibly support the horizontal scaling of microservices and supports multiple storage methods. Its application scenarios are broader; its essence is memory synchronization, not involving specific business logic, but merely serving as a basic capability, widely supporting microservices and cloud-native systems.
[0106] like Figure 15 As shown, the present invention provides a synchronization device, the device comprising: The first marking module 151 is configured to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program. The first transceiver module 152 is configured to receive a first request message sent by a client through a first application programming interface (API), wherein the first request message is used to request modification of the value of a first variable in memory, and the first request message includes an input parameter for modifying the value of the first variable. The first modification module 153 is configured to: if the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter; The first transceiver module 152 is further configured to: in response to receiving the first request information, send a second request information to a second service node associated with the microservice program via a second API, wherein the second request information is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node, and the second request information includes the entry parameter.
[0107] In some embodiments, the first marking module 151 is further configured to: Use annotations from the native programming language to mark variables in memory that need to be modified.
[0108] In some embodiments, the first transceiver module 152 is further configured such that the input parameters include the key information of the first variable and / or the modified value.
[0109] In some embodiments, the first transceiver module 152 is further configured to: Expose the first information to the client; The first information includes information about the first API.
[0110] In some embodiments, the first transceiver module 152 is further configured to: Register the address information of the first service node to the registration center; The registry center stores the address information of the service nodes associated with the microservice program.
[0111] In some embodiments, the first transceiver module 152 is further configured to: Once the first request information is received, the address information of the service node associated with the microservice program is obtained from the registry center; The address information includes the address of the second service node.
[0112] In some embodiments, the first transceiver module 152 is further configured to: The input parameters are encrypted.
[0113] In some embodiments, the first modification module 153 is further configured to: If the microservice program is an object-oriented program, the value of the first variable in the memory of the first service node is modified using reflection based on the entry parameter.
[0114] In some embodiments, the first modification module 153 is further configured to: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the first database of the first service node; The first database contains data for starting the microservice program.
[0115] like Figure 16 As shown, the present invention provides a synchronization device, the device comprising: The second marking module 161 is configured to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program. The second transceiver module 162 is configured to receive, via a second API, a second request message sent by a first service node associated with the microservice program. The second request message is used to request modification of the value of the first variable in memory to synchronously modify the value of the first variable in the second service node. The second request message includes the entry parameter. The second modification module 163 is configured to: if the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter.
[0116] In some embodiments, the second marking module 161 is further configured to: Use native programming language annotations to mark variables in memory that need to be modified.
[0117] In some embodiments, the second transceiver module 162 is further configured such that the input parameters include the key information of the first variable and / or the modified value.
[0118] In some embodiments, the second transceiver module 162 is further configured to: register the address information of the second service node to the registration center; The registry center stores the address information of the service nodes associated with the microservice program.
[0119] In some embodiments, the second transceiver module 162 is further configured to: decrypt the encrypted entry parameters in the second request information to obtain the decrypted entry parameters.
[0120] In some embodiments, the second modification module 163 is further configured to: if the microservice program is an object-oriented program, modify the value of the first variable in the memory of the second service node based on the entry parameter using reflection.
[0121] In some embodiments, the second modification module 163 is further configured to: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the second database of the second service node; The second database contains data used to start the microservice program.
[0122] This invention provides a processing device, the processing device comprising: Memory, used to store executable programs; A processor, when executing an executable program stored in the memory, implements any of the methods described in this invention.
[0123] It is understood that memory can be volatile or non-volatile, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.
[0124] The synchronization method disclosed in this invention can be applied to or implemented by the processor. The processor can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the synchronization method can be completed through integrated logic circuits in the processor's hardware or through software instructions. The processor can be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor can implement or execute the methods, steps, and logic diagrams disclosed in this invention. A general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in a storage medium, specifically a memory. The processor reads information from the memory and, in conjunction with its hardware, completes the steps of the synchronization method provided in this application.
[0125] This invention also provides a computer storage medium storing an executable program that, when executed by a processor, implements the synchronization method as described in any of the embodiments of this invention. Specifically, it may be a computer-readable storage medium, such as a memory including a computer program that can be executed by a processor of a processing device to complete the steps described in the embodiments of this application. The computer-readable storage medium may be a ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.
[0126] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A synchronization method, characterized in that, The method is executed by the first service node, and the method includes: Use annotations from the native programming language to mark variables in memory that need to be modified; The memory is the memory required during the execution of the microservice program, and the first service node is the service node associated with the execution of the microservice program. The address information of the first service node is registered to the registration center, wherein the registration center stores the address information of the service nodes associated with the microservice program; The system receives a first request message sent by the client through a first application programming interface (API). The first request message is used to request modification of the value of a first variable in memory. The first request message includes an input parameter for modifying the value of the first variable. If the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter; Upon confirming receipt of the first request information, the address information of the service node associated with the microservice program is obtained from the registration center, wherein the address information includes the address of the second service node; In response to receiving the first request information, based on the address information, a second request information is sent to the second service node associated with the microservice program via a second API. The second request information is used to request modification of the value of the first variable in the memory of the second service node to synchronously modify the value of the first variable in the second service node. The second request information includes the entry parameters.
2. The method according to claim 1, characterized in that, The input parameters include the key information of the first variable and / or the modified value.
3. The method according to claim 1, characterized in that, Before receiving the first request information sent by the client via the first application programming interface (API), the method further includes: Expose the first information to the client; The first information includes information about the first API.
4. The method according to claim 1, characterized in that, Before sending the second request information to the second service node associated with the microservice program via the second API, the method further includes: The input parameters are encrypted.
5. The method according to claim 1, characterized in that, Modifying the value of the first variable in memory based on the input parameter includes: If the microservice program is an object-oriented program, the value of the first variable in the memory of the first service node is modified using reflection based on the entry parameter.
6. The method according to claim 1, characterized in that, The method further includes: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the first database of the first service node; The first database contains data for starting the microservice program.
7. A synchronization method, characterized in that, The method is executed by the second service node, and the method includes: The variables in memory that need to be modified are marked using annotation information from the native programming language. The memory is the memory that needs to be used during the execution of the microservice program. The second service node is a service node associated with the execution of the microservice program. The address information of the second service node is registered to the registration center, wherein the registration center stores the address information of the service nodes associated with the microservice program; The second API receives a second request message sent by a first service node associated with the microservice program. The second request message is used to request modification of the value of a first variable in the memory of the second service node in order to synchronously modify the value of the first variable in the second service node. The second request message includes the entry parameter. If the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter.
8. The method according to claim 7, characterized in that, The input parameters include the key information of the first variable and / or the modified value.
9. The method according to claim 7, characterized in that, The method further includes: The encrypted entry parameters in the second request information are decrypted to obtain the decrypted entry parameters.
10. The method according to claim 7, characterized in that, Modifying the value of the first variable in the memory of the second service node based on the input parameters includes: If the microservice program is an object-oriented program, the value of the first variable in the memory of the second service node is modified using reflection based on the entry parameter.
11. The method according to claim 7, characterized in that, The method further includes: In response to the successful modification of the first variable in memory, the modified value of the first variable is stored in the second database of the second service node; The second database contains data used to start the microservice program.
12. A synchronization device, characterized in that, The device includes: The first marking module is configured to use annotation information in the native programming language to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the first service node is a service node associated with the execution of the microservice program. The first transceiver module is configured to: register the address information of the first service node to a registration center, wherein the registration center stores the address information of the service node associated with the microservice program; and receive a first request message sent by a client through a first application programming interface (API), wherein the first request message is used to request modification of the value of a first variable in memory, and the first request message includes an entry parameter for modifying the value of the first variable. The first modification module is configured to: if the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter; The first transceiver module is further configured to: upon receiving the first request information, obtain the address information of the service node associated with the microservice program from the registration center, wherein the address information includes the address of the second service node; in response to receiving the first request information, based on the address information, send a second request information to the second service node associated with the microservice program via a second API, wherein the second request information is used to request modification of the value of the first variable in the memory of the second service node to synchronously modify the value of the first variable in the second service node, and the second request information includes the entry parameter.
13. A synchronization device, characterized in that, The device includes: The second marking module is configured to use annotation information in the native programming language to mark variables in memory that need to be modified, wherein the memory is the memory that needs to be used during the execution of the microservice program, and the second service node is a service node associated with the execution of the microservice program. The second transceiver module is configured to: register the address information of the second service node to the registration center, wherein the registration center stores the address information of the service node associated with the microservice program; and receive, via a second API, a second request message sent by the first service node associated with the microservice program, wherein the second request message is used to request modification of the value of a first variable in the memory of the second service node to synchronously modify the value of the first variable in the second service node, and the second request message includes the entry parameter; The second modification module is configured to: if the marked variable contains the first variable, modify the value of the first variable in memory based on the entry parameter.
14. A processing apparatus, characterized in that, The processing equipment includes: Memory, used to store executable programs; A processor, when executing an executable program stored in the memory, implements the method as described in any one of claims 1 to 6 and / or claims 7 to 11.
15. A computer storage medium, characterized in that, The computer storage medium stores an executable program, which, when executed by a processor, implements the method as described in any one of claims 1 to 6 and / or claims 7 to 11.
Citation Information
Patent Citations
Method and system for managing variables of web applications
CN106293678A
Method and system for operating memory data, equipment and medium
CN113608725A
Local cache synchronization method and system based on micro-service and version number mechanism
CN117171271A
