Configuration strategy synchronization method, device and computer program product
By comparing and updating the policy configuration data in the database and shared memory, hot loading of the configuration policy is achieved, solving the problem of cold restart required in the existing technology and improving the synchronization efficiency and stability of the system in high concurrency scenarios.
Patent Information
- Application Number
- CN202310620178.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2043-05-29
AI Technical Summary
The existing configuration policy synchronization solution is based on static configuration files and requires a cold restart to re-release and go online. It is impossible to synchronize configuration policies unconsciously in high-concurrency scenarios.
By comparing the first policy configuration data preset in the database with the second policy configuration data stored in the shared memory, it is determined whether to update, and the first policy configuration data in the shared memory is loaded through the gateway layer to achieve hot loading of the configuration policy.
In high-concurrency scenarios, it achieves imperceptible synchronization of configuration policies, reduces system overhead, and improves system stability and security.
Smart Images

Figure CN116700824B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically distributed technology, and more particularly to a configuration policy synchronization method, apparatus, electronic device, storage medium, and computer program product, which can be applied in distributed configuration synchronization scenarios. Background Art
[0002] The current configuration policy synchronization solution is based on static configuration files. Configuration policies are written to the static configuration files, read from the static configuration files by the model, and loaded into memory. In static file-based configuration synchronization, policies are configured as static files. Each time a configuration policy is modified, it must be re-released and released online using a cold restart. Summary of the Invention
[0003] The present disclosure provides a configuration policy synchronization method, apparatus, electronic device, storage medium, and computer program product.
[0004] According to a first aspect, a method for synchronizing a configuration policy is provided, comprising: comparing first policy configuration data pre-set in a database with second policy configuration data stored in a shared memory to obtain a comparison result; determining, based on the comparison result, whether to update the second policy configuration data based on the first policy configuration data; and in response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, loading the first policy configuration data in the shared memory through a gateway layer.
[0005] According to a second aspect, a configuration policy synchronization device is provided, comprising: a comparison unit configured to compare first policy configuration data pre-set in a database and second policy configuration data stored in a shared memory to obtain a comparison result; a determination unit configured to determine, based on the comparison result, whether to update the second policy configuration data based on the first policy configuration data; and a loading unit configured to load the first policy configuration data in the shared memory through a gateway layer in response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data.
[0006] According to a third aspect, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so as to enable the at least one processor to execute the method described in any implementation manner of the first aspect.
[0007] According to a fourth aspect, a non-transitory computer-readable storage medium storing computer instructions is provided, where the computer instructions are used to cause a computer to execute the method as described in any implementation of the first aspect.
[0008] According to a fifth aspect, a computer program product is provided, comprising: a computer program, which implements the method described in any implementation manner of the first aspect when executed by a processor.
[0009] According to the technology disclosed in the present invention, a method for synchronizing configuration policies is provided. Based on the comparison result between first policy configuration data pre-set in the database and second policy configuration data stored in the shared memory, if it is determined that the first policy configuration data is the updated data of the second policy configuration data, the second policy configuration data in the shared memory is updated to the first policy configuration data, and the first policy configuration data in the shared memory is loaded through the gateway layer, thereby realizing hot loading of configuration policy data. In the face of high concurrency scenarios, configuration policies can be synchronized without business perception.
[0010] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0012] Figure 1 is an exemplary system architecture diagram in which an embodiment of the present disclosure may be applied;
[0013] Figure 2 is a flow chart of an embodiment of a method for synchronizing configuration policies according to the present disclosure;
[0014] Figure 3 is a schematic diagram of an application scenario of the synchronization method of the configuration policy according to this embodiment;
[0015] Figure 4 is a flowchart of another embodiment of a method for synchronizing configuration policies according to the present disclosure;
[0016] Figure 5 is a flow chart of another embodiment of a configuration policy synchronization method according to the present disclosure;
[0017] Figure 6 is a structural diagram of an embodiment of a synchronization device for configuring a policy according to the present disclosure;
[0018] Figure 7 It is a schematic diagram of the structure of a computer system suitable for implementing the embodiments of the present disclosure. DETAILED DESCRIPTION
[0019] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0020] In the technical solutions disclosed herein, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0021] Figure 1 An exemplary architecture 100 is shown to which the synchronization method and apparatus of the configuration policy of the present disclosure can be applied.
[0022] like Figure 1 As shown, system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The communication connections between terminal devices 101, 102, 103 constitute a topological network, and network 104 is used to provide a medium for communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0023] The terminal devices 101, 102, and 103 can be hardware devices or software that support network connection for data interaction and data processing. When the terminal devices 101, 102, and 103 are hardware, they can be various electronic devices that support network connection, information acquisition, interaction, display, processing, and other functions, including but not limited to smartphones, tablet computers, car computers, e-book readers, laptop computers, and desktop computers. When the terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made here.
[0024] Server 105 can be a server that provides various services, for example, a background processing server that receives network requests from terminal devices 101, 102, and 103 and processes the network requests through a gateway layer that loads updated policy configuration data. The background processing server can synchronize policy configuration data in the following manner: based on a comparison result between first policy configuration data pre-set in a database and second policy configuration data stored in a shared memory, if it is determined that the first policy configuration data is an update of the second policy configuration data, the second policy configuration data in the shared memory is updated to the first policy configuration data, and the first policy configuration data in the shared memory is loaded through the gateway layer. As an example, server 105 can be a cloud server.
[0025] It should be noted that the server can be either hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or as a single server. When the server is software, it can be implemented as multiple software or software modules (e.g., software or software modules for providing distributed services), or as a single software or software module. No specific limitations are given here.
[0026] It should also be noted that the configuration policy synchronization method provided in the embodiments of the present disclosure can be executed by a server, a terminal device, or a server and a terminal device in cooperation with each other. Accordingly, the various parts (e.g., various units) included in the configuration policy synchronization device can be entirely provided in the server, entirely provided in the terminal device, or separately provided in the server and the terminal device.
[0027] It should be understood that Figure 1 The number of terminal devices, networks, and servers in the system is merely illustrative. Any number of terminal devices, networks, and servers may be provided as needed. When the electronic device on which the synchronization method for configuring policy is running does not need to transmit data with other electronic devices, the system architecture may only include the electronic device (e.g., server or terminal device) on which the synchronization method for configuring policy is running.
[0028] Please refer to Figure 2 , Figure 2 This is a flow chart of a configuration policy synchronization method provided by an embodiment of the present disclosure. In process 200, the following steps are included:
[0029] Step 201 : Compare first policy configuration data preset in a database with second policy configuration data stored in a shared memory to obtain a comparison result.
[0030] In this embodiment, the execution subject of the synchronization method of the configuration policy (for example, Figure 1The terminal device or server in the system can obtain the first policy configuration data preset in the database and the second policy configuration data stored in the shared memory remotely or locally through a wired network connection or a wireless network connection, and compare the first policy configuration data preset in the database and the second policy configuration data stored in the shared memory to obtain a comparison result.
[0031] The policy configuration data represents the processing logic rules for network requests, such as the processing logic rules for verifying, filtering and intercepting network requests; the processing logic rules corresponding to the failover and fault tolerance mechanisms, such as the backup mechanism and cache synchronization strategy.
[0032] In a distributed scenario, front-end network requests are processed by load balancing and then distributed to the target service node in the distributed cluster. The target service node then determines and reports the processing result of the network request. Before determining the processing result, each service node in the distributed cluster must operate on the network request distributed to it using the policy configuration data loaded in the gateway layer.
[0033] The service device corresponding to each service node uses a shared memory mechanism. Shared memory refers to a mechanism by which multiple processes or threads on a service device share the same physical memory area. Operating systems typically provide technologies and APIs (Application Programming Interfaces) to support shared memory, enabling multiple processes to communicate and collaborate with each other.
[0034] The basic principle of shared memory is to map a physical memory area into the virtual address spaces of multiple processes or threads, allowing them to exchange data by reading and writing to this area. The specific implementation mechanism involves: the operating system establishes a shared memory area and protects its security (such as access permissions); processes or threads can open and connect to this shared memory area using specific APIs; and each process or thread can write to or read from this shared memory area, enabling data sharing between processes.
[0035] The second policy configuration data stored in the shared memory of a service device is the policy configuration data currently used by the service device. When there is a need to update the policy configuration data, the updated configuration policy data can be saved in the database as the first policy configuration data.
[0036] The execution subject may obtain the first policy configuration data from the database based on a preset acquisition method, wherein the preset acquisition method may be, for example, performing an operation of obtaining the first policy configuration data from the database once every preset time interval.
[0037] After obtaining the first policy configuration data in the database, the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory can be compared to obtain a comparison result. For example, the above-mentioned execution subject can compare the first policy configuration data and the second policy configuration data word by word to determine whether the two policy configuration data are consistent. For another example, the above-mentioned execution subject can obtain the hash value corresponding to the first policy configuration data and the hash value corresponding to the second policy configuration data, and determine whether the two policy configuration data are consistent based on the two hash values. For another example, the above-mentioned execution subject can compare the data generation time of the first policy configuration data and the data generation time of the second policy configuration data, and determine the comparison result based on the two data generation times.
[0038] Step 202: Determine whether to update the second policy configuration data based on the first policy configuration data according to the comparison result.
[0039] In this embodiment, the execution entity may determine whether to update the second policy configuration data based on the first policy configuration data according to the comparison result.
[0040] As an example, when the comparison result indicates that the first policy configuration data and the second policy configuration data are inconsistent, it is determined that the second policy configuration data needs to be updated based on the first policy configuration data, and in this case, the second policy configuration data in the shared memory is updated to the first policy configuration data. When the comparison result indicates that the first policy configuration data and the second policy configuration data are consistent, it is determined that the second policy configuration data does not need to be updated based on the first policy configuration data. In this example, the database generally stores the latest policy configuration data. When the first policy configuration data and the second policy configuration data are inconsistent, it can be determined that the policy configuration data in the database has been updated compared to the policy configuration data in the shared memory. In this case, the policy configuration data in the shared memory is in a lagging state.
[0041] Corresponding to the comparison result determination process listed above, when the first policy configuration data and the second policy configuration data are consistent in data content, the two policy configuration data are determined to be consistent; otherwise, the two policy configuration data are determined to be inconsistent. Alternatively, when the hash value corresponding to the first policy configuration data and the hash value corresponding to the second policy configuration data are consistent, the two policy configuration data are determined to be consistent; otherwise, the two policy configuration data are determined to be inconsistent. Alternatively, when the data generation time of the first policy configuration data and the data generation time of the second policy configuration data are consistent, the two policy configuration data are determined to be consistent; otherwise, the two policy configuration data are determined to be inconsistent.
[0042] Step 203 : In response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, the first policy configuration data in the shared memory is loaded through the gateway layer.
[0043] In this embodiment, in response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, the execution entity may load the first policy configuration data in the shared memory through the gateway layer.
[0044] In a distributed scenario, each service device in the distributed cluster may respectively perform synchronization operations on the policy configuration data based on the above steps 201 - 203 to ensure timely update of the policy configuration data loaded by the gateway layer of each service device.
[0045] Continue to see Figure 3 , Figure 3 FIG3 is a schematic diagram 300 of an application scenario of the synchronization method of the configuration policy according to this embodiment. Figure 3 In an application scenario, a policy configuration personnel has pre-configured first policy configuration data in database 301. For each service device 302 in the distributed cluster, the first policy configuration data pre-set in database 301 is compared with the second policy configuration data stored in the shared memory 3021 of the device to obtain a comparison result. Based on the comparison result, a determination is made as to whether the second policy configuration data should be updated based on the first policy configuration data. In response to determining that the second policy configuration data in shared memory 3021 has been updated to the first policy configuration data, the first policy configuration data in shared memory 3021 is loaded through the gateway layer 3022 of the device.
[0046] In this embodiment, a method for synchronizing configuration policies is provided. Based on the comparison result between first policy configuration data pre-set in the database and second policy configuration data stored in the shared memory, if it is determined that the first policy configuration data is updated data of the second policy configuration data, the second policy configuration data in the shared memory is updated to the first policy configuration data, and the first policy configuration data in the shared memory is loaded through the gateway layer, thereby realizing hot loading of configuration policy data. In the face of high concurrency scenarios, configuration policies can be synchronized without business perception.
[0047] In some optional implementations of this embodiment, the execution entity may perform step 201 as follows:
[0048] First, an asynchronous loading method based on a random clock is used to determine the first policy configuration data preset in the database.
[0049] For each service device in the distributed cluster, the recording module in the gateway layer of the service device can set a timer based on a preset time interval, and within each preset time interval, the first policy configuration data is pulled from the database at a random clock.
[0050] The preset time interval may be specifically set according to actual conditions. For example, the preset time interval is 20 seconds, and a time point is randomly selected within the time range of 20 seconds to pull the policy configuration data.
[0051] Second, compare the first policy configuration data preset in the database with the second policy configuration data stored in the shared memory to obtain a comparison result.
[0052] In this implementation, the above-mentioned execution entity can adopt the word-by-word comparison method, hash value-based comparison method, and generation time-based comparison method shown in the above-mentioned step 201 to compare the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory to obtain a comparison result.
[0053] In this implementation, by adopting an asynchronous loading method based on a random clock, it is possible to avoid the situation where a large number of nodes update the policy configuration data at the same time, thereby reducing the pressure and impact on the server. Specifically, this method of pulling policy configuration data has the following advantages: the random clock can effectively simulate the time drift between distributed nodes, making the time for pulling configuration more evenly distributed, avoiding the risk of a large number of nodes accessing the database at the same time causing excessive database load; by setting a timer to periodically pull new policy configuration data, it can ensure that the configuration information of each service node is relatively new, and relying on the random time pulling method, it can avoid service nodes using the old version of policy configuration data for a long time, causing business mismatches or calculation errors; the method of starting the timer can reduce the frequent call operations for external service interface resources, and improve the security and stability of the system; by pulling new policy configuration data with a random clock once within a preset time interval, it can effectively reduce system overhead and improve overall operating efficiency.
[0054] In some optional implementations of this embodiment, the first policy configuration data pre-set in the database is policy configuration data that is released using a hierarchical release method. Hierarchical release involves testing and verifying the configuration policy data to varying degrees in terms of stability, performance, and security, with more complete and stable versions gradually released to service nodes in the distributed cluster.
[0055] For example, during the hierarchical release of policy configuration data, newly developed or modified policy configuration data is first verified at multiple levels, including unit testing and integration testing, to ensure its quality and functional correctness. Then, after thorough testing and verification of its stability and usability, it is pushed to a small group of service nodes for real-world testing. Finally, after comprehensive testing and verification of passing all indicators, this version of the policy configuration data is pushed to the distributed cluster for use.
[0056] In this implementation, the execution subject may perform the above process of obtaining the comparison result in the following manner:
[0057] (1) For a service device that provides a target service, determine whether the first policy configuration data is policy configuration data related to the service device.
[0058] As an example, the execution entity may determine the correlation between the first policy configuration data and the service device in the following manner:
[0059] Manual specification method: The administrator or operation and maintenance personnel manually controls whether each service device in the distributed cluster needs to receive and load new policy configuration data.
[0060] Periodic polling method: By periodically polling the status and configuration version information of each service device in the distributed cluster, it is determined whether they need to receive and load new policy configuration data.
[0061] Event-driven approach: When a node in a distributed cluster needs to update its policy configuration data, it triggers a specific event and passes it to the system responsible for issuing policy configuration data. The system then decides whether to publish the new policy configuration data to the service node.
[0062] Adaptive approach based on system load and performance: A real-time determination of whether new policy configuration data needs to be loaded is made based on the current service load and performance status of the service node. If a node's performance is insufficient to complete a service request, the policy configuration may need to be readjusted to suit its actual situation.
[0063] (2) In response to the determination being yes, the first policy configuration data preset in the database is compared with the second policy configuration data stored in the shared memory to obtain a comparison result.
[0064] In this implementation, in response to determining that the first policy configuration data is the policy configuration data related to the service device, a comparison operation is performed between the first policy configuration data and the second policy configuration data to obtain a comparison result.
[0065] In this implementation, the hierarchical release of policy configuration data is adopted, which can effectively reduce the risk of releasing policy configuration data, improve its reliability and availability, and provide more stable and secure support for system operation; for each service node in the distributed cluster, when it is determined that the first policy configuration data is the policy configuration data related to the service device, the comparison operation between the first policy configuration data and the second policy configuration data is performed, thereby improving the effectiveness of information processing during the synchronization process.
[0066] In some optional implementations of this embodiment, the above-mentioned execution entity can perform the comparison process between policy data in the following manner to obtain the comparison result: compare the version number corresponding to the first policy configuration data and the version number corresponding to the second policy configuration data to obtain the comparison result.
[0067] In this implementation, a version number that uniquely identifies each policy configuration data published through the database is set, and the version number corresponding to the policy configuration data published in the database is used in the shared memory.
[0068] In this way, when the version number corresponding to the first policy configuration data and the version number corresponding to the second policy configuration data are different, it means that the first policy configuration data in the database is different from the second policy configuration data in the shared memory; otherwise, it means that the first policy configuration data in the database and the second policy configuration data in the shared memory are the same.
[0069] In order to further improve the comparison efficiency of the comparison process, the version number gradually increases with the release time of the policy configuration data. At this time, when the version number corresponding to the first policy configuration data is greater than the version number corresponding to the second policy configuration data, it means that new policy configuration data is released in the database after the second policy configuration data in the shared memory.
[0070] In this implementation, the comparison process between the policy configuration data is performed based on the version numbers corresponding to the policy configuration data, which helps to improve the execution efficiency of the comparison result determination process and reduce the information processing amount of the comparison process.
[0071] In some optional implementations of this embodiment, the above-mentioned execution entity can perform the above-mentioned step 202 in the following manner: in response to determining that the comparison result represents that the first policy configuration data is updated data after the second policy configuration data in the shared memory, the second policy configuration data in the shared memory is updated based on the first policy configuration data.
[0072] As an example, when the version number corresponding to the first policy configuration data is greater than the version number corresponding to the second policy configuration data, it is determined that the comparison result indicates that the first policy configuration data is updated data after the second policy configuration data in the shared memory, and the second policy configuration data in the shared memory is updated to the first policy configuration data.
[0073] In this implementation, in response to determining that the first policy configuration data is updated data after the second policy configuration data, a synchronization operation of the policy configuration data in the shared memory is performed, ensuring that the policy configuration in the shared memory can be updated in time, thereby improving the processing efficiency of the synchronization operation.
[0074] In some optional implementations of this embodiment, the execution subject may execute the configuration policy data update process in the following manner: based on the first policy configuration data, update the shared variables related to the second policy configuration data in the shared memory.
[0075] In a distributed scenario, when a process starts, the address of the policy configuration data in the shared memory is loaded and asynchronously loaded to replace the value of the shared variable of the policy configuration data in the shared memory, but the pointer address does not change.
[0076] In this implementation, based on shared variables, it helps to improve the execution efficiency of the update process of the configuration policy data and reduce the data processing volume of the update process.
[0077] In some optional implementations of this embodiment, before executing step 201, the execution entity may further perform the following operations:
[0078] First, in response to determining that the gateway layer is loading the policy configuration data for the first time, the policy configuration data set in the database is synchronized to the shared memory.
[0079] When the policy configuration data is loaded for the first time at the gateway layer, the policy configuration data does not exist in the shared memory. There is no need to perform a comparison process between the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory. The policy configuration data set in the database is directly synchronized to the shared memory.
[0080] Second, the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory are synchronized.
[0081] Synchronize the policy configuration data set in the database to the shared memory. It is necessary to synchronize the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory to ensure comparability between the version numbers in the subsequent comparison process.
[0082] This implementation method provides an implementation method for the gateway layer to load policy configuration data for the first time, directly synchronizes the configuration policy data in the database to the shared memory, and synchronizes the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory, providing a basis for subsequent configuration synchronization processes based on lower data processing volume.
[0083] In some optional implementations of this embodiment, before executing step 201, the execution entity may further perform the following operations:
[0084] First, based on the received configuration operation, first policy configuration data is generated.
[0085] Second, the first policy configuration data is stored in a distributed relational database.
[0086] In this implementation, the execution subject supports the configuration function of the policy configuration data, and the generated first policy configuration data is stored in a distributed relational database.
[0087] In this implementation, based on the configuration function of the policy configuration data, developers can flexibly configure the policy configuration data according to their needs; by storing the first policy configuration data in a distributed relational database, the underlying persistence of the policy configuration data is achieved, which can avoid data loss.
[0088] In some optional implementations of this embodiment, the execution entity may perform the second step in the following manner:
[0089] First, based on the configuration operation, rule configuration data and indication data representing hierarchical release of the rule configuration data in a service device providing a target service are generated.
[0090] The rule configuration data is used to represent the processing logic rules for network requests.
[0091] As an example, configuration operations include configuration data configuration operations and indication data configuration operations. Based on the configuration data configuration operations, rule configuration data is generated; based on the indication data configuration operations, indication data is generated. The target service can be a variety of services, such as online storage services, short video services, etc.
[0092] The indication data may be indication data corresponding to the above-mentioned manual designation method, timed polling method, event-driven method, or method based on system load and performance self-adaptation.
[0093] Then, the rule configuration data and the indication data are combined to obtain first policy configuration data.
[0094] In this implementation, policy configuration data supports hierarchical release, which can effectively reduce the risk of policy configuration data release, improve its reliability and availability, and provide more stable and secure support for system operation; configuration developers can flexibly configure the indicator data for hierarchical release based on configuration operations, which improves the flexibility and operability of the hierarchical release process.
[0095] In some optional implementations of this embodiment, the execution subject may further perform the following operation: processing a received network request by loading the gateway layer of the first policy configuration data.
[0096] After the gateway layer loads the updated first policy configuration data in the shared memory, the gateway layer performs operations such as verification, filtering, and interception on the received network request based on the first policy configuration data.
[0097] In this implementation, the gateway layer of the service device processes network requests according to timely synchronized policy configuration data, which improves the security of the network request processing process and ensures the healthy development of the target service ecosystem.
[0098] Continue to refer Figure 4 , shows a schematic process 400 of another embodiment of the configuration policy synchronization method according to the present disclosure. In the process 400, the following steps are included:
[0099] Step 401 : In response to determining that the gateway layer loads policy configuration data for the first time, synchronizing the policy configuration data set in the database to the shared memory.
[0100] Step 402: Synchronize the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory.
[0101] Step 403: Determine the first policy configuration data preset in the database by adopting an asynchronous loading method based on a random clock.
[0102] The first policy configuration data is policy configuration data for data release in a hierarchical release manner.
[0103] Step 404: For a service device providing a target service, determine whether the first policy configuration data is policy configuration data related to the service device.
[0104] Step 405 : In response to the determination being yes, the version number corresponding to the first policy configuration data and the version number corresponding to the second policy configuration data are compared to obtain a comparison result.
[0105] Step 406 : In response to determining that the comparison result indicates that the first policy configuration data is updated data subsequent to the second policy configuration data in the shared memory, the second policy configuration data in the shared memory is updated based on the first policy configuration data.
[0106] Step 407 : In response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, the first policy configuration data in the shared memory is loaded through the gateway layer.
[0107] Step 408: Process the received network request by loading the gateway layer of the first policy configuration data.
[0108] It can be seen from this embodiment that Figure 2 Compared with the corresponding embodiments, process 400 of the configuration policy synchronization method in this embodiment specifically describes the hierarchical publishing process of policy configuration data, the process of determining comparison results, and the process of processing network requests, realizing hot loading of configuration policy data. When facing high concurrency scenarios, configuration policies can be synchronized without business perception; based on the hierarchical publishing method, the risk of publishing policy configuration data is effectively reduced, its reliability and availability are improved, and more stable and secure support is provided for system operation.
[0109] Continue to refer to Figure 5 , shows a flow chart of a synchronization method for a configuration policy disclosed in the present invention. In order to further illustrate the implementation process of the present invention, the following description is made using a network disk system as an example:
[0110] 1. Perform data preparation operations such as data classification, verification, and formatting on the business data of the network disk system, and generate the first policy configuration data for data release in a hierarchical release manner based on the configuration operations received from the configuration developer.
[0111] 2. Store the first policy configuration data in the database.
[0112] 3. Publish the first policy configuration data in the database in a hierarchical manner:
[0113] 3.1. For each service device in the distributed network disk system, the loading module in the gateway layer of the service device requests the timing module.
[0114] 3.2. The timing module uses an asynchronous loading method based on a random clock to pull the first strategy configuration data from the database.
[0115] 3.3. During the hierarchical publishing process, determine whether the first policy configuration data is policy configuration data related to the service device.
[0116] 3.4. In response to the determination being yes, compare whether the version number corresponding to the first policy configuration data is greater than the version number corresponding to the second policy configuration data.
[0117] 3.5. In response to determining that the version number corresponding to the first policy configuration data is greater than the version number corresponding to the second policy configuration data, update the second configuration policy data in the service device to the first policy configuration data.
[0118] 3.6. The gateway layer of the service device loads the first policy configuration data in the shared memory and processes the received network request.
[0119] Continue to refer Figure 6 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a synchronization device for configuring a strategy. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0120] like Figure 6 As shown, the synchronization device 600 for configuring a policy includes: a comparison unit 601, configured to compare the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory to obtain a comparison result; a determination unit 602, configured to determine whether to update the second policy configuration data based on the first policy configuration data according to the comparison result; and a loading unit 603, configured to load the first policy configuration data in the shared memory through the gateway layer in response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data.
[0121] In some optional implementations of this embodiment, the comparison unit 601 is further configured to: determine the first policy configuration data pre-set in the database using an asynchronous loading method based on a random clock; compare the first policy configuration data pre-set in the database with the second policy configuration data stored in the shared memory to obtain a comparison result.
[0122] In some optional implementations of this embodiment, the first policy configuration data is policy configuration data that is published in a hierarchical manner, and the comparison unit 601 is further configured to: for a service device that provides a target service, determine whether the first policy configuration data is policy configuration data related to the service device; in response to determining that it is, compare the first policy configuration data pre-set in the database with the second policy configuration data stored in the shared memory to obtain a comparison result.
[0123] In some optional implementations of this embodiment, the comparison unit 601 is further configured to: compare the version number corresponding to the first policy configuration data with the version number corresponding to the second policy configuration data to obtain a comparison result.
[0124] In some optional implementations of this embodiment, the determination unit 602 is further configured to: in response to determining that the comparison result indicates that the first policy configuration data is updated data after the second policy configuration data in the shared memory, update the second policy configuration data in the shared memory based on the first policy configuration data.
[0125] In some optional implementations of this embodiment, the determining unit 602 is further configured to: update the shared variables related to the second policy configuration data in the shared memory based on the first policy configuration data.
[0126] In some optional implementations of this embodiment, the above-mentioned device also includes: a first loading unit (not shown in the figure), which is configured to: compare the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory, and before obtaining the comparison result, in response to determining that the gateway layer is loading the policy configuration data for the first time, synchronize the policy configuration data set in the database to the shared memory; synchronize the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory.
[0127] In some optional implementations of this embodiment, the above-mentioned device also includes: a configuration unit (not shown in the figure), which is configured to: generate first policy configuration data based on the received configuration operation before obtaining the comparison result between the first policy configuration data pre-set in the comparison database and the second policy configuration data stored in the shared memory; and store the first policy configuration data through a distributed relational database.
[0128] In some optional implementations of this embodiment, the configuration unit (not shown in the figure) is further configured to: based on the configuration operation, generate rule configuration data and indication data representing the hierarchical release of the rule configuration data in the service device providing the target service, wherein the rule configuration data is used to represent the processing logic rules for network requests; and combine the rule configuration data and the indication data to obtain the first policy configuration data.
[0129] In some optional implementations of this embodiment, the apparatus further includes: a processing unit (not shown in the figure), configured to process a received network request by loading a gateway layer of the first policy configuration data.
[0130] In this embodiment, a configuration policy synchronization device is provided. Based on the comparison result between the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory, if it is determined that the first policy configuration data is the updated data of the second policy configuration data, the second policy configuration data in the shared memory is updated to the first policy configuration data, and the first policy configuration data in the shared memory is loaded through the gateway layer, thereby realizing hot loading of the configuration policy data. When facing high concurrency scenarios, the configuration policy can be synchronized without business perception.
[0131] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can implement the configuration policy synchronization method described in any of the above embodiments when executing.
[0132] According to an embodiment of the present disclosure, the present disclosure further provides a readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to implement the configuration policy synchronization method described in any of the above embodiments when executed.
[0133] An embodiment of the present disclosure provides a computer program product, which, when executed by a processor, can implement the configuration policy synchronization method described in any of the above embodiments.
[0134] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0135] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. Various programs and data required for the operation of the device 700 can also be stored in the RAM 703. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0136] Various components in device 700 are connected to I / O interface 705, including an input unit 706, such as a keyboard, mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a magnetic disk, optical disk, etc.; and a communication unit 709, such as a network card, modem, wireless communication transceiver, etc. The communication unit 709 allows device 700 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0137] The computing unit 701 can be a variety of general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as the configuration policy synchronization method. For example, in some embodiments, the configuration policy synchronization method can be implemented as a computer software program that is tangibly contained in a machine-readable medium, such as the storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 700 via the ROM 702 and / or the communication unit 709. When the computer program is loaded into the RAM 703 and executed by the computing unit 701, one or more steps of the configuration policy synchronization method described above can be performed. Alternatively, in other embodiments, the computing unit 701 can be configured to perform the configuration policy synchronization method by any other appropriate means (e.g., by means of firmware).
[0138] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0139] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0140] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0141] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0142] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0143] A computer system may include a client and a server. The client and server are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, establishing a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within a cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosts and virtual private servers (VPS). It may also be a server in a distributed system or a server integrated with blockchain.
[0144] According to the technical solution of the embodiment of the present disclosure, a method for synchronizing configuration policies is provided. Based on the comparison result between the first policy configuration data pre-set in the database and the second policy configuration data stored in the shared memory, if it is determined that the first policy configuration data is the updated data of the second policy configuration data, the second policy configuration data in the shared memory is updated to the first policy configuration data, and the first policy configuration data in the shared memory is loaded through the gateway layer, thereby realizing hot loading of the configuration policy data. In the face of high concurrency scenarios, the configuration policies can be synchronized without business perception.
[0145] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions provided by this disclosure can be achieved. This is not a limitation herein.
[0146] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A configuration policy synchronization method, comprising: Comparing first policy configuration data pre-set in a database with second policy configuration data stored in a shared memory to obtain a comparison result, including: for a service device providing a target service, determining whether the first policy configuration data is policy configuration data related to the service device; in response to determining that it is, comparing the first policy configuration data pre-set in the database with the second policy configuration data stored in the shared memory to obtain the comparison result, wherein the policy configuration data is used to characterize a processing logic rule for a target service device that receives a network request for the network request, so as to guide the target service device in processing the network request and obtain a business processing result, and the first policy configuration data is policy configuration data for data publishing in a hierarchical publishing manner, and the network request is distributed to the target service device in a distributed cluster after load balancing processing; determining, according to the comparison result, whether to update the second policy configuration data based on the first policy configuration data; In response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, the first policy configuration data in the shared memory is loaded through the gateway layer.
2. The method according to claim 1, wherein The comparison of the first policy configuration data preset in the database and the second policy configuration data stored in the shared memory to obtain a comparison result includes: Determining the first policy configuration data preset in the database by adopting an asynchronous loading method based on a random clock; The first policy configuration data preset in the database and the second policy configuration data stored in the shared memory are compared to obtain the comparison result.
3. The method according to claim 1, wherein The comparing the first policy configuration data preset in the database with the second policy configuration data stored in the shared memory to obtain the comparison result includes: Compare the version number corresponding to the first policy configuration data and the version number corresponding to the second policy configuration data to obtain the comparison result.
4. The method according to claim 1, wherein The determining, according to the comparison result, whether to update the second policy configuration data based on the first policy configuration data includes: In response to determining that the comparison result indicates that the first policy configuration data is updated data subsequent to the second policy configuration data in the shared memory, the second policy configuration data in the shared memory is updated based on the first policy configuration data.
5. The method according to claim 4, wherein The updating of the second policy configuration data in the shared memory based on the first policy configuration data includes: Based on the first policy configuration data, the shared variables related to the second policy configuration data in the shared memory are updated.
6. The method according to claim 1, wherein Before obtaining the comparison result of comparing the first policy configuration data preset in the database and the second policy configuration data stored in the shared memory, the method further includes: In response to determining that the gateway layer loads the policy configuration data for the first time, synchronizing the policy configuration data set in the database to the shared memory; Synchronize the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory.
7. The method according to claim 1, wherein Before obtaining the comparison result of comparing the first policy configuration data preset in the database and the second policy configuration data stored in the shared memory, the method further includes: generating the first policy configuration data based on the received configuration operation; The first policy configuration data is stored in a distributed relational database.
8. The method according to claim 7, wherein: The generating the first policy configuration data based on the received configuration operation includes: Based on the configuration operation, generating rule configuration data and indication data representing hierarchical release of the rule configuration data in a service device providing a target service, wherein the rule configuration data is used to represent a processing logic rule for a network request; The first policy configuration data is obtained by combining the rule configuration data and the indication data.
9. The method according to any one of claims 1 to 8, wherein Also includes: The gateway layer loads the first policy configuration data to process the received network request.
10. A synchronization device for configuring a policy, comprising: A comparison unit is configured to compare first policy configuration data preset in a database with second policy configuration data stored in a shared memory to obtain a comparison result, including: for a service device providing a target service, determining whether the first policy configuration data is policy configuration data related to the service device; in response to determining that it is, comparing the first policy configuration data preset in the database with the second policy configuration data stored in the shared memory to obtain the comparison result, wherein the policy configuration data is used to characterize a processing logic rule for a target service device that receives a network request for the network request, so as to guide the target service device in processing the network request to obtain a business processing result, and the first policy configuration data is policy configuration data that is released in a hierarchical manner, and the network request is distributed to the target service device in the distributed cluster after load balancing processing; a determining unit configured to determine, according to the comparison result, whether to update the second policy configuration data based on the first policy configuration data; The loading unit is configured to, in response to determining that the second policy configuration data in the shared memory is updated to the first policy configuration data, load the first policy configuration data in the shared memory through the gateway layer.
11. The device according to claim 10, wherein The comparison unit is further configured to: The first policy configuration data preset in the database is determined by adopting an asynchronous loading method based on a random clock; and the first policy configuration data preset in the database is compared with the second policy configuration data stored in the shared memory to obtain the comparison result.
12. The device according to claim 10, wherein The comparison unit is further configured to: Compare the version number corresponding to the first policy configuration data and the version number corresponding to the second policy configuration data to obtain the comparison result.
13. The device according to claim 10, wherein The determining unit is further configured to: In response to determining that the comparison result indicates that the first policy configuration data is updated data subsequent to the second policy configuration data in the shared memory, the second policy configuration data in the shared memory is updated based on the first policy configuration data.
14. The device according to claim 13, wherein The determining unit is further configured to: Based on the first policy configuration data, the shared variables related to the second policy configuration data in the shared memory are updated.
15. The device according to claim 10, wherein Also includes: The first loading unit is configured to: before obtaining a comparison result between the first policy configuration data pre-set in the comparison database and the second policy configuration data stored in the shared memory, in response to determining that the gateway layer is loading the policy configuration data for the first time, synchronize the policy configuration data set in the database to the shared memory; Synchronize the version number corresponding to the policy configuration data in the database and the version number corresponding to the policy configuration data in the shared memory.
16. The device according to claim 10, wherein Also includes: The configuration unit is configured to: generate the first policy configuration data based on the received configuration operation before obtaining the comparison result of the first policy configuration data pre-set in the comparison database and the second policy configuration data stored in the shared memory; and store the first policy configuration data in a distributed relational database.
17. The device according to claim 16, wherein The configuration unit is further configured to: Based on the configuration operation, rule configuration data and indication data representing the hierarchical release of the rule configuration data in the service device providing the target service are generated, wherein the rule configuration data is used to represent the processing logic rules for network requests; the first policy configuration data is obtained by combining the rule configuration data and the indication data.
18. The device according to any one of claims 10 to 17, wherein Also includes: The processing unit is configured to process the received network request by loading the gateway layer of the first policy configuration data.
19. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
20. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9.
21. A computer program product comprising: A computer program which, when executed by a processor, implements the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Dynamic load balancing method and device
CN112929408A