A data synchronization system, method and device for microservice architecture
Through the collaborative cooperation of data synchronization services and data processing services in the microservice architecture, the data consistency problem in the microservice architecture is solved, efficient data synchronization and stability are achieved, and service coupling is reduced.
Patent Information
- Application Number
- CN202111370709.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-18
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2041-11-18
AI Technical Summary
In the microservice architecture, although the response performance of external data services is improved, it cannot meet the requirements of data consistency between multiple levels.
Through the collaboration of data synchronization service and data processing service, a synchronization request is sent to the data processing service every first preset time, the data is verified and data synchronization is performed when there is data to be updated, thereby reducing the coupling between services and improving data consistency.
It reduces the workload of data synchronization, reserves storage space, ensures data consistency, and can independently handle business when data processing services are abnormal, thereby improving system stability.
Smart Images

Figure CN114090688B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data transmission technology, and in particular to a data synchronization system, method, and device for a microservice architecture. Background Art
[0002] With the development of the Internet, the amount of business data has increased, and a single system cannot meet the data response performance requirements. At this time, the design of distributed applications and microservice architecture has emerged. In microservices, services at all levels need to be linked for business transmission and processing. The process of converting the original single-machine data service to a multi-level joint service involves the process of related data synchronization. The joint data support between the services has improved the performance of external data service responses, but cannot meet the requirements of data consistency between multiple levels.
[0003] Currently, no effective solution has been proposed to the above-mentioned problem of "improving the performance of external data service responses, but failing to meet the requirements of data consistency between multiple levels." Summary of the Invention
[0004] The present application provides a data synchronization system, method and device for a microservice architecture to solve the above-mentioned technical problem of "improving the performance of external data service response, but failing to meet the requirements of data consistency between multiple levels".
[0005] According to one aspect of an embodiment of the present application, the present application provides a data synchronization system of a microservice architecture, including: a data synchronization service, which is used to send a synchronization request to a data processing service every first preset time period, wherein the synchronization request carries first data stored in the data synchronization service, and the first data is used to be sent to the data processing service for verification, and the data processing service is used to provide services for the business; when the data processing service completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service; the data processing service is used to obtain the first data stored in the data synchronization service carried in the synchronization request when receiving the synchronization request from the data synchronization service; verify the first data with the second data in the data processing service, wherein the second data is data generated by the data processing service when providing services for the business; when the verification result is that there is data to be updated, the update information is returned to the data synchronization service, so that the data synchronization service synchronizes the data according to the update information.
[0006] According to another aspect of an embodiment of the present application, the present application provides a data synchronization method for a microservice architecture, which is applied to a data synchronization service, including: sending a synchronization request to a data processing service every first preset time period, wherein the synchronization request carries first data stored by the data synchronization service, and the first data is used to be sent to the data processing service for verification, and the data processing service is used to provide services for the business; when the data processing service completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service.
[0007] Optionally, before sending a synchronization request to the data processing service each time, the method also includes: calling a health check interface, which is an interface provided by the data processing service; obtaining a health check result of the data processing service through the health check interface; and sending a synchronization request to the data processing service when it is determined that the health check result indicates that the data processing service is in a healthy state.
[0008] Optionally, the method also includes: in the event of an abnormality in the data processing service, extracting locally stored service data, wherein the service data is the data stored during the previous data synchronization of the data processing service; linking to the target business interface, and providing services to the business based on the service data, wherein the target business interface is the interface called by the data processing service when providing services to the business.
[0009] According to another aspect of an embodiment of the present application, the present application provides a data synchronization method for a microservice architecture, which is applied to a data processing service, including: upon receiving a synchronization request from a data synchronization service, obtaining first data stored by the data synchronization service carried in the synchronization request; verifying the first data with second data in the data processing service, wherein the second data is data generated by the data processing service when providing services to the business; if the verification result is that there is data to be updated, returning update information to the data synchronization service so that the data synchronization service synchronizes data according to the update information.
[0010] Optionally, before obtaining the first data stored in the data synchronization service carried in the synchronization request, the method also includes performing a health check in the following manner: filtering out data packets in the third data that are on a whitelist corresponding to a pre-stored whitelist database to obtain a target data packet, wherein the third data is data generated by the data processing service in the process of providing the service, and the whitelist is used to record trusted data sources; determining a health check result of the target data packet; when the target data packet is in a first state, determining that the data processing service is in a healthy state; and when the target data packet is in a second state, determining that the data processing service is in an unhealthy state.
[0011] Optionally, verifying the first data with the second data in the data processing service includes: obtaining verification data of the first data and the second data, wherein the verification data includes at least one of a data identifier and a data checksum; and when the verification data of the first data and the second data are inconsistent, determining that the verification result is that there is data to be updated.
[0012] Optionally, the method further includes: adding at least one data processing service node for providing services for the business together with the data processing service.
[0013] According to another aspect of an embodiment of the present application, the present application provides a data synchronization device of a microservice architecture, which is applied to a data synchronization service, including: a sending module for sending a synchronization request to a data processing service every first preset time period, wherein the synchronization request carries first data stored by the data synchronization service, and the first data is used to be sent to the data processing service for verification, and the data processing service is used to provide services for the business; an update module for updating data according to the verification result when the data processing service completes the verification and returns the verification result, so as to maintain data synchronization with the data processing service.
[0014] According to another aspect of an embodiment of the present application, the present application provides a data synchronization device of a microservice architecture, which is applied to a data processing service, including: an acquisition module, which is used to obtain the first data stored in the data synchronization service carried in the synchronization request when a synchronization request of the data synchronization service is received; a verification module, which is used to verify the first data with the second data in the data processing service, wherein the second data is the data generated by the data processing service when providing services to the business; and a return module, which is used to return update information to the data synchronization service when the verification result is that there is data to be updated, so that the data synchronization service performs data synchronization according to the update information.
[0015] According to another aspect of an embodiment of the present application, the present application provides an electronic device, including a memory, a processor, a communication interface and a communication bus, wherein the memory stores a computer program that can be run on the processor, the memory and the processor communicate through the communication bus and the communication interface, and the steps of the above method are implemented when the processor executes the computer program.
[0016] According to another aspect of an embodiment of the present application, the present application also provides a computer-readable medium having a non-volatile program code executable by a processor, where the program code enables the processor to execute any of the above methods.
[0017] The technical solution of this application can be applied to recommendation technology to design the recommendation system architecture.
[0018] The above technical solution provided by the embodiment of the present application has the following advantages compared with the related art:
[0019] The present application provides a data synchronization system of a microservice architecture, comprising: a data synchronization service, configured to send a synchronization request to a data processing service at a first preset time interval, wherein the synchronization request carries first data stored in the data synchronization service, the first data is sent to the data processing service for verification, and the data processing service is configured to provide services for the business; when the data processing service completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service; the data processing service, configured to obtain the first data stored in the data synchronization service carried in the synchronization request upon receiving the synchronization request from the data synchronization service; verify the first data with the second data in the data processing service, wherein the second data is data generated when the data processing service provides services for the business; when the verification result shows that there is data to be updated, update information is returned to the data synchronization service so that the data synchronization service synchronizes data according to the update information. The present application solves the problem of data synchronization under a microserver architecture, and performs data synchronization through a data synchronization service and a data processing service, which not only reduces the coupling between the services but also improves the consistency of the data. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] Figure 1 A schematic diagram of a data synchronization system of an optional microservice architecture provided according to an embodiment of the present application;
[0023] Figure 2 A flowchart of an optional data synchronization service method provided according to an embodiment of the present application;
[0024] Figure 3 A flowchart of an optional data processing service method provided according to an embodiment of the present application;
[0025] Figure 4 A block diagram of an optional data synchronization service device provided according to an embodiment of the present application;
[0026] Figure 5 A block diagram of an optional data processing service provided according to an embodiment of the present application;
[0027] Figure 6 A schematic diagram of an optional electronic device structure provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0029] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of this application and have no specific meaning. Therefore, "module" and "component" can be used interchangeably.
[0030] In related technologies, microservices at all levels need to be linked for business transmission and processing. The process of converting the original single-machine data service to a multi-level joint service involves the process of relevant data synchronization. The joint provision of data support between services improves the performance of external data service responses, but cannot meet the requirements of data consistency between multiple levels.
[0031] In order to solve the problems mentioned in the background technology, according to one aspect of an embodiment of the present application, the present application provides a data synchronization system of a microservice architecture, including: a data synchronization service 11, for sending a synchronization request to a data processing service 12 every first preset time period, wherein the synchronization request carries first data stored in the data synchronization service 11, and the first data is used to be sent to the data processing service 12 for verification, and the data processing service 12 is used to provide services for the business; when the data processing service 12 completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service 12; the data processing service 12 is used to obtain the first data stored in the data synchronization service 11 carried in the synchronization request when receiving the synchronization request from the data synchronization service 11; verify the first data with the second data in the data processing service, wherein the second data is data generated when the data processing service 12 provides services for the business; when the verification result is that there is data to be updated, the update information is returned to the data synchronization service 11, so that the data synchronization service 11 synchronizes the data according to the update information.
[0032] Specifically, the microservice architecture includes a data synchronization service 11 and a data processing service 12. The data synchronization service 11 serves as the underlying data support and data processor, synchronizing and updating data from the data processing service 12. The data processing service 12 receives cached data generated when providing services to the business. Upon receiving a synchronization request from the data synchronization service 11, the data in the synchronization request is verified against its own cached data. If the verification indicates that there is data to be updated, the update information is sent to the data synchronization service 11. The data synchronization service 11 then updates its own data based on the update information to maintain data consistency with the data processing service 12.
[0033] This application uses the collaborative cooperation of the data processing service 12 and the data synchronization service 11. After the data processing service 12 generates new data during business processing, upon receiving the synchronization request from the data synchronization service 11, it verifies the overlapping parts of the new data and the local data of the data synchronization service 11, thereby extracting the data to be synchronized in the new data that is different from the local data of the data synchronization service 11, and sends it to the data synchronization service 11. In this way, the workload of obtaining the data to be updated through verification is less than the workload of directly synchronizing all the new data, reducing the workload of synchronizing redundant data, retaining a larger storage space, and being able to update the data every first preset time period, thereby ensuring the consistency of the data.
[0034] According to another aspect of the embodiment of the present application, Figure 2 As shown, this application provides a data synchronization method for a microservice architecture, which is applied to data synchronization services, including:
[0035] Step 111: Send a synchronization request to the data processing service at a first preset interval, wherein the synchronization request carries first data stored in the data synchronization service, and the first data is sent to the data processing service for verification, and the data processing service is used to provide services for the business;
[0036] Step 112: When the data processing service completes verification and returns a verification result, data is updated according to the verification result to maintain data synchronization with the data processing service.
[0037] In an embodiment of the present application, the data synchronization service serves as the storage entity for data synchronization and sends a synchronization request to the data processing service every first preset time period. The first preset time period can be set according to demand, for example, 10 seconds.
[0038] Specifically, the synchronization request carries the first data stored in the data synchronization service. The first data is local data stored in the data synchronization service and is sent to the data processing service for verification. The verification is performed by comparing it with new data generated by the data processing service in the process of providing services to the business.
[0039] Specifically, when the data processing service completes verification and returns a verification result, the data is updated based on the verification result to maintain data synchronization with the data processing service. If the verification result indicates that there is no data to be updated, the data synchronization service does not perform the operation. If the verification result indicates that there is data to be updated, the data synchronization service updates the data based on the specific update information.
[0040] As an optional embodiment, before sending a synchronization request to the data processing service each time, the method also includes: calling a health check interface, which is an interface provided by the data processing service; obtaining a health check result of the data processing service through the health check interface; and sending a synchronization request to the data processing service when it is determined that the health check result indicates that the data processing service is in a healthy state.
[0041] In an embodiment of the present application, before sending a synchronization request to the data processing service, the data synchronization service must first call the health check interface to obtain the health status of the data processing service. After confirming that the data processing service is in a healthy state, the synchronization request is sent to the data processing service. If it is confirmed that the data processing service is in an unhealthy state or the health status of the data processing service is uncertain, the synchronization request is not sent to the data processing service.
[0042] As an optional embodiment, the method also includes: in the event of an abnormality in the data processing service, extracting locally stored service data, wherein the service data is the data stored during the previous data synchronization of the data processing service; linking to the target business interface, and providing services to the business based on the service data, wherein the target business interface is the interface called by the data processing service when providing services to the business.
[0043] In the embodiment of the present application, the data synchronization service and the data processing service work together to complete the synchronization operation, and can also independently process business. In the event of an abnormality in the data processing service, the data synchronization service can replace the data processing service to process the business. The specific operations are: extracting the locally stored service data, which is the service data stored for the previous data synchronization of the data processing service, that is, the current latest data; linking to the target business interface, which is the interface called by the data processing service when providing services to the business, providing services to the business through the locally stored service data, and caching the new data generated in the process of providing services to the business.
[0044] Optionally, after the data processing service returns to normal, the data synchronization service disconnects the target business interface and continues to collaborate with the data processing service to perform data synchronization according to the synchronization method of this application.
[0045] In the embodiment of the present application, the data synchronization service can replace the data processing service to process related business when an abnormality occurs in the data processing service, maintain the normal operation of the system, solve the data fault problem in abnormal situations, reduce the coupling between services, and improve the stability of the system.
[0046] According to another aspect of the embodiment of the present application, Figure 3 As shown, this application provides a data synchronization method for a microservice architecture, which is applied to data processing services, including:
[0047] Step 121: upon receiving a synchronization request from a data synchronization service, obtaining first data stored in the data synchronization service and carried in the synchronization request;
[0048] Step 122 , verifying the first data with second data in the data processing service, wherein the second data is data generated when the data processing service provides services for the business;
[0049] Step 123: If the verification result shows that there is data to be updated, update information is returned to the data synchronization service, so that the data synchronization service performs data synchronization according to the update information.
[0050] Specifically, after obtaining the first data stored in the data synchronization service carried in the synchronization request in step 121, execute step 122 to verify the first data with the second data in the data processing service, where the second data is the data generated when the data processing service provides services for the business. Then execute step 123. If the verification result shows that there is data to be updated, return update information to the data synchronization service so that the data synchronization service synchronizes data according to the updated information.
[0051] Optionally, the update information includes update instructions and update data. The update instruction includes at least one operation of deletion or addition. For example, when the update information returned by the data processing service is addition (update instruction A) and data A (update data A), the operation of the data synchronization service is to add the content of data A to its own local storage; when the update information returned by the data processing service is deletion (update instruction B) and data B (update data B), the operation of the data synchronization service is to delete the content of data B in its own local storage; when the update information returned by the data processing service is deletion and addition (update instruction C) and data C (update data C), data C contains newly added data and deleted data respectively. At this time, the operation of the data synchronization service is to add the newly added data of data C to its own local storage and delete its corresponding deleted data.
[0052] As an optional embodiment, before obtaining the first data stored in the data synchronization service carried in the synchronization request, the method also includes performing a health check in the following manner: filtering out the data packets in the third data that are on the whitelist corresponding to the pre-stored whitelist database to obtain the target data packet, wherein the third data is the data generated by the data processing service in the process of providing the service, and the whitelist is used to record the trusted data source; determining the health check result of the target data packet; when the target data packet is in the first state, determining that the data processing service is in a healthy state; when the target data packet is in the second state, determining that the data processing service is in an unhealthy state.
[0053] Optionally, before obtaining the first data stored by the data synchronization service carried in the synchronization request, the data processing service needs to perform a health check.
[0054] Specifically, when processing business, the data processing service pre-stores the trusted data source in the database in advance. When performing a health check, the data packets in the third data corresponding to the whitelist database pre-stored are filtered out, and the target data packets outside the whitelist are obtained for inspection. The third data is the data generated by the data processing service when processing business.
[0055] Optionally, the state of the target data packet includes a first state and a second state. When the target data packet is in the first state, the data processing service is determined to be in a healthy state; when the target data packet is in the second state, the data processing service is determined to be in an unhealthy state. For example, the data processing service sends a request instruction to the target data source, and when the target data source returns a status code that is a target status code (e.g., 200), the target data packet is in the first state, and the data processing service is determined to be in a healthy state. When the target data source returns a status code that is not the target status code, the target data packet is in the second state, and the data processing service is determined to be in an unhealthy state.
[0056] As an optional embodiment, verifying the first data with the second data in the data processing service includes: obtaining verification data of the first data and the second data, wherein the verification data includes at least one of a data identifier and a data checksum; and when the verification data of the first data and the second data are inconsistent, determining that the verification result is that there is data to be updated.
[0057] Specifically, when the data processing service caches new data at regular intervals, it divides the new data into at least one data group and generates a data identifier and a checksum for each data group.
[0058] Optionally, the method for verifying the first data with the second data in the data processing service includes: obtaining verification data for the first data and the second data, wherein the verification data includes at least one of a data identifier and a data checksum. The verification data for the first data includes a first data identifier and a first checksum, and the verification data for the second data includes a second data identifier and a second checksum. The first data identifier is verified against the second data identifier, and the first checksum is verified against the second checksum to obtain a verification result.
[0059] Specifically, when the verification data of the first data and the second data are inconsistent, it is determined that the verification result is that there is data to be updated.
[0060] Optionally, the case where the verification data is inconsistent includes an inconsistency between the first data identifier and the second data identifier. The first data identifier of the first data and the second data identifier of the second data are verified. When the first data identifier and the second data identifier are inconsistent, it is determined that the verification data are inconsistent, and the verification result is determined to be that data to be updated exists; when the first data identifier and the second data identifier are consistent, it is determined that the verification data are consistent, and the verification result is determined to be that data to be updated does not exist.
[0061] Optionally, the case where the verification data is inconsistent includes the first checksum and the second checksum being inconsistent. The first checksum of the first data and the second checksum of the second data are verified. When the first checksum and the second checksum are inconsistent, it is determined that the verification data are inconsistent, and the verification result is determined to be that data to be updated exists; when the first checksum and the second checksum are consistent, it is determined that the verification data are consistent, and the verification result is determined to be that data to be updated does not exist.
[0062] Optionally, the case of inconsistent verification data includes an inconsistency between the first data identifier and the second data identifier or an inconsistency between the first checksum and the second checksum, and the verification result is determined to be the presence of data to be updated; if and only if the first data identifier is the same as the second data identifier and the first checksum is the same as the second checksum, the verification result is determined to be the absence of data to be updated. For example, the verification data of the first data is the data identifier a and the checksum b, and the verification data of the second data is the data identifier c and the checksum d. When either a is not equal to c or b is not equal to d, the verification result of the first and second data is determined to be the presence of data to be updated; when a is equal to c and b is equal to d, the verification result of the first and second data is determined to be the absence of data to be updated.
[0063] The embodiment of the present application determines whether there is data to be updated through the verification result before performing the synchronization operation. This targeted data synchronization reduces the redundant workload of directly synchronizing all data and effectively reduces the storage space occupied by data synchronization.
[0064] As an optional embodiment, the method further includes: adding at least one data processing service node for providing services for the business together with the data processing service.
[0065] Optionally, when the business volume of the data processing service increases, in order to reduce the impact on the processing of other businesses, at least one data processing service node is added horizontally through load balancing. The working principle of the data processing service node is the same as that of the data processing service, and is used to provide services for the business together with the data processing service.
[0066] The embodiment of the present application horizontally adds no less than one data processing service node, thereby ensuring normal synchronization of data while taking into account the processing of other services.
[0067] According to another aspect of the embodiments of the present application, the present application provides a data synchronization device of a microservice architecture, which is applied to a data synchronization service, including:
[0068] a sending module 41 configured to send a synchronization request to the data processing service at a first preset interval, wherein the synchronization request carries first data stored by the data synchronization service, the first data being sent to the data processing service for verification, and the data processing service being configured to provide services for the business;
[0069] The updating module 42 is configured to update data according to the verification result when the data processing service completes the verification and returns the verification result, so as to maintain data synchronization with the data processing service.
[0070] It should be noted that the sending module 41 in this embodiment can be used to execute step 111 in the embodiment of the present application, and the updating module 42 in this embodiment can be used to execute step 112 in the embodiment of the present application.
[0071] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. Figure 1 The system shown can be implemented by software or hardware.
[0072] Optionally, the data synchronization device of the microservice architecture is applied to the data synchronization service and also includes a calling module for calling the health check interface, which is an interface provided by the data processing service; obtaining the health check result of the data processing service through the health check interface; and sending a synchronization request to the data processing service when it is determined that the health check result indicates that the data processing service is in a healthy state.
[0073] Optionally, the data synchronization device of the microservice architecture is applied to the data synchronization service and also includes a processing module for extracting locally stored service data in the event of an abnormality in the data processing service, wherein the service data is the data stored in the previous data synchronization of the data processing service; linking to the target business interface and providing services to the business based on the service data, wherein the target business interface is the interface called by the data processing service when providing services to the business.
[0074] According to another aspect of the embodiments of the present application, the present application provides a data synchronization device of a microservice architecture, which is applied to data processing services, including:
[0075] An acquisition module 51 is configured to, upon receiving a synchronization request from a data synchronization service, acquire first data stored in the data synchronization service and carried in the synchronization request;
[0076] a verification module 52 for verifying the first data with second data in the data processing service, wherein the second data is data generated when the data processing service provides services for the business;
[0077] The return module 53 is configured to return update information to the data synchronization service when the verification result shows that there is data to be updated, so that the data synchronization service performs data synchronization according to the update information.
[0078] It should be noted that the acquisition module 51 in this embodiment can be used to execute step 121 in the embodiment of the present application, the verification module 52 in this embodiment can be used to execute step 122 in the embodiment of the present application, and the return module 53 in this embodiment can be used to execute step 123 in the embodiment of the present application.
[0079] It should be noted that the examples and application scenarios implemented by the above modules and corresponding steps are the same, but are not limited to the contents disclosed in the above embodiments. Figure 1 The system shown can be implemented by software or hardware.
[0080] Optionally, the verification module 52 is further used to obtain verification data of the first data and the second data, wherein the verification data includes at least one of a data identifier and a data checksum; when the verification data of the first data and the second data are inconsistent, the verification result is determined to be that there is data to be updated.
[0081] Optionally, the data synchronization device of the microservice architecture is applied to the data processing service and also includes a checking module for obtaining the first data stored in the data synchronization service carried in the synchronization request. The method also includes performing a health check in the following manner: filtering out the data packets in the third data that are on the whitelist corresponding to the pre-stored whitelist database to obtain the target data packet, wherein the third data is the data generated by the data processing service in the process of providing the service, and the whitelist is used to record the trusted data source; determining the health check result of the target data packet; when the target data packet is in the first state, determining that the data processing service is in a healthy state; when the target data packet is in the second state, determining that the data processing service is in an unhealthy state.
[0082] Optionally, the data synchronization device of the microservice architecture is applied to the data processing service and further includes an adding module for adding at least one data processing service node for providing services for the business together with the data processing service.
[0083] According to another aspect of the embodiment of the present application, Figure 6 As shown, the present application provides an electronic device, including a memory 61, a processor 62, a communication interface 63 and a communication bus 64. The memory 61 stores a computer program that can be run on the processor 62. The memory 61 and the processor 62 communicate through the communication bus 64 and the communication interface 63. When the processor 62 executes the computer program, the steps of the above method are implemented.
[0084] The memory and processor in the electronic device communicate via a communication bus and a communication interface. The communication bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The communication bus may be divided into an address bus, a data bus, a control bus, and the like.
[0085] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0086] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0087] According to another aspect of an embodiment of the present application, the present application also provides a computer-readable medium having a non-volatile program code executable by a processor, where the program code enables the processor to execute any of the above methods.
[0088] Optionally, in an embodiment of the present application, the computer-readable medium is configured to store program codes for the processor to execute the following steps:
[0089] The data synchronization service sends a synchronization request to the data processing service at a first preset interval, wherein the synchronization request carries first data stored by the data synchronization service, and the first data is sent to the data processing service for verification, and the data processing service is used to provide services for the business; when the data processing service completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service;
[0090] When the data processing service receives a synchronization request from the data synchronization service, it obtains the first data stored by the data synchronization service carried in the synchronization request; verifies the first data with the second data in the data processing service, where the second data is data generated by the data processing service when providing services to the business; and if the verification result shows that there is data to be updated, returns update information to the data synchronization service, so that the data synchronization service synchronizes data according to the updated information.
[0091] The present application provides a data synchronization system with a microservice architecture, including: a data synchronization service, which is used to send a synchronization request to a data processing service at a first preset time interval, wherein the synchronization request carries first data stored in the data synchronization service, the first data is used to be sent to the data processing service for verification, and the data processing service is used to provide services for the business; when the data processing service completes the verification and returns the verification result, the data is updated according to the verification result to maintain data synchronization with the data processing service; the data processing service is used to obtain the first data stored in the data synchronization service carried in the synchronization request when receiving the synchronization request from the data synchronization service; verify the first data with the second data in the data processing service, wherein the second data is the data generated when the data processing service provides services for the business; when the verification result shows that there is data to be updated, update information is returned to the data synchronization service, so that the data synchronization service synchronizes data according to the update information. The present application solves the problem of data synchronization under the microserver architecture, and performs data synchronization through the data synchronization service and the data processing service, which not only reduces the coupling between the services, but also improves the consistency of the data.
[0092] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment will not be described in detail here.
[0093] When implementing the embodiments of the present application, reference may be made to the above embodiments, which have corresponding technical effects.
[0094] It is understood that the embodiments described herein may be implemented using hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit may be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or a combination thereof.
[0095] For software implementation, the technology described herein can be implemented by a unit that performs the functions described herein. The software code can be stored in a memory and executed by a processor. The memory can be implemented in the processor or outside the processor.
[0096] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0097] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0098] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.
[0099] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0100] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0101] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application are essentially or partly contributed to the prior art or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard drive, a ROM, a RAM, a magnetic disk, or an optical disk. It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without further constraints, an element defined by the phrase "comprises a..." does not preclude the existence of additional identical elements in the process, method, article or apparatus that includes the element.
[0102] The foregoing is merely a list of specific embodiments of the present application, intended to enable those skilled in the art to understand or implement the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the broadest scope consistent with the principles and novel features of the present application.
Claims
1. A data synchronization system based on a microservice architecture, characterized in that: include: a data synchronization service configured to send synchronization requests to a data processing service at intervals of a first preset time, wherein the synchronization requests carry first data stored by the data synchronization service, the first data being sent to the data processing service for verification, the data processing service being configured to provide services for the business; and, when the data processing service completes the verification and returns a verification result, updating the data based on the verification result to maintain data synchronization with the data processing service; A data processing service is used to, upon receiving a synchronization request from a data synchronization service, obtain the first data stored by the data synchronization service carried in the synchronization request; verify the first data with the second data in the data processing service, wherein the second data is data generated when the data processing service provides services for the business; and if the verification result shows that there is data to be updated, return update information to the data synchronization service so that the data synchronization service synchronizes data according to the update information.
2. A data synchronization method for a microservice architecture applied to a data synchronization system of a microservice architecture as claimed in claim 1, applied to a data synchronization service, characterized in that: include: Sending a synchronization request to the data processing service every first preset time period, wherein the synchronization request carries first data stored by the data synchronization service, the first data being sent to the data processing service for verification, and the data processing service being used to provide services for the business; When the data processing service completes verification and returns a verification result, data is updated according to the verification result to maintain data synchronization with the data processing service.
3. The method according to claim 2, characterized in that Before sending the synchronization request to the data processing service each time, the method further includes: Calling a health check interface, where the health check interface is an interface provided by the data processing service; Obtaining the health check result of the data processing service through the health check interface; If it is determined that the health check result indicates that the data processing service is in a healthy state, the synchronization request is sent to the data processing service.
4. The method according to claim 2, characterized in that The method further comprises: In the event of an abnormality in the data processing service, extracting locally stored service data, wherein the service data is data stored in a previous data synchronization of the data processing service; Link to the target business interface and provide services for the business based on the service data, wherein the target business interface is the interface called when the data processing service provides services for the business.
5. A data synchronization method for a microservice architecture applied to a data synchronization system for a microservice architecture as claimed in claim 1, applied to data processing services, characterized in that: include: Upon receiving a synchronization request from a data synchronization service, obtaining first data stored by the data synchronization service and carried in the synchronization request; Verifying the first data with second data in the data processing service, wherein the second data is data generated when the data processing service provides services for the business; If the verification result shows that there is data to be updated, update information is returned to the data synchronization service, so that the data synchronization service performs data synchronization according to the update information.
6. The method according to claim 5, characterized in that Before obtaining the first data stored by the data synchronization service carried in the synchronization request, the method further includes performing a health check in the following manner: filtering out data packets on a whitelist corresponding to a pre-stored whitelist database from the third data to obtain a target data packet, wherein the third data is data generated by the data processing service in the process of providing the service, and the whitelist is used to record trusted data sources; Determining a health check result of the target data packet; When the target data packet is in the first state, determining that the data processing service is in a healthy state; When the target data packet is in the second state, it is determined that the data processing service is in an unhealthy state.
7. The method according to claim 5, characterized in that Verifying the first data with the second data in the data processing service includes: Acquire verification data of the first data and the second data, wherein the verification data includes at least one of a data identifier and a data checksum; In a case where the verification data of the first data and the second data are inconsistent, it is determined that the verification result is that data to be updated exists.
8. The method according to claim 5, characterized in that The method further comprises: Add at least one data processing service node to provide services for the business together with the data processing service.
9. A data synchronization device for a microservice architecture applied to a data synchronization system for a microservice architecture as claimed in claim 1, applied to a data synchronization service, characterized in that: include: a sending module, configured to send a synchronization request to the data processing service at a first preset time interval, wherein the synchronization request carries first data stored by the data synchronization service, the first data being sent to the data processing service for verification, and the data processing service being configured to provide services for the business; The update module is used to update the data according to the verification result when the data processing service completes the verification and returns the verification result, so as to maintain data synchronization with the data processing service.
10. A data synchronization device for a microservice architecture applied to a data synchronization system for a microservice architecture as claimed in claim 1, applied to data processing services, characterized in that: include: an acquisition module, configured to, upon receiving a synchronization request from a data synchronization service, acquire first data stored in the data synchronization service and carried in the synchronization request; a verification module, configured to verify the first data with second data in the data processing service, wherein the second data is data generated when the data processing service provides services for a business; The return module is used to return update information to the data synchronization service when the verification result shows that there is data to be updated, so that the data synchronization service performs data synchronization according to the update information.
11. An electronic device comprising a memory, a processor, a communication interface, and a communication bus, wherein the memory stores a computer program that can be run on the processor, and the memory and the processor communicate via the communication bus and the communication interface, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 2 to 4 or 5 to 8 are implemented.
12. A computer-readable medium having a non-volatile program code executable by a processor, characterized in that The program code enables the processor to execute the method according to any one of claims 2 to 4 or 5 to 8.
Citation Information
Patent Citations
Data synchronization method, module and system based on message queue and micro-service
CN111930529A
Data synchronization method, terminal equipment and computer readable storage medium
CN112328701A