Synchronization method and device for service configuration data in distributed system
By configuring multiple management nodes of the data management system in a distributed system to receive and process changes notifications of business configuration data, synchronize the latest version of data to the application cache, solving the problem of invalid database access caused by excessive synchronization frequency, and achieving more efficient data updates and system stability.
Patent Information
- Application Number
- CN202311820089.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-27
- Publication Date
- 2025-06-27
AI Technical Summary
In distributed systems, the synchronization frequency of business configuration data is too high, resulting in invalid database access, increasing network bandwidth consumption and the application's own garbage collection frequency, affecting system stability.
By configuring multiple management nodes in the data management system, we receive notifications of changes in business configuration data, update version information, and make each management node informed. When updating version information, synchronize the latest version of business configuration data to the application cache, thereby improving the timeliness of data updates and reducing invalid database access.
It realizes the timely update of business configuration data in the application local cache without increasing physical resource investment, reduces invalid database access and network bandwidth consumption, and improves system stability.
Smart Images

Figure CN120216592A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular, to a method and device for synchronizing service configuration data in a distributed system. Background Art
[0002] The non-bank payment institution network payment clearing platform provides a national unified clearing system, which has extremely high requirements for the stability of the platform. Among them, the service configuration data that supports the smooth operation of the platform is very important. Service configuration data refers to the configuration carried out for specific service requirements, and is used to support the implementation of service processes and requirements.
[0003] A system that can provide service configuration data requires a very large amount of data query and invocation, and also requires a very high success rate. To meet the above requirements, an application local cache is usually added locally. When querying service configuration data, there is no need to access the database, thereby improving the query rate. Correspondingly, when the service configuration data in the database changes, the application local cache needs to be refreshed. For different service configuration data, different synchronization frequencies can be set when synchronizing between the application local cache and the database. By increasing the synchronization frequency of service configuration data, the timeliness of service configuration data synchronization can be improved. However, at the same time, if the service configuration data has not changed, too many invalid database accesses will be generated, and the network bandwidth consumption and the garbage collection frequency of the application itself will be increased.
[0004] Therefore, how to avoid generating too many invalid database accesses, reduce the network bandwidth consumption and the garbage collection frequency of the application itself is an urgent problem to be solved at present. Summary of the Invention
[0005] Embodiments of the present invention provide a method and device for synchronizing service configuration data in a distributed system, which can improve the timeliness of updating various service configuration data in the application local cache without increasing physical resource investment and without causing pressure on existing resources, while reducing the invalid access of the application and the database of the service configuration data, reducing the network bandwidth consumption, and improving the system stability.
[0006] In a first aspect, an embodiment of the present invention provides a method for synchronizing service configuration data. The applications using the service configuration data include multiple application nodes. The method is executed by any one of the management nodes in the configuration data management system, and includes:
[0007] Receiving a change notification for target service configuration data;
[0008] Updating the version information of the target service configuration data according to the change notification, and causing each management node in the configuration data management system to know that the version information of the target service configuration data has been updated;
[0009] When it is known that the version information of any service configuration data is updated, the application cache of this management node synchronizes the latest version of the updated service configuration data from the service configuration database for the application node corresponding to the application cache to read.
[0010] In the above technical solution, a configuration data management system includes multiple management nodes. For any one node, when it is necessary to modify service configuration data, a change notification will be received. Then, the version information of the service configuration data is updated according to the change notification. And each management node in the configuration data management system is informed that the above service configuration data is updated. And for any one of the multiple management nodes, when it is known that any service configuration data is updated, the application cache of this management node synchronizes the new version of the service configuration data from the database. This improves the timeliness of the update of various service configuration data in the local cache of the application and reduces the invalid access to the database.
[0011] Optionally, updating the version information of the target service configuration data according to the change notification includes:
[0012] Determine the first type to which the target service configuration data belongs;
[0013] Generate a first version number corresponding to the service configuration data of the first type according to the target service configuration data.
[0014] In the above technical solution, after determining the first type corresponding to the target service configuration data, a first version number corresponding to the service configuration data of the first type is generated according to the target service configuration data. Through the first version number, the bandwidth consumption of the network can be reduced and the system stability can be improved.
[0015] Optionally, generating a first version number corresponding to the target service configuration data of the first type according to the target service configuration data includes:
[0016] Use the last change timestamp of the target service configuration data as the first version number corresponding to the service configuration data of the first type.
[0017] In the above technical solution, the first version number can be determined according to the last change timestamp of the target service configuration data or determined according to a preset algorithm. When transmitting, it can reduce the bandwidth consumption of the network and improve the system stability.
[0018] Optionally, updating the version information of the target service configuration data according to the change notification and informing each management node in the configuration data management system that the version information of the target service configuration data is updated includes:
[0019] Update the version information to the master data node of the version database, so that the slave data nodes of the version database can obtain the version information based on the synchronization mechanism;
[0020] Each of the management nodes is respectively connected to at least one data node, and monitors whether the version information in the corresponding data node is updated.
[0021] In the above technical solution, different types of service configuration data have different identifiers. After generating the first version number corresponding to the first type of service configuration data, a mapping relationship between the identifier of the first type of service configuration data and the corresponding first version number is established. Then, the first version number and the mapping relationship between the first version number and the corresponding identifier of the first type are saved to the master data node of the database. The slave data nodes of the database synchronize the version information in the master data node based on the synchronization mechanism. If the changed service configuration data needs to be in gray scale, the changed service configuration data is written into the gray scale pre-effective data table, and after being processed by the gray scale task, the gray scale becomes effective and is then stored in the database, realizing the fine-grained update of the service configuration data. Each management node is respectively connected to at least one data node, and periodically obtains the first version number corresponding to each type of service configuration data. For any type of service configuration data, after obtaining the first version number of this type of service configuration data, it is compared with the second version number corresponding to this type of service configuration data in the local cache to determine whether they are the same. If they are not the same, it indicates that the service configuration data of this type has changed; if they are the same, it indicates that the service configuration data of this type has not changed. This improves the timeliness of the update of various service configuration data in the application local cache and reduces the ineffective access to the database.
[0022] Optionally, updating the version information of the target service configuration data according to the change notification and enabling each management node in the configuration data management system to know that the version information of the target service configuration data has been updated includes:
[0023] Publish a message event indicating that the version information of the target service configuration data has been updated to the message middleware;
[0024] Each of the management nodes is a consumer of the message event.
[0025] In the above technical solution, a mapping relationship between the identifier of the first type corresponding to the target service configuration data and the first version number is established, and then the first version number and the mapping relationship between the first version number and the corresponding identifier of the first type are saved to the database. The management node then publishes a message event indicating that the version information of the target service configuration data has been updated to the message middleware. Each management node can consume the message event in the message middleware, then obtain the first version number of the service configuration data of the first type from the database, and update the service configuration data of the first type in the application cache. This improves the timeliness of the update of various service configuration data in the local cache of the application and reduces the ineffective access to the database.
[0026] Optionally, synchronizing the latest version of the service configuration data whose update has occurred from the service configuration database to the application cache of this management node includes:
[0027] Obtaining the service configuration data of the first type corresponding to the service configuration data whose update has occurred from the database;
[0028] Updating the service configuration data of the first type and the first version number corresponding to the service configuration data of the first type to the application cache.
[0029] In the above technical solution, each type of service configuration data has a corresponding identifier. According to the mapping relationship of the first version number, the identifier of the service configuration data of the first type is determined, and then the service configuration data of the first type is obtained from the database. The service configuration data of the first type in the local cache is updated according to the obtained service configuration data of the first type, and the corresponding first version number is used as the second version number to realize the update of the service configuration data in the local cache, improving the timeliness of the update of various service configuration data in the local cache of the application.
[0030] Optionally, the method further includes:
[0031] Determining the application node corresponding to the application cache;
[0032] Sending a change instruction to the application node; the change instruction includes the service configuration data of the first type corresponding to the service configuration data whose update has occurred, and the first version number corresponding to the service configuration data of the first type, so that the application node updates its corresponding information according to the change instruction.
[0033] In the above technical solution, after the service configuration data of the first type in the application cache is updated, the application node corresponding to this type of service configuration data is determined. A change instruction is sent to the application node so that the application node synchronizes the second version number of the service configuration data of the above type and the configuration data of the above type. This improves the timeliness of the update of various service configuration data.
[0034] Optionally, the method further includes:
[0035] Receiving a query request sent by an application node corresponding to an application cache;
[0036] In response to the query request, feeding back a query result to the application node; the query result includes a second version number corresponding to each type of service configuration data; so that the application node determines a second version number inconsistent with its own version information according to the query result, and reads the service configuration data corresponding to the inconsistent second version number.
[0037] In the above technical solution, after receiving a query request sent by an application node corresponding to an application cache, the second version number corresponding to each type of service configuration data in the application cache is sent to the client, so that the application node synchronizes the service configuration data of the second version number different from its own version information. Improve the timeliness of updating various types of service configuration data.
[0038] In a second aspect, an embodiment of the present invention provides a synchronization device for service configuration data in a distributed system, including:
[0039] An obtaining module, configured to receive a change notification for target service configuration data;
[0040] A processing module, configured to update the version information of the target service configuration data according to the change notification, and notify each management node in the configuration data management system that the version information of the target service configuration data has been updated;
[0041] When it is known that the version information of any service configuration data has been updated, the application cache of the local management node synchronizes the latest version of the service configuration data that has been updated from the service configuration database for the application node corresponding to the application cache to read.
[0042] Optionally, the processing module is specifically configured to:
[0043] Determine a first type to which the target service configuration data belongs;
[0044] Generate a first version number corresponding to the service configuration data of the first type according to the target service configuration data.
[0045] Optionally, the processing module is specifically configured to:
[0046] Use the last change timestamp of the target service configuration data as the first version number corresponding to the service configuration data of the first type.
[0047] Optionally, the processing module is specifically configured to:
[0048] Update the version information to the master data node of the version database, so that the slave data nodes of the version database can obtain the version information based on the synchronization mechanism;
[0049] Each of the management nodes is respectively connected to at least one data node and monitors whether the version information in the corresponding data node is updated.
[0050] Optionally, the processing module is specifically configured to:
[0051] Publish a message event indicating that the version information of the target service configuration data is updated to the message middleware;
[0052] Each of the management nodes is a consumer of the message event.
[0053] Optionally, the processing module is specifically configured to:
[0054] Obtain the first type of service configuration data corresponding to the updated service configuration data from the database;
[0055] Update the first type of service configuration data and the first version number corresponding to the first type of service configuration data to the application cache.
[0056] Optionally, the processing module is further configured to:
[0057] Determine the application node corresponding to the application cache;
[0058] Send a change instruction to the application node; the change instruction includes the first type of service configuration data corresponding to the updated service configuration data and the first version number corresponding to the first type of service configuration data, so that the application node updates its corresponding information according to the change instruction.
[0059] Optionally, the processing module is further configured to:
[0060] Receive a query request sent by the application node corresponding to the application cache;
[0061] In response to the query request, feedback a query result to the application node; the query result includes the second version numbers corresponding to each type of service configuration data; so that the application node determines the second version numbers inconsistent with its own version information according to the query result and reads the service configuration data corresponding to the inconsistent second version numbers.
[0062] In a third aspect, an embodiment of the present invention provides a configuration data management system, including multiple management nodes;
[0063] Any management node in the configuration data management system is used for:
[0064] The management node receives a change notice for the target service configuration data;
[0065] The management node updates the version information of the target service configuration data according to the change notice, and notifies other management nodes in the configuration data management system that the version information of the target service configuration data has been updated;
[0066] When the management node learns that the version information of any service configuration data has been updated, the application cache of the management node synchronizes the latest version of the service configuration data that has been updated from the service configuration database for the application node corresponding to the application cache to read.
[0067] Fourthly, an embodiment of the present invention further provides a computer device, including:
[0068] A memory for storing program instructions;
[0069] A processor for calling the program instructions stored in the memory and executing the synchronization method of service configuration data in the above-mentioned distributed system according to the obtained program.
[0070] Fifthly, an embodiment of the present invention further provides a computer-readable storage medium, and the computer-readable storage medium stores computer-executable instructions for causing a computer to execute the synchronization method of service configuration data in the above-mentioned distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following will briefly introduce the drawings required for the description of the embodiments. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to these drawings.
[0072] Figure 1 It is a schematic diagram of a system architecture provided by an embodiment of the present invention;
[0073] Figure 2 It is a database architecture diagram provided by an embodiment of the present invention;
[0074] Figure 3 It is a data table structure diagram provided by an embodiment of the present invention;
[0075] Figure 4 It is a flowchart of a synchronization method of service configuration data in a distributed system provided by an embodiment of the present invention;
[0076] Figure 5A flowchart showing a method for synchronizing service configuration data in a distributed system provided by an embodiment of the present invention;
[0077] Figure 6 A structural diagram of a device for synchronizing service configuration data in a distributed system provided by an embodiment of the present invention. Detailed implementation manners
[0078] In order 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. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the scope of protection of the present invention.
[0079] The terms "first" and "second" in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in this application may represent at least two, for example, it may be two, three or more, and the embodiments of this application do not make limitations.
[0080] Before introducing a method for synchronizing service configuration data provided by an embodiment of this application, for the convenience of understanding, first, the nouns and technical background related to the embodiments of this application will be introduced below.
[0081] Service configuration data: Service configuration data refers to the configuration for specific service requirements, which is used to support the implementation of service processes and requirements. It generally has a low change frequency and includes business rules, service process configurations, data dictionaries, business parameters, etc.
[0082] Application local cache: Application local cache refers to a technology used in an application program to store and manage data to improve the performance and response speed of the application program. It creates a temporary storage area on the local computer to save the data that needs to be frequently read and written in the application program, avoiding the delay of obtaining data from the network or database each time.
[0083] As a system that can provide service configuration data services, the data call volume during data query is very large, and the success rate requirement for data calls is very high. To meet the above requirements, application local caches are usually added to improve the performance of data query and reduce the dependence on the database. When the service configuration data changes, there is a corresponding mechanism to refresh the application local cache.
[0084] Generally, a balance needs to be struck between the timeliness of data cache updates and the impact of database access on performance, so as to not only ensure that the latest business configuration data can be obtained in a timely and effective manner when the business configuration data is used, but also not increase the database access pressure and maintain the stability of the database service. In related technologies, for different types of business configuration data, the application local cache can have different synchronization frequencies with the database. If the requirement for perceiving data changes is relatively high, the synchronization frequency needs to be increased. For example, for the machine room routing rules: such configuration data is directly related to the timeliness of isolation in case of machine room failures and can be synchronized once per second; for the member institution message version: such configuration is related to the message version used by member institutions and can be synchronized once per minute.
[0085] With the development of business, the types of business configuration data are increasing. When multiple different types of business configuration data need to improve the timeliness of application local cache updates simultaneously, the existing solutions need to increase the refresh frequencies of various types of business configuration data at the same time. However, due to the characteristic that business configuration data has a relatively low change frequency, when the business configuration data has not changed, accessing the database to update the business configuration data will result in invalid database access, increase the network bandwidth consumption, and since the original business configuration data needs to be cleared when updating the business configuration data in the application local cache, it increases the garbage collection frequency of the application itself.
[0086] Therefore, the present invention proposes a synchronization method for business configuration data. By detecting changes in the version number, it is possible to reduce invalid database access, lower the network bandwidth consumption and the garbage collection frequency of the application itself, and improve the stability of the system.
[0087] Figure 1 An exemplary system architecture applicable to the embodiments of the present invention is shown. The system architecture includes a terminal device 100, a platform 110, and a database 120. The platform 110 includes a basic data management system 130. The basic data management system 130 includes a data change processing module 140, an application local data cache module 150, a data change notification acceptance module 160, and a data sharing service 170.
[0088] A client of an application with various types of service configuration data is installed on the terminal device 100. It can be understood that the terminal device 100 can be a mobile phone, a tablet computer, a laptop computer, a netbook, a vehicle-mounted device, and a business intelligence terminal (including: visual phone, conference desktop intelligent terminal, etc.), a personal digital assistant (PDA), an augmented reality (AR) / virtual reality (VR) device, etc. The embodiments of the present application do not limit the specific form of the terminal device.
[0089] The platform 110 is used to process the service configuration data based on the basic data management system 130. Specifically, the data change processing module 140 is used to receive change requests of various types of service configuration data, and when a change request is received, save the changed service configuration data to the database 120, and at the same time notify the data change notification acceptance module 160 to generate a first version number corresponding to this type of service configuration data. After generating the first version number, the data change notification acceptance module 160 establishes a mapping relationship between the first version number and the identifier of this type of service configuration data, and saves the first version number and the mapping relationship to the database 120, and monitors whether the first version number is consistent with the second version number of this type of service configuration data. When they are inconsistent, the data change notification acceptance module 160 notifies the application local data cache module 150 to update this type of service configuration data. The application local data cache module 150 is used to save various types of service configuration data, and after receiving the update notification from the data change notification acceptance module 160, obtain this type of service configuration data from the database for update. The data sharing service 170 is used to obtain various types of service configuration data and the corresponding second version numbers from the application local data cache module 150 after receiving a query request from the client.
[0090] The database 120 is used to save various types of service configuration data, the corresponding first version numbers, and the mapping relationships between various types of identifiers and the first version numbers. The database 120 adopts a master-slave cross-data center synchronization architecture, such as Figure 2 shown Figure 2 An exemplary database architecture diagram applicable to the embodiments of the present invention is shown, which includes a main data center cluster and multiple non-main data center clusters, and the main data center can be switched. The main data center can perform read and write operations, and the non-main data center can only perform read operations. During the data synchronization process, the master in the non-main data center is used as a slave of the main data center for data synchronization, and the remaining nodes are used as slaves of this master for data synchronization. The corresponding first version numbers and the mapping relationships between various types of identifiers and the first version numbers in the database 120 are saved in the form of data tables, such as Figure 3 shownFigure 3 Exemplarily shown is a structure diagram of a data table applicable to an embodiment of the present invention. Different data tables respectively correspond to various types of service configuration data. The data table contains the identifier of this type, the corresponding first version number, and the last update time. When the first version number and the mapping relationship between each type of identifier and the first version number are obtained, the corresponding data table is determined according to the mapping relationship, and the first version number in the data table is replaced.
[0091] It should be noted that Figure 1 the structure shown above is only an example, and the embodiments of the present invention are not limited thereto.
[0092] Based on the above description, Figure 4 Exemplarily shown is a schematic flowchart of a method for synchronizing service configuration data in a distributed system provided by an embodiment of the present invention. As Figure 4 shown, the process specifically includes:
[0093] Step 410, receiving a change notice for target service configuration data.
[0094] In an embodiment of the present invention, it is executed by any one of the management nodes in the configuration data management system, and any one of the management nodes will receive a change notice for a piece of service configuration data.
[0095] Step 420, updating the version information of the target service configuration data according to the change notice, and notifying each management node in the configuration data management system that the version information of the target service configuration data has been updated.
[0096] In an embodiment of the present invention, the version information of the target service configuration data is updated according to the received change notice. Specifically, after receiving a change notice including the target service configuration data, the first type of the target service configuration data is determined. A corresponding first version number is generated according to the first type of the target service configuration data. Exemplarily, when the platform modifies the service configuration data in the computer room routing rule, the type of this service configuration data is the computer room routing rule. The corresponding first version number is generated according to the computer room routing rule. Among them, the type can be set according to experience, or set according to the use of the service configuration data, or determined according to the data type of the service configuration data. For example, the types include computer room routing rules and member institution message versions. There are multiple pieces of service configuration data in the computer room routing rules and member institution messages respectively. The type of the service configuration data is not specifically limited herein.
[0097] The process of generating the first version number can be as follows: using the last change timestamp of the target service configuration data as the first version number corresponding to the first type of service configuration data; or calculating based on a preset algorithm according to the last change timestamp of the target service configuration data and the target service configuration data to obtain the first version number corresponding to the first type of service configuration data.
[0098] Meanwhile, each management node in the configuration data management system is informed that the version information of the target service configuration data has been updated. The version information is updated to the master data node of the version database so that the slave data nodes of the version database can obtain the version information based on the synchronization mechanism. Each management node is respectively connected to at least one data node and monitors whether the version information in the corresponding data node has been updated. Specifically, after generating the first version number, a mapping relationship between the identifier of the first type and the first version number corresponding to the first type of service configuration data is established. The first version number corresponding to the first type of service configuration data and the mapping relationship between the identifier of the first type and the first version number corresponding to the first type of service configuration data are stored in the database. Specifically, according to the mapping relationship between the identifier of the first type and the first version number corresponding to the first type of service configuration data, the corresponding data table is determined, and the first version number in the corresponding data table is replaced with this first version number. In some embodiments, if the changed service configuration data needs to be in a gray state, the changed service configuration data is written into the gray pre-effective data table, and after passing through the gray task processing to make the gray state effective, it is then saved to the database. The database includes a master data node and slave data nodes, and each management node is connected to at least one data node. Each management node periodically obtains the first version number corresponding to each type of service configuration data from the database. Among them, the period can be a preset value based on experience, such as obtaining it once every 5 seconds, which is not specifically limited here. Any type of service configuration data includes at least one service configuration data. For any type of service configuration data, it is determined whether the first version number corresponding to this type of service configuration data is consistent with the second version number corresponding to this type of service configuration data in the application cache. Specifically, after obtaining the first version number of any type of service configuration data, the first version number is compared with the second version number corresponding to this type of service configuration data in the application local cache to determine whether they are consistent. Exemplarily, after obtaining the first version number of the machine room routing rule, it is compared with the second version number of the machine room routing rule in the application local cache. If they are consistent, it indicates that this type of service configuration data has not been updated; if they are inconsistent, it indicates that this type of service configuration data has been updated.
[0099] In a possible embodiment, for any management node, a message event indicating an update in the version information of the target service configuration data is published to the message middleware. Each management node is a consumer of the message event. Specifically, after saving the first version number to the database, the management node publishes the message event to the message middleware, enabling each management node to obtain the first version number and the corresponding service configuration data of the first type from the database after consuming the message event, and then update the service configuration data of the first type and the second version number in the application cache.
[0100] Step 430, when it is known that the version information of any service configuration data has been updated, synchronize the latest version of the updated service configuration data from the service configuration database to the application cache of this management node for the application node corresponding to the application cache to read.
[0101] In the embodiment of the present invention, for any management node, when it is known that the version information of any service configuration data has been updated, synchronize the latest version of the updated service configuration data from the service configuration database to the application cache of this management node for the application node corresponding to the application cache to read. For example, when the first version number of any type of service configuration data is different from the second version number corresponding to the service configuration data of this type in the application cache, synchronize the service configuration data of this type and the corresponding first version number to the application cache. Specifically, obtain the service configuration data of this type from the database, such as obtaining the service configuration data of the computer room routing rules from the database. Update the service configuration data of this type in the application cache according to the service configuration data of this type obtained from the database. Use the first version number corresponding to the service configuration data of this type as the second version number corresponding to the service configuration data of this type. Exemplarily, query the details of the service configuration data of the computer room routing rules in the local application cache, replace the details of the service configuration data of the computer room routing rules in the local application cache with the details of the changed service configuration data of the computer room routing rules obtained from the database, and replace the second version number of the service configuration data of the computer room routing rules in the local application cache with the first version number, that is, regard the first version number as the second version number.
[0102] In a possible implementation, every interval period, obtain the service configuration data of each type in the database, replace the service configuration data of each type in the application cache, and use the current timestamp as the third version number of the service configuration data of each type. Establish a mapping relationship between the identifier of the service configuration data of each type and the fourth version number, and save the mapping relationship and the third version number to the database. The interval period can be every hour, or every two hours, and can be a preset value based on experience, which is not specifically limited here.
[0103] In another possible implementation, the application node corresponding to the application cache reads the service configuration data in the application cache, including: determining the application node corresponding to the application cache; sending a change instruction to the application node having the application node, where the change instruction includes the first type of service configuration data corresponding to the updated service configuration data and the first version number corresponding to the first type of service configuration data, so that the application node updates the information corresponding to itself according to the change instruction. In some embodiments, the change instruction includes the second version number corresponding to each type of service configuration data. After receiving the change instruction, the application node compares whether the version information of its own service configuration data is the same as the second version number, and then obtains the service configuration data with different version information from the application cache of the management node to update the service configuration data corresponding to itself. Exemplarily, the application corresponding to the computer room routing rule is the treasury front-end application, and a change instruction is sent to the client having the treasury front-end application. The change instruction includes the second version number corresponding to each type of service configuration data in the treasury front-end application. After receiving the change instruction, the client compares whether the version information of each type of service configuration data in its own treasury front-end application is consistent with the second version number of each type of service configuration data corresponding in the change instruction. If the version information of any service configuration data is different from the second version number, the service configuration data of the type corresponding to the version information of the service configuration data is updated.
[0104] In still another possible implementation, the application node corresponding to the application cache reads the service configuration data in the application cache, including: receiving a query request sent by the application node corresponding to the application cache; in response to the query request, sending the second version number corresponding to each type of service configuration data to the application node, so that after receiving the second version number, the application node compares whether the version information of its own service configuration data is the same as the second version number, and then obtains the service configuration data with different version information from the application cache of the management node to update the service configuration data corresponding to itself. Exemplarily, the application corresponding to the computer room routing rule is the treasury front-end application. A query instruction sent by the client having the treasury front-end application is received. After receiving the query instruction, the second version number of each type of service configuration data in the treasury front-end application is sent to the client. After the client receives the second version number of each type of service configuration data, it compares whether the version information of each type of service configuration data in its own treasury front-end application is consistent with the second version number of each type of service configuration data obtained. If the version information of any service configuration data is different from the second version number, the service configuration data of the type corresponding to the version information of the service configuration data is updated.
[0105] In an embodiment of the present invention, the platform includes a configuration data management system, and the configuration data management system has multiple management nodes corresponding to multiple databases. After any management node changes the service configuration data, the data version number and the changed service configuration data are saved to the database, and each management node can perceive the data change through the database synchronization mechanism, so that each management node can update the service configuration data in the local cache of the application in a timely manner. Among them, other message middleware can also be used to replace the data synchronization of each management node, which is not specifically limited here.
[0106] To better explain the above technical solution, Figure 5 An exemplary flow diagram of a method for synchronizing service configuration data in a distributed system provided by an embodiment of the present invention is shown, as Figure 5 shown. The overall process is divided into four parts, specifically including: configuration details change logic, data version change notification logic, configuration details cache logic, and application query configuration details logic. This process can be implemented by any management node in the configuration data management system. Taking one management node in any management node as an example, the specific process implemented in this management node includes:
[0107] The configuration details change logic is specifically:
[0108] Step 501, receive a change notification.
[0109] Receive a change notification of the service configuration data. The change notification includes the changed service configuration data, such as changing the switch for sending MQ messages from true to false.
[0110] Step 502, determine whether gray scale is required. If so, execute step 503, otherwise execute step 505.
[0111] Determine the first type corresponding to the changed service configuration data, and determine whether the changed service configuration data requires gray scale.
[0112] Step 503, write to the gray scale pre-effective data table.
[0113] Write the changed service configuration data to the gray scale pre-effective data table.
[0114] Step 504, perform gray scale task processing.
[0115] Process the changed service configuration data written to the gray scale pre-effective data table to make the gray scale effective.
[0116] Step 505, write to the database.
[0117] If the changed service configuration data does not require gray scale, it is directly written to the database.
[0118] If the changed business configuration data needs to be in a gray release state, it will be written to the database after the gray release takes effect.
[0119] Step 506, notify the current version of the data to change.
[0120] The logic for notifying the data version change is specifically as follows:
[0121] Step 507, receive the notification of the data version change.
[0122] After the data version change module receives the version change notification, it generates a first version number according to the type corresponding to the changed business configuration data.
[0123] Step 508, write the data version to the database.
[0124] Establish a mapping relationship between the first version number and the first type, and write the first version number and the mapping relationship to the database.
[0125] Step 509, periodically obtain the data version.
[0126] Obtain the first version number of the business configuration data of any type from the database every five seconds.
[0127] Step 510, determine whether the data version has changed. If it has changed, execute Step 511; if not, directly end.
[0128] Compare the first version number of the business configuration data of any type obtained with the second version number in the application cache to determine whether they are the same.
[0129] Step 511, determine whether it is the first startup. If not, execute Step 512; if so, directly end.
[0130] Determine whether it is the first time to obtain the first version number.
[0131] Step 512, publish a data version change event.
[0132] The logic for configuring the detailed cache is specifically as follows:
[0133] Step 513, receive the data version change event.
[0134] Step 514, determine the type of the business configuration data.
[0135] Determine the type of the business configuration data according to the first version number.
[0136] Step 515, update the business configuration data in the application local cache.
[0137] Query the application configuration details in the local cache of the application and determine the business configuration data type. Obtain the business configuration data of this type in the database and replace the business configuration data in the local cache of the application.
[0138] Step 516, obtain the business configuration data of each type once every preset time period.
[0139] Obtain the business configuration data of each type corresponding to the application in the database once per hour.
[0140] Step 517, use the current timestamp as the data version number.
[0141] Use the timestamp when obtaining the business configuration data of each type currently as the fourth version number. Save the fourth version number to the database.
[0142] Step 518, replace the business configuration data of each type in the local cache of the application.
[0143] Query all valid business configuration data of the application in the local cache of the application, and replace the business configuration data of each type in the local cache of the application with the obtained business configuration data of each type according to the corresponding relationship.
[0144] The specific logic for the application to query the configuration details is as follows:
[0145] Step 519, query the data version in the local cache of the application.
[0146] Query the second version number of the business configuration data of each type in the local cache of the application.
[0147] Step 520, query the data version in the gray area in the local cache of the application.
[0148] Query the second version number of the business configuration data of each type in the gray area in the local cache of the application.
[0149] Step 521, determine whether the data version in the client is consistent with the data version in the local cache of the application. If not, execute Step 522; if so, execute Step 523.
[0150] Step 522, an update is required.
[0151] Determine that the business configuration data in the client needs to be updated.
[0152] Step 523, no update is required.
[0153] Determine that the business configuration data in the client does not need to be updated.
[0154] Step 524, return the result.
[0155] Send messages that need to be updated or do not need to be updated to the client.
[0156] In the configuration details memory structure in the figure, app1 can be the front-office application for the national treasury, and app2 can be the security situation application; conflg1 can be the switch for sending messages by MQ, and the corresponding detail1 can be true; conflg2 can be the warning transaction amount, and the corresponding detail1 can be 10,000. The above content is only an example and is not specifically limited here.
[0157] In the embodiments of the present invention, by monitoring the changes in the data versions of various types of service configuration data, when the data version of any type of service configuration data changes, obtain the service configuration data of that type to update the service configuration data of that type in the local cache of the application. This reduces invalid database access, reduces network bandwidth consumption and the garbage collection frequency of the application itself, and improves the stability of the system.
[0158] Based on the same technical concept, Figure 6 Exemplarily shows a schematic structural diagram of a synchronization device for service configuration data in a distributed system provided by an embodiment of the present invention. This device can execute the process of the synchronization method for service configuration data in the distributed system.
[0159] As Figure 6 shown, the device specifically includes:
[0160] An acquisition module 610, configured to receive a change notification for target service configuration data;
[0161] A processing module 620, configured to update the version information of the target service configuration data according to the change notification, and notify each management node in the configuration data management system that the version information of the target service configuration data has been updated;
[0162] When it is known that the version information of any service configuration data has been updated, cause the application cache of the local management node to synchronize the latest version of the service configuration data that has been updated from the service configuration database for the application node corresponding to the application cache to read.
[0163] Optionally, the processing module 620 is specifically configured to:
[0164] Determine the first type to which the target service configuration data belongs;
[0165] Generate a first version number corresponding to the service configuration data of the first type according to the target service configuration data.
[0166] Optionally, the processing module 620 is specifically configured to:
[0167] Take the last change timestamp of the target service configuration data as the first version number corresponding to the first type of service configuration data.
[0168] Optionally, the processing module 620 is specifically configured to:
[0169] Update the version information to the master data node of the version database, so that the slave data nodes of the version database obtain the version information based on the synchronization mechanism;
[0170] Each of the management nodes is connected to at least one data node and monitors whether the version information in the corresponding data node is updated.
[0171] Optionally, the processing module 620 is specifically configured to:
[0172] Publish a message event indicating that the version information of the target service configuration data has been updated to the message middleware;
[0173] Each of the management nodes is a consumer of the message event.
[0174] Optionally, the processing module 620 is specifically configured to:
[0175] Obtain the first type of service configuration data corresponding to the updated service configuration data from the database;
[0176] Update the first type of service configuration data and the first version number corresponding to the first type of service configuration data to the application cache.
[0177] Optionally, the processing module 620 is further configured to:
[0178] Determine the application node corresponding to the application cache;
[0179] Send a change instruction to the application node; the change instruction includes the first type of service configuration data corresponding to the updated service configuration data and the first version number corresponding to the first type of service configuration data, so that the application node updates its corresponding information according to the change instruction.
[0180] Optionally, the processing module 620 is further configured to:
[0181] Receive a query request sent by the application node corresponding to the application cache;
[0182] In response to the query request, feedback a query result to the application node; the query result includes the second version numbers corresponding to each type of service configuration data; so that the application node determines the second version number inconsistent with its own version information according to the query result and reads the service configuration data corresponding to the inconsistent second version number.
[0183] Based on the same inventive concept, an embodiment of the present invention further provides a computer device, including:
[0184] A memory for storing program instructions;
[0185] A processor for calling the program instructions stored in the memory and executing the method for synchronizing service configuration data in the above-mentioned distributed system according to the obtained program.
[0186] Based on the same inventive concept, an embodiment of the present invention further provides a computer-readable storage medium, where the computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause a computer to execute the method for synchronizing service configuration data in the above-mentioned distributed system.
[0187] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0188] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as the combination of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for realizing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0189] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means realizes the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 one block or multiple blocks.
[0190] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, so that a series of operation steps are executed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions for implementing the steps of the functions specified in one process or a plurality of processes and / or boxes Figure 1 one process or a plurality of processes and / or boxes Figure 1 steps of the functions specified in one box or a plurality of boxes. Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations
Claims
1. A method for synchronizing service configuration data in a distributed system, characterized in that, Applications using the service configuration data include multiple application nodes. The method is executed by any one of the management nodes in the configuration data management system and includes: Receiving a change notification for target service configuration data; Updating the version information of the target service configuration data according to the change notification, and notifying each management node in the configuration data management system that the version information of the target service configuration data has been updated; When it is known that the version information of any service configuration data has been updated, synchronize the latest version of the service configuration data with the update from the service configuration database to the application cache of this management node for the application node corresponding to the application cache to read.
2. The method according to claim 1, characterized in that, Updating the version information of the target service configuration data according to the change notification includes: Determining the first type to which the target service configuration data belongs; Generating a first version number corresponding to the service configuration data of the first type according to the target service configuration data.
3. The method according to claim 2, wherein Generating a first version number corresponding to the target service configuration data of the first type according to the target service configuration data includes: Using the last change timestamp of the target service configuration data as the first version number corresponding to the service configuration data of the first type.
4. The method according to claim 1, characterized in that, Updating the version information of the target service configuration data according to the change notification, and notifying each management node in the configuration data management system that the version information of the target service configuration data has been updated, includes: Updating the version information to the master data node of the version database so that the slave data nodes of the version database can obtain the version information based on the synchronization mechanism; Each of the management nodes is connected to at least one data node and listens for whether the version information in the corresponding data node has been updated.
5. The method according to claim 1, characterized in that, Updating the version information of the target service configuration data according to the change notification, and notifying each management node in the configuration data management system that the version information of the target service configuration data has been updated, includes: Publishing a message event indicating that the version information of the target service configuration data has been updated to the message middleware; Each of the management nodes is a consumer of the message event.
6. The method according to claim 1, wherein Synchronizing the latest version of the service configuration data with the update from the service configuration database to the application cache of this management node includes: Obtaining the service configuration data of the first type corresponding to the service configuration data with the update from the database; Updating the service configuration data of the first type and the first version number corresponding to the service configuration data of the first type to the application cache.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Determining the application node corresponding to the application cache; Sending a change instruction to the application node; the change instruction includes the service configuration data of the first type corresponding to the service configuration data with the update, and the first version number corresponding to the service configuration data of the first type, so that the application node can update its corresponding information according to the change instruction.
8. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Receiving a query request sent by the application node corresponding to the application cache; In response to the query request, feedback a query result to the application node; the query result includes second version numbers corresponding to various types of service configuration data; so that the application node determines, according to the query result, the second version numbers that are inconsistent with its own version information, and reads the service configuration data corresponding to the inconsistent second version numbers.
9. A synchronization device for service configuration data in a distributed system, characterized in that, Comprising: An acquisition module, configured to receive a change notice for target service configuration data; A processing module, configured to update the version information of the target service configuration data according to the change notice, and enable each management node in the configuration data management system to know that the version information of the target service configuration data has been updated; When it is known that the version information of any service configuration data has been updated, cause the application cache of this management node to synchronize the latest version of the service configuration data whose version has been updated from the service configuration database for the application node corresponding to the application cache to read.
10. A configuration data management system, characterized in that, Comprising a plurality of management nodes; Any management node in the configuration data management system is used for: The management node receives a change notice for target service configuration data; The management node updates the version information of the target service configuration data according to the change notice, and enables other management nodes in the configuration data management system to know that the version information of the target service configuration data has been updated; When the management node knows that the version information of any service configuration data has been updated, the management node causes the application cache of the management node to synchronize the latest version of the service configuration data whose version has been updated from the service configuration database for the application node corresponding to the application cache to read.
11. A computer device, characterized in that, Comprising: A memory, configured to store program instructions; A processor, configured to call the program instructions stored in the memory and execute the method according to any one of claims 1 to 8 according to the obtained program.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to cause a computer to execute the method according to any one of claims 1 to 8.