Service data synchronization method and device
By introducing a business data synchronization method between the client and the server, and synchronizing data using incremental interfaces, the performance degradation and crash problems caused by a large number of requests during batch update of data is solved, and more efficient data synchronization and system stability are achieved.
Patent Information
- Application Number
- CN202411686888.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-03-25
AI Technical Summary
When the system performs batch updates of data, the client may trigger a large number of requests to send to the server, resulting in untimely processing on the server, the interface response time becomes longer, performance is degraded, and even system crashes or denial of service.
By introducing a business data synchronization method between the client and the server, the client sends a acquisition request to the server to obtain interface configuration information. Based on this information and the configuration information recorded by the client, it determines whether the calling conditions of the incremental interface are met. If so, the incremental interface synchronization data is called.
This method effectively avoids the burden on the server by excessive requests, reduces unnecessary data transmission, speeds up data synchronization, reduces the risk of system crashes and denial of service, and improves user experience and system performance.
Smart Images

Figure CN119697012A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing, and in particular to a method and device for synchronizing business data. Background Art
[0002] When the system performs batch data updates, the client may trigger a large number of requests to be sent to the server, causing the server to be unable to process these requests in a timely manner, resulting in longer interface response time and reduced performance, which in turn causes system crashes and denial of service, and even affects user experience. Therefore, effective technical solutions are urgently needed to solve these problems in order to improve the overall performance of the system and user satisfaction. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a business data synchronization method and device for solving the problems of delayed processing, prolonged interface response time, and reduced system performance when a large number of requests are triggered.
[0004] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions: In a first aspect, an embodiment of the present application provides a service data synchronization method, which is applied to a client and includes: Sending a first acquisition request to a server, where the first acquisition request is used to acquire interface configuration information of the server; Receive first interface configuration information returned by the server, where the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; Determining whether a calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information including a version identifier of the second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client.
[0005] In a second aspect, an embodiment of the present application provides a service data synchronization method, which is applied to a server and includes: Receive a first acquisition request sent by a client, where the first acquisition request is used to acquire interface configuration information of the server; In response to the first acquisition request, returning first interface configuration information to the client, the first interface configuration information including: the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server received the first acquisition request; In response to the client's call request for the incremental interface, the incremental data of the first business data relative to the second business data stored by the client is synchronized to the client. The call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0006] In a third aspect, an embodiment of the present application provides a service data synchronization device, applied to a client, including: A sending unit, configured to send a first acquisition request to a server, wherein the first acquisition request is used to acquire interface configuration information of the server; A receiving unit, configured to receive first interface configuration information returned by the server, wherein the first interface configuration information includes: a state of an incremental interface of the server, a version identifier of first business data stored by the server, and a time point at which the server receives the first acquisition request; a determining unit, configured to determine whether a calling condition of the incremental interface is met based on the first interface configuration information and second interface configuration information recorded by the client, wherein the second interface configuration information includes a version identifier of second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; A synchronization unit is used to, if yes, call the incremental interface to synchronize incremental data of the first business data relative to the second business data to the client.
[0007] In a fourth aspect, an embodiment of the present application provides a service data synchronization device, which is applied to a server, including: A receiving unit, configured to receive a first acquisition request sent by a client, wherein the first acquisition request is used to acquire interface configuration information of the server; A first response unit, configured to return first interface configuration information to the client in response to the first acquisition request, wherein the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; A second response unit is used to synchronize the incremental data of the first business data relative to the second business data stored by the client to the client in response to the client's call request for the incremental interface, the call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request, and the second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0008] In a fifth aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method described in the first aspect or the second aspect.
[0009] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method described in the first aspect or the second aspect.
[0010] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: by sending a first acquisition request to the server, the interface configuration information of the server is acquired, and according to the first interface configuration information returned by the server and the second interface configuration information stored by the client, it is determined whether the calling condition of the incremental interface is met, and if so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client, wherein the first interface configuration information includes the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request, the second interface configuration information includes the version identifier of the second business data stored by the client, and the time point when the server receives the second acquisition request, and the second acquisition request is the acquisition request sent to the server before the first acquisition request. Transmission through the incremental interface can reduce unnecessary data transmission to speed up data synchronization. By introducing interface configuration information and calling condition determination, the client only calls the incremental interface when specific conditions are met, thereby avoiding the server burden caused by excessive requests. In addition to determining whether the status of the incremental interface is available, it is also necessary to determine whether the calling conditions of the incremental interface are met based on the comparison results of the time point and the version identifier, combined with the previous request synchronization situation. This can effectively avoid triggering a large number of requests to be sent to the server, ensure the processing efficiency and response speed of the server, and effectively reduce the risk of system crashes and denial of service caused by a surge in requests, thereby improving user experience and improving the overall performance and reliability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 One of the flowcharts of a business data synchronization method provided by an embodiment of the present application; Figure 2 A second flowchart of a method for synchronizing business data provided by an embodiment of the present application; Figure 3 A schematic diagram of an application scenario of a business data synchronization method provided by an embodiment of the present application; Figure 4 One of the structural schematic diagrams of a service data synchronization device provided by an embodiment of the present application; Figure 5 A second structural diagram of a service data synchronization device provided by an embodiment of the present application; Figure 6 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0012] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0013] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this way can be interchanged where appropriate so that the embodiments of the present application are implemented in a sequence other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.
[0014] When the system performs batch data updates, the client may trigger a large number of requests to be sent to the server, causing the server to be unable to process these requests in a timely manner, resulting in longer response time and lower performance of the interface, which in turn may cause system crashes and denial of service, and even affect user experience.
[0015] In view of this, an embodiment of the present application provides a business data synchronization method, which obtains the interface configuration information of the server by sending a first acquisition request to the server, and determines whether the calling condition of the incremental interface is met according to the first interface configuration information returned by the server and the second interface configuration information stored by the client. If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client, wherein the first interface configuration information includes the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request, the second interface configuration information includes the version identifier of the second business data stored by the client, and the time point when the server receives the second acquisition request, and the second acquisition request is the acquisition request sent to the server before the first acquisition request. Transmitting through the incremental interface can reduce unnecessary data transmission to speed up data synchronization. By introducing interface configuration information and calling condition determination, the client only calls the incremental interface when specific conditions are met, thereby avoiding the server burden caused by excessive requests. In addition to determining whether the status of the incremental interface is available, it is also necessary to determine whether the calling conditions of the incremental interface are met based on the comparison results of the time point and the version identifier, combined with the previous request synchronization situation. This can effectively avoid triggering a large number of requests to be sent to the server, ensure the processing efficiency and response speed of the server, and effectively reduce the risk of system crashes and denial of service caused by a surge in requests, thereby improving user experience and improving the overall performance and reliability of the system.
[0016] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0017] See also Figure 1 , is a flow chart of a business data synchronization method provided by an embodiment of the present application. Figure 1 As shown, an embodiment of the present application provides a service data synchronization method, which is applied to a client. The method may include the following steps: S102: Send a first acquisition request to the server.
[0018] The first acquisition request is used to obtain the interface configuration information of the server. The interface configuration information is information used to describe the characteristics, status, parameters, functions, types, etc. of the interface. As an example, the interface configuration information includes the type of interface, the status of the interface, etc. The type of the interface indicates the type of the interface. As an example, the types of interfaces include incremental interfaces and full interfaces. The status of the interface indicates the operating status of the interface, such as busy, under maintenance, available, etc. Whether the interface can be used can be determined based on the status of the interface. As an example, the status of the interface includes two status representations, 0 and 1, and the status of the interface can be represented by loadAllDataOnOff. "loadAllDataOnOff: 0" means that the interface is busy or under maintenance, that is, the interface is unavailable. "loadAllDataOnOff: 1" means that the interface is not very busy or is not transmitting data, that is, the interface is available.
[0019] In an embodiment of the present application, before the client calls an interface each time, it is necessary to first obtain the interface configuration information of the server, and determine whether the interface to be called is available based on the interface configuration information, such as the type of interface, the status of the interface, etc. After determining that the interface is available, it sends an interface call request to the server to avoid untimely interface response and affect the user experience.
[0020] The server is a computer system or application that provides corresponding data, services or resources. For example, in an online shopping website, the server can be a server that hosts product information, user data and transaction processing.
[0021] As an example, the above S102 can be implemented through an HTTP GET request.
[0022] As an example, the above S102 may also be implemented through an AJAX (Asynchronous JavaScript and XML) request.
[0023] The embodiment of the present application shows some implementation methods of the above S102. Of course, it should be understood that the above S102 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0024] S104, receiving the first interface configuration information returned by the server.
[0025] The first interface configuration information includes the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request.
[0026] The incremental interface is used to transmit incremental data. The incremental interface status includes two states: 0 and 1. When the status is 0, it means that the interface is unavailable. When the status is 1, it means that the interface is available.
[0027] The version identifier is a unique identifier used to identify the data version, which can be represented by loadAllDataVersion. For example, a user information table may generate a new version identifier after being updated, such as changing from "loadAllDataVersion: v1.0" to "loadAllDataVersion: v1.1". According to the version identifier, the business data stored by the server at various stages can be determined. In an embodiment of the present application, the first business data is the business data currently stored by the server, and the version identifier of the first business data is the latest version identifier stored by the server. As an example, the business data stored by the server can be pulled from the data source. Each time the server pulls data, it will update the version identifier accordingly. By comparing the version identifiers before and after the update, it can determine the business data of the server before and after the update, as well as the incremental data after the update relative to before the update.
[0028] Each time the server receives a request from the client, it records the time of receiving the request, expressed as loadAllDataTimeHours, and carries it in the interface configuration information, returning the time point, version identifier, and interface status to the client. The time point refers to a specific moment, for example: "loadAllDataTimeHours: 2024-10-25 10:15:30".
[0029] In an embodiment of the present application, before the client calls the incremental interface each time, it is necessary to first obtain the interface configuration information of the server. According to the first interface configuration information returned by the server, the first interface information includes the status of the incremental interface of the server, the version identifier of the first business data stored on the server, and the time point when the server receives the first acquisition request, and then determine whether the incremental interface of the server can be called. After determining that the incremental interface is available, the incremental interface call request is sent to the server to avoid untimely response of the incremental interface and affect the user experience.
[0030] As an example, the above S106 can be implemented through an HTTP GET request.
[0031] As another example, the above S106 can be implemented through real-time communication (WebSocket).
[0032] The embodiment of the present application shows some implementation methods of the above S106. Of course, it should be understood that the above S106 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0033] S106: Determine whether a calling condition of an incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client.
[0034] The second interface configuration information includes a version identifier of the second business data stored in the client and a time point when the server receives a second acquisition request, where the second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0035] A client is an application or device that requests data or services from a server. For example, in a mobile application, a client can be a user's mobile app that sends a request to obtain data or submit information.
[0036] The second business data is the business data currently stored in the client, and the version identifier of the second business data is the latest version identifier stored in the client.
[0037] In the embodiment of the present application, after receiving the first interface configuration information returned by the server, the client can obtain the second interface configuration information by querying the client locally. If the query finds that the client has the second interface configuration information stored, it determines whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information. If the second interface configuration information is not found, it means that the client has not been initialized, and the full interface is directly called to synchronize the first business data of the server to the client, and the client's local is initialized according to the obtained first business data, completing the first update and data synchronization.
[0038] In an embodiment of the present application, after receiving the first interface configuration information returned by the server, the client can first determine whether the status of the incremental interface is an available status. If it is an available status, it can then determine whether the calling conditions of the incremental interface are met based on the version identifier and time point in the first interface configuration information and the version identifier and time point in the second interface configuration information. After determining that the corresponding calling conditions are met; if it is an unavailable status, stop calling the incremental interface.
[0039] As an optional implementation, the above 106 may include the following steps: if the state of the incremental interface is an available state, comparing the version identifier of the first service data with the version identifier of the second service data to obtain a first comparison result; Compare the duration between the time point of the first acquisition request and the time point of the second acquisition request with a preset duration range to obtain a second comparison result; Based on the first comparison result and the second comparison result, it is determined whether a calling condition of the incremental interface is met.
[0040] The above-mentioned comparison of the version identifier of the first business data and the version identifier of the second business data to obtain the first comparison result may include the following steps: determining whether the version identifier of the first business data and the version identifier of the second business data are the same, thereby obtaining the first comparison result. The first comparison result includes two situations: one is that the version identifier of the first business data and the version identifier of the second business data are the same, and the other is that the version identifier of the first business data and the version identifier of the second business data are different. If they are the same, it means that the second business data stored in the client is the same as the business data stored in the server, and the data on the server has not been updated since the last synchronization. If they are not the same, it means that the second business data stored in the client is different from the business data stored in the server, and the data on the server has been updated since the last synchronization. By comparing the version identifiers of the first business data and the second business data, it is ensured that synchronization is triggered only when the data has actually changed.
[0041] The above-mentioned comparison of the duration between the time point of the first acquisition request and the time point of the second acquisition request with the preset duration range to obtain the second comparison result may include the following steps: subtracting the time point of the first acquisition request from the time point of the second acquisition request to obtain the duration between the time point of the first acquisition request and the time point of the second acquisition request, determining whether the obtained duration satisfies the preset duration range, and then obtaining the second comparison result. The second comparison result includes two situations: one is that the duration satisfies the preset duration range, and the other is that the duration does not satisfy the preset duration range. When the duration is within the preset duration range, it is satisfied; when the duration is not within the preset duration range, it is not satisfied. By comparing the differences in the time points of the requests, it is ensured that the synchronization operation will not be too frequent.
[0042] The above-mentioned determination of whether the calling condition of the incremental interface is met based on the first comparison result and the second comparison result may specifically include the following steps: if the first comparison result indicates that the version identifier of the first business data and the version identifier of the second business data are different, and the second comparison result indicates that the duration meets the preset duration range, then it is determined that the calling condition of the incremental interface is met. By comparing the version identifiers of the first business data and the second business data, and by comparing the difference in the time points of the requests, excessive calls to the incremental interface can be effectively avoided, ensuring efficient use of system resources.
[0043] The embodiment of the present application introduces the status of the incremental interface, the business data version identifier, and the comparison of the time point to accurately determine whether the conditions for calling the incremental interface are met, which can avoid frequent and unnecessary synchronization requests from the client, thereby reducing the pressure on the server and preventing performance degradation or system crashes due to too many requests. By comparing the version identifiers of the first business data and the second business data, it is ensured that synchronization is triggered only when the data has actually changed, and by comparing the difference in the time points of the requests, it is ensured that the synchronization operation is not too frequent, which can effectively avoid excessive calls to the incremental interface and ensure the efficient use of system resources, thereby improving response speed and system stability, as well as user experience.
[0044] As an optional implementation, the above-mentioned determination of whether the calling conditions of the incremental interface are met based on the first comparison result and the second comparison result may specifically include the following steps: if the version identifier of the first business data and the version identifier of the second business data are different, and the duration between the time point of the first acquisition request and the time point of the second acquisition request is within a preset duration range, then it is determined that the calling conditions of the incremental interface are met.
[0045] In an embodiment of the present application, when the state of the incremental interface is an available state, and the version identifier of the first business data is different from the version identifier of the second business data, and the duration between the time point of the first acquisition request and the time point of the second acquisition request is within a preset duration range, it is determined that the calling conditions of the incremental interface are met, and then the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client.
[0046] The embodiment of the present application compares the version identifiers of the first business data and the second business data, and at the same time compares the difference in the time points of the requests. When the version identifiers of the first business data and the second business data are different, and the time between the time points of the two requests is within the preset time range, the condition for calling the incremental interface is met, which can ensure that incremental data synchronization is performed only when the data actually changes and the request interval is reasonable, thereby avoiding frequent and invalid synchronization operations, effectively reducing the system burden caused by too many requests, alleviating the pressure on the server, improving the response speed, and avoiding the risk of performance degradation and system crash. At the same time, by setting a reasonable range for the time interval, it is possible to avoid repeated synchronization of the same data in a short period of time, improve the utilization efficiency of system resources, ensure the stability and reliability of the system in high-concurrency scenarios, and thus improve the user experience and overall system performance.
[0047] In the embodiment of the present application, when the state of the incremental interface is available, if the version identifier of the first business data and the version identifier of the second business data are different, and the duration between the time point of the first acquisition request and the time point of the second acquisition request is within the preset duration range, it is determined that the calling condition of the incremental interface is met; if the version identifier of the first business data and the version identifier of the second business data are the same, it is determined that the calling condition of the incremental interface is not met, and the full interface can be called; if the duration between the time point of the first acquisition request and the time point of the second acquisition request is not within the preset duration range, it is determined that the calling condition of the incremental interface is not met, and the full interface can be called. The first business data is synchronized from the server to the client by calling the full interface.
[0048] As another optional implementation, after the above S106, the following step may also be included: when the calling condition of the incremental interface is not met, calling the full interface to synchronize the first business data to the client.
[0049] When calling the full interface, the server may send a call request for the full interface to the server. After receiving the call request, the server returns the first business data to the client. The client updates the client locally according to the received business data to achieve data synchronization between the server and the client.
[0050] The full data interface is used to transmit full data. Full data includes the business data newly added compared to the last update and all the existing data at the time of the last update.
[0051] Based on the incremental data synchronization mechanism, the embodiment of the present application adds a method of synchronizing data using a full interface when the incremental interface call conditions are not met. This can effectively deal with scenarios where data cannot be synchronized through the incremental interface, ensuring that data can be synchronized to the client in a timely and complete manner, thereby avoiding data inconsistencies between the client and the server. Under certain conditions, such as large data changes or long time intervals, incremental synchronization may not be able to meet the needs. At this time, full synchronization is used to ensure data integrity and consistency, and will not cause client data lags or errors, allowing the system to find a balance between performance and data integrity, avoiding excessive full synchronization causing excessive burden on the server, and ensuring that the synchronization operation is completed smoothly when incremental synchronization is not feasible, avoiding system crashes and reduced user experience, thereby improving the flexibility and robustness of the system, optimizing the overall performance of the system, ensuring that data can be effectively synchronized in a variety of situations, and enhancing system reliability and user satisfaction.
[0052] As an optional implementation, after the above S106, the following steps may also be included: updating the version identifier of the second service data stored in the client to the version identifier of the first service data; The time point of the second acquisition request stored by the client is updated to the time point of the first acquisition request.
[0053] In the embodiment of the present application, if the state of the incremental interface is unavailable, the incremental interface should be stopped from being called. At this time, no interface will be called to obtain any data and the client's local will be updated. In this case, there is no need to configure the second interface stored in the client according to the first interface configuration information obtained. If the state of the incremental interface is available, based on the comparison result of the version identifier and the comparison result of the time point, it is determined whether the calling conditions of the incremental interface are met, and then it is determined whether to call the incremental interface or the full interface. Regardless of which interface is called, the client's local will be updated. In this case, the second interface configuration information stored in the client needs to be updated according to the first interface configuration information obtained. Specifically, the version identifier of the second business data stored in the client is updated to the version identifier of the first business data, and the time point of the second acquisition request stored in the client is updated to the time point of the first acquisition request.
[0054] The embodiment of the present application updates the version identification and time point information stored by the client after completing data synchronization, ensuring that the client can timely update the second business data version identification and requested time point stored by it after each synchronization, so that it is consistent with the data status of the server, and can avoid repeated data synchronization operations and unnecessary incremental interface calls. At the same time, by ensuring the consistency of the status recorded by the client with the server data, redundant requests and invalid synchronization caused by data inconsistency are avoided, and the efficiency of the system is improved. When the incremental interface call conditions are met, updating the version identification and time point of the client can effectively prevent the repeated processing of the synchronized data at the next synchronization, reduce the frequency of requests and the burden on the server, and thus improve the overall performance of the system, avoid performance bottlenecks caused by excessive synchronization, avoid data confusion caused by state lag or asynchrony, ensure the stability and reliability of the system, and thus improve the user experience.
[0055] S108: If yes, call the incremental interface to synchronize the incremental data of the first business data relative to the second business data to the client.
[0056] Incremental data refers to the business data that is newly added relative to the last update. Business data refers to business-related data, which is related to specific business scenarios. As an example, the business scenario can be a communication scenario, and the business data can be the communication data of each user, such as: user ID, name, mobile phone number, email, address, etc. The business data synchronization method proposed in the embodiment of the present application is applicable to various scenarios that require data synchronization, and the present application does not make specific limitations on this.
[0057] As an optional implementation, the above S108 may specifically include the following steps: when the calling conditions of the incremental interface are met, a calling request of the incremental interface may be sent to the server, and incremental data returned by the server is received, where the incremental data is incremental data of the first business data relative to the second business data; based on the incremental data returned by the server, the client's local data is updated, thereby achieving data synchronization between the server and the client.
[0058] As an example, the incremental interface call request carries a version identifier of the second business data stored by the client. The above S108 may specifically include the following steps: when the call conditions of the incremental interface are met, the version identifier of the second business data stored by the client may be carried in the call request of the incremental interface and sent to the server, and the incremental data returned by the server is received, and the client's local data is updated, thereby achieving data synchronization between the server and the client. After the server receives the call request of the incremental interface, it can compare the version identifier carried in the incremental interface call request with the latest version identifier stored by the server, determine the incremental data of the first business data relative to the second business data, and then return the determined incremental data to the client. The specific determination method will be further described in subsequent embodiments.
[0059] The embodiment of the present application obtains the interface configuration information of the server by sending a first acquisition request to the server, and determines whether the calling condition of the incremental interface is met based on the first interface configuration information returned by the server and the second interface configuration information stored by the client. If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client, wherein the first interface configuration information includes the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request, the second interface configuration information includes the version identifier of the second business data stored by the client, and the time point when the server receives the second acquisition request, and the second acquisition request is the acquisition request sent to the server before the first acquisition request. Transmission through the incremental interface can reduce unnecessary data transmission to speed up data synchronization. By introducing interface configuration information and calling condition determination, the client only calls the incremental interface when specific conditions are met, thereby avoiding the server burden caused by excessive requests. In addition to determining whether the status of the incremental interface is available, it is also necessary to determine whether the calling conditions of the incremental interface are met based on the comparison results of the time point and the version identifier, combined with the previous request synchronization situation. This can effectively avoid triggering a large number of requests to be sent to the server, ensure the processing efficiency and response speed of the server, and effectively reduce the risk of system crashes and denial of service caused by a surge in requests, thereby improving user experience and improving the overall performance and reliability of the system.
[0060] In an embodiment of the present application, when the client and the server synchronize business data, the client preferentially calls the incremental interface and obtains the interface configuration information of the server before calling the incremental interface, and then obtains relevant data such as version identification, time difference, and interface status, and then compares it with the interface configuration information stored locally on the client to determine whether the calling conditions of the incremental interface are met. If so, the incremental interface call request is sent to the server to pull the business data of the server, which can reduce redundant calls and data loading.
[0061] In the embodiment of the present application, when the client loads business data from the local computer and displays it in the user interface, upon receiving a clear request, the necessary business data will be loaded synchronously. The request is triggered by the user through the user operation interface. For example, in a communication scenario, when the user is viewing other users' address books, the user's own address book list will also be loaded. If detailed data or more data needs to be displayed, asynchronous loading is used to avoid blocking the user interface.
[0062] In the embodiment of the present application, when the client loads business data from the local computer and displays it in the user interface, a block loading method is adopted, first displaying a part of the business data, and then loading the remaining business data when receiving a request triggered by the user. For example, in a communication scenario, when the user scrolls to the bottom of the address book list, more data is loaded. This can reduce the loading time, improve the user experience, reduce the number of local database accesses, and increase the data loading speed.
[0063] In an embodiment of the present application, for business data frequently accessed by users, the client can also use cache technology such as Redis to store it locally.
[0064] See also Figure 2 , is a flow chart of a business data synchronization method provided by an embodiment of the present application. Figure 2 As shown, an embodiment of the present application provides a business data synchronization method, which is applied to a server. The method may include the following steps: S202: Receive a first acquisition request sent by a client.
[0065] The first acquisition request is used to obtain the interface configuration information of the server. The interface configuration information is information used to describe the characteristics, status, parameters, functions, types, etc. of the interface. For details, please refer to the specific embodiments of the client side, which will not be repeated here.
[0066] In the embodiment of the present application, before calling the incremental interface each time, the client needs to send a request to the server. After receiving the request, the server returns the interface configuration information to the client, thereby realizing data synchronization between the server and the client. By setting the pre-judgment of the incremental interface, the client is prevented from directly sending a call request to the server, and a large number of requests from the server are prevented from piling up, causing the system to crash.
[0067] As an example, the above S202 can be implemented through an HTTP GET request.
[0068] As another example, the above S202 can be implemented through real-time communication (WebSocket).
[0069] The embodiment of the present application shows some implementation methods of the above S202. Of course, it should be understood that the above S202 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0070] S204: Return the first interface configuration information to the client in response to the first acquisition request.
[0071] The first interface configuration information includes the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request.
[0072] The incremental interface is an interface for transmitting incremental data. For details, please refer to the specific embodiment of the client side, which will not be repeated here.
[0073] The version identifier is a unique identifier used to identify the data version. For details, please refer to the specific implementation example of the client side, which will not be repeated here.
[0074] A time point refers to a specific moment. Each time the server receives a request from the client, it records the time point of receiving the request and carries it in the interface configuration information, and returns the time point, version identifier, and interface status to the client. For details, please refer to the specific implementation example on the client side, which will not be repeated here.
[0075] In an embodiment of the present application, before each call to the incremental interface by the client, it is necessary to first send a request for acquisition to the server. The server receives the request for acquisition and records the time point, and returns the interface configuration information to the client based on the recorded time point, the state of the incremental interface of the server, and the version identifier of the first business data stored by the server. The client receives and determines whether the calling conditions of the incremental interface are met based on the interface configuration information, and if so, sends a call request for the incremental interface to the server. After receiving the call request for the incremental interface, the server returns the incremental data to the client, thereby realizing data synchronization between the server and the client.
[0076] As an example, the above S204 can be implemented through an HTTP GET request.
[0077] As an example, the above S204 may also be implemented through an AJAX (Asynchronous JavaScript and XML) request.
[0078] The embodiment of the present application shows some implementation methods of the above S204. Of course, it should be understood that the above S204 can also be implemented in other ways, and the embodiment of the present application does not limit this.
[0079] S206 , in response to the client's call request for the incremental interface, synchronizing incremental data of the first business data relative to the second business data stored in the client to the client.
[0080] The call request is sent by the client when it determines to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0081] In an embodiment of the present application, after the server returns the first interface configuration information to the client, the client determines whether the calling conditions of the incremental interface are met based on the received first interface configuration information and the second interface configuration information stored by the client. For details, please refer to the method embodiment on the client side, which will not be repeated here. When the client confirms that the calling conditions of the incremental interface are met, it will send a call request for the incremental interface to the server. Based on the call request for the incremental interface received, the server returns the incremental data of the first business data relative to the second business data to the client to update the client's local data and achieve data synchronization between the server and the client.
[0082] The embodiment of the present application transmits through an incremental interface, which can reduce unnecessary data transmission to speed up data synchronization. When responding to a client acquisition request, the server provides detailed interface configuration information, including the status of the incremental interface, the version identifier of the business data, and the request time point, to ensure that the client can make data synchronization judgments based on accurate configuration information when making incremental interface calls. This not only avoids the client from initiating incremental synchronization requests when it is not necessary, but also ensures data consistency between the server and the client, and reduces redundant synchronization operations caused by data asynchrony. In addition, by accurately controlling the synchronization timing and conditions of incremental data, the performance bottleneck problem caused by frequent data requests in the system is avoided, thereby improving the response speed and resource utilization of the system. By optimizing the triggering conditions for data synchronization and the information exchange during the synchronization process, the stability and scalability of the system are enhanced, and the system performance and user experience are effectively improved while ensuring data consistency.
[0083] As an example, the call request of the incremental interface sent by the client carries the version identifier of the second business data. The above S206 may include the following steps: in response to the call request of the client for the incremental interface, the version identifier of the second business data carried in the call request is compared with the version identifier of the first business data, the incremental data of the first business data relative to the second business data stored by the client is determined, and the determined incremental data is returned to the client, so as to realize data synchronization between the server and the client.
[0084] As an optional implementation, in the case where the server includes multiple server nodes, the above S206 may include the following steps: responding to a call request from the client to the incremental interface, the call request carrying a version identifier of the second business data; Determine, based on a version identifier of the first business data and a version identifier of the second business data, identification information of incremental data of the first business data relative to the second business data; Determine a second target server node storing the incremental data based on a first index table corresponding to a version identifier of the first business data and a second index table corresponding to a version identifier of the second business data, wherein the first index table includes index information of the first business data, and the second index table includes index information of the second business data, and the index information of each business data is generated based on identification information of the business data and identification information of a server node storing the business data; Sending a query request to the second target server node, where the query request carries identification information of the incremental data; Receive the incremental data returned by the second target server node, and send the incremental data to the client.
[0085] In an embodiment of the present application, the process of processing the incremental interface call request of the client can be written into a program and encapsulated as a function, such as chinatower_calculate_shard_index. When business data needs to be queried, the corresponding business data is queried and returned to the client by calling this function.
[0086] A server node refers to each physical or virtual server involved in storing and processing data in a distributed system or multi-node architecture. Multiple server nodes on the server side are used to share the task of storing business data. As an example, each node may store different versions or different types of business data. By dividing different server nodes, the distribution of data storage and the scalability of the system can be improved.
[0087] Business data is information or data related to the business. For details, please refer to the method embodiment on the client side.
[0088] Identification information is information used to uniquely identify business data and server nodes. As an example, in a communication scenario, the identification information of business data can be a user ID. Of course, in a specific scenario, it can also be based on the needs of the business and the characteristics of the data, such as ID, timestamp, geographic location, etc. as identification information of the business data, which is not limited in the embodiments of the present application.
[0089] The index table is a data structure used by the server to store and search for business data. Each index table maps the identification information of the business data to the identification information of its corresponding storage server node. Through the index table, the server node storing specific business data can be quickly found, thereby improving the efficiency of the data synchronization process. In an embodiment of the present application, the first index table stores the index information of the first business data, and the second index table stores the index information of the second business data.
[0090] Index information is key information used to quickly locate and access business data, including the identification information of the business data and the identification information of the server node storing the business data. Through index information, the specific location of the stored data can be efficiently found, avoiding full scans and improving the speed of query and data synchronization.
[0091] When determining the identification information of the incremental data of the first business data relative to the second business data based on the version identification of the first business data and the version identification of the second business data, the incremental data of the first business data relative to the second business data can be determined by comparing the first index table corresponding to the version identification of the first business data and the second index table corresponding to the version identification of the second business data. Specifically, the identification information of each business data in the first index table is compared with the identification information of each business data in the second index table to determine the identification information of the incremental data. Then, according to the identification information of the incremental data, the server node corresponding to the storage of the incremental data, i.e., the second target server node, is queried in the first index table corresponding to the version identification of the first business data.
[0092] The query request is used to request the business data in the query server node. In an embodiment of the present application, the query request carries the identification information of the incremental data. When the server node receives the request, it can determine the specific data to be returned based on the identification information carried in the request. After determining the identification information of the incremental data and the second target server node storing the incremental data, the embodiment of the present application will carry the identification information of the incremental data in the query request and send it to the second target server node to execute the corresponding query request, thereby querying the incremental data and forwarding it to the client.
[0093] When there are multiple second target server nodes, you can wait for the query results of each server node to be returned, merge the data and then forward it to the client, or forward it according to the query results received in real time without waiting for all query results to be returned.
[0094] The embodiment of the present application optimizes the efficiency and accuracy of incremental data synchronization by introducing multiple server nodes and an incremental data query mechanism based on an index table, effectively utilizes a distributed architecture, and disperses the storage and processing of data among multiple server nodes. By finding the location of incremental data storage based on the version identification and index table of business data, full query and invalid data transmission are avoided, and query efficiency is improved. According to the version identification carried in the call request of the incremental interface initiated by the client, the incremental data that needs to be synchronized can be accurately identified, and the correct server node can be located through the index table, so that only the necessary incremental data is queried and synchronized, which not only reduces the load of the server node, but also accelerates the data synchronization process. In addition, the distributed storage and query method based on multiple server nodes can improve the scalability and flexibility of the system, effectively deal with the performance bottlenecks that may occur during large-scale data synchronization, and then reduce unnecessary data transmission while ensuring data consistency, improve the efficiency of data synchronization, enhance the response speed and reliability of the system, and thus improve the user experience.
[0095] As an optional implementation, when the server includes multiple server nodes, Figure 2 The business data synchronization method shown may also include the following steps: obtaining first business data from a data source; Performing a hash calculation on the identification information of the first service data to obtain a first hash value mapped to the first service data on a hash ring, where the hash ring is a virtual ring generated based on a fixed hash range; Compare the first hash value with a plurality of second hash values, where the plurality of second hash values are hash values mapped to the hash ring by a plurality of server nodes; Based on the comparison result, determining a first target server node; The first service data is written into the first target server node.
[0096] The data writing method in the embodiment of the present application can be written into a program and encapsulated as a function, such as chinatower_calculate_shard_index. When new business data needs to be written, this function is called to determine the server node to which the business data belongs, and then the data is written to the corresponding server node.
[0097] A data source refers to a system or component that provides raw business data. The data it provides may be collected in real time or stored historically.
[0098] As an example, the data source may be an office automation system portal, namely, an OA (Office Automation) portal, which is usually operated by an administrator to achieve unified management of business information and data.
[0099] Hash calculation is to map the input data into a fixed-length value through specific rules. This value is the hash value. As an example, it can be implemented through a specific hash function to map the input data into a fixed-length hash value. The hash range refers to the range of values that the hash function can map, usually a fixed value domain. For example, the output of the hash function may be an integer value of a fixed size, and the hash range defines the possible value range of these integers, such as: 0 to 2^32-1.
[0100] The hash ring is a virtual ring formed by arranging the hash values within the hash range in a ring structure. All server nodes and the first business data will be mapped to the hash ring, and the position of each server node and the first business data is determined by its hash value. In the hash ring, data or nodes with smaller hash values will be closer to the starting position of the ring, while larger hash values will be closer to the end of the ring. In an embodiment of the present application, by mapping the server nodes and the first business data to the hash ring, uniform distribution can be guaranteed and a good load balancing effect can be achieved.
[0101] As another optional manner, before comparing the first hash value with the plurality of second hash values, the method further includes: performing hash calculation on the identification information of each server node to obtain a second hash value mapped to the hash ring by the server node.
[0102] The above-mentioned determination of the first target server node based on the comparison result may include the following steps: first determine a second hash value that is smaller than the first hash value, recorded as the third hash value, and calculate the difference between the first hash value and each third hash value, and determine the server node corresponding to the third hash value with the smallest difference as the first target server node.
[0103] The embodiment of the present application realizes the distributed storage of business data on the server side through a sharding strategy based on hash calculation and combined with a distributed architecture. When the client pulls business data from the server, the server can perform query and other operations on multiple server nodes at the same time. If the server nodes involved in the multiple requests sent by the client are different, the server can also process these multiple requests simultaneously, thereby increasing the speed at which the server queries business data, thereby increasing the server's response speed to client requests. In addition, for large data sets, this sharded storage method can simplify data management tasks. For example, operations such as backup, recovery, and migration can be performed on a single shard or server node, rather than the entire data set, thereby reducing the complexity and time cost of the operation.
[0104] It should be understood that each server node includes a primary shard and a replica shard, each shard corresponds to a shard table, and the structure of the shard table includes multiple fields. The business data in the shard table corresponding to the primary shard is written based on the hash calculation, and the business data in the shard table corresponding to the replica shard is copied from other server nodes.
[0105] As an example, the above-mentioned writing the first business data into the first target server node includes: writing the first business data into the shard table corresponding to the main shard. For example: in the communication scenario, the fields included in the shard table include: user ID, name, mobile phone number, email, address, etc., and the communication data, such as Zhang San, etc., are written into the corresponding fields.
[0106] The embodiment of the present application realizes efficient and uniform distribution of business data among multiple server nodes by introducing the concept of hash ring. Business data is mapped to the hash ring by hash calculation, and the location of data storage is determined by comparing with the hash values of multiple server nodes, avoiding the problem of uneven load and data imbalance between server nodes. Especially when the number of servers changes, data migration and load balancing problems are more prominent. By introducing the hash ring, it is ensured that the mapping relationship between data and server nodes has a "ring" structure. When the nodes increase or decrease, only part of the data needs to be remapped without causing large-scale data migration, thereby reducing the complexity and cost of data migration. In addition, the implementation of the hash ring makes the storage of data more fault-tolerant and scalable. Even when the server node fails, the mapping relationship of other nodes in the hash ring can be quickly found to replace the node for data storage and access, thereby improving the reliability and performance of the system. By using the structural design of hash calculation and hash ring, the performance, reliability and scalability of the distributed system can be effectively improved, especially in an environment with large data volume and dynamic changes of server nodes, the effect is more obvious.
[0107] In the embodiment of the present application, the database used to store the business data book in each server node can use a Nosql database or a relational database. For frequently accessed business data, a cache technology such as Redis can also be used for storage.
[0108] The following uses a scenario of updating contact data as an example to illustrate the service data synchronization method provided in the embodiment of the present application, which should not be understood as limiting the method of the embodiment of the present application. Figure 3 , is a schematic diagram of the application scenario structure of a business data synchronization method provided by an embodiment of the present application, and the application scenario includes: a server, a client, and an OA portal. In the word scenario, business data refers to communication data, including information such as user ID, name, mobile phone number, email, address, etc. The OA portal serves as the data source of communication data. The server includes multiple server nodes. In this scenario, three server nodes are taken as an example to store communication data pulled from the OA portal. In order to ensure the consistency of communication data between the client and the server, the client obtains business data from the server to update the local communication data of the client. Specifically, the scenario will be further explained for the server and the client respectively.
[0109] Server side: Receive the business data pushed by the OA portal, and store the business data slices in each server node through routing calculation. Specifically include the following steps: Hash calculation is performed on the identification information of each business data, such as user ID, to obtain the hash value of each business data mapped to the hash ring, that is, the first hash value, and the hash ring is pre-generated. Determine the server node storing each business data according to the hash value of each business data. Before determining, the identification information of each server node must be hashed to obtain the hash value mapped to the hash ring of each server node, that is, the second hash value. When determining the server node storing each business data, by comparing the hash value of each business data with the hash value of each server node, find the second hash value on the hash ring that is closest to the hash value of the business data and less than the hash value of the business data, and then determine the server node storing the business data, that is, the first target server node. Through routing calculation, determine the business data contained in the primary slice of each server node. At the same time, each server node will also copy the business data in the primary slice of other server nodes to obtain a replicated slice, such as Figure 3 As shown, if a server node fails, the corresponding data can be obtained from other server nodes.
[0110] Client: The client triggers the update operation of the address book. It first obtains the interface configuration information of the server, determines whether the incremental interface meets the call conditions, and then determines whether to pull business data based on the judgment result. Specifically, it includes the following steps: The client sends a request to the server, that is, the first request.
[0111] The server receives the first acquisition request and returns the interface configuration information, namely the first interface configuration information, to the client. The first interface configuration information includes: the time when the server receives the first acquisition request, the service data stored by the server, namely the version identifier of the first service data, and the status of the incremental interface in the server.
[0112] The client receives the first interface configuration information and first determines whether the incremental interface in the server is in an available state. If not, the client stops calling the interface; if it is in an available state, the client checks whether the client has the interface configuration information saved locally, that is, the second interface configuration information.
[0113] If the client does not have the second interface configuration information locally, the client is initialized locally, the client obtains the first business data from the server by calling the full interface to update the client locally, and saves the first interface configuration information returned by the server locally.
[0114] After receiving the call request of the full interface, the server obtains the first business data from each server node and returns it to the client to initialize the local of the client.
[0115] If the client has saved the second interface configuration information, it determines whether the call condition of the incremental interface is met based on the first interface configuration information returned by the server and the second interface configuration information saved locally by the client. The second interface configuration information includes the business data stored by the client, that is, the version identifier of the second business data and the time point of the second acquisition request returned by the server, and the second acquisition request is sent before the first acquisition request.
[0116] If the version identifier of the first business data returned by the server is the same as the version identifier of the second business data saved by the client, or the duration between the time point of the first acquisition request returned by the server and the time point of the second acquisition request saved by the client is not within the preset duration range, it is determined that the call request of the incremental interface is not satisfied, and the full interface can be called to obtain the first business data stored in the server by sending a call request for the full interface to the server to update the client locally, and update the version identifier of the first business data returned by the server and the time point of the first acquisition request to the client locally.
[0117] After receiving the call request of the full interface, the server obtains the first business data from each server node and returns it to the client to update the local of the client.
[0118] If the version identifier returned by the server is different from the version identifier saved by the client, and the duration between the time point returned by the server and the time saved by the client is within the preset duration range, it is determined that the calling conditions of the incremental interface are met. Then, the version identifier of the second business data saved by the client is carried in the calling request of the incremental interface and sent to the server to obtain the incremental data to update the client locally, and the version identifier of the first business data returned by the server and the time point of the first acquisition request are updated to the client locally.
[0119] The server receives a call request for the incremental interface, determines the identification information of the incremental data based on the version identifier carried in the request and the version identifier of the first business data stored on the server, determines the server node storing the incremental data based on the identification information, that is, the second target server node, carries the identification information of the incremental data in a query request and sends it to the second target server node, and returns the incremental data returned by the second target server node to the client to update the client's local data.
[0120] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0121] With the above Figure 1 Corresponding to the service data synchronization method shown, the embodiment of the present application also proposes a service data synchronization device. Figure 4 , which is one of the structural diagrams of a business data synchronization device provided by an embodiment of the present application. The device is applied to a client, and the device 400 includes: a sending unit 410, a receiving unit 420, a determining unit 430, and a synchronization unit 440.
[0122] The sending unit 410 is used to send a first acquisition request to the server, where the first acquisition request is used to acquire interface configuration information of the server.
[0123] The receiving unit 420 is used to receive the first interface configuration information returned by the server, wherein the first interface configuration information includes: the status of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server receives the first acquisition request.
[0124] The determination unit 430 is used to determine whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information including the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request, the second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0125] The synchronization unit 440 is configured to, if yes, call the incremental interface to synchronize incremental data of the first business data relative to the second business data to the client.
[0126] Optionally, when determining whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the determining unit 430 may perform the following steps: if the state of the incremental interface is an available state, comparing the version identifier of the first business data with the version identifier of the second business data to obtain a first comparison result; Compare the duration between the time point of the first acquisition request and the time point of the second acquisition request with a preset duration range to obtain a second comparison result; Based on the first comparison result and the second comparison result, it is determined whether a calling condition of the incremental interface is met.
[0127] Optionally, when the determination unit 430 determines whether the calling condition of the incremental interface is met based on the first comparison result and the second comparison result, it can perform the following steps: if the version identifier of the first business data and the version identifier of the second business data are different, and the duration between the time point of the first acquisition request and the time point of the second acquisition request is within a preset duration range, it is determined that the calling condition of the incremental interface is met.
[0128] Optionally, the device 400 further includes: a calling unit; The calling unit is used to perform the following steps after the determination unit 430 determines whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client: if the calling condition of the incremental interface is not met, call the full interface to synchronize the first business data to the client.
[0129] Optionally, the apparatus 400 further includes: an updating unit; The updating unit is used to perform the following steps after the determining unit 430 determines whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client: updating the version identifier of the second business data stored by the client to the version identifier of the first business data; The time point of the second acquisition request stored by the client is updated to the time point of the first acquisition request.
[0130] Obviously, the service data synchronization device provided in the embodiment of the present application can be used as Figure 1 The execution subject of the business data synchronization method shown is, for example Figure 1 In the business data synchronization method shown in FIG. 1 , step S102 may be performed by Figure 4 The sending unit 410 in the service data synchronization device 400 shown in FIG. 1 is executed, and step S104 can be performed by Figure 4 The receiving unit 420 in the service data synchronization device 400 shown in FIG. 1 is executed, and step S106 can be performed by Figure 4 The determining unit 430 in the service data synchronization device 400 shown in FIG. 1 is executed, and step S108 can be performed by Figure 4 The synchronization unit 440 in the business data synchronization device 400 shown is executed.
[0131] With the above Figure 2 Corresponding to the service data synchronization method shown, the embodiment of the present application also proposes a service data synchronization device. Figure 5 , which is a second structural diagram of a business data synchronization device provided by an embodiment of the present application. The device is applied to the server, and the device 500 includes: a receiving unit 510, a first response unit 520, and a second response unit 530.
[0132] The receiving unit 510 is used to receive a first acquisition request sent by a client, where the first acquisition request is used to acquire interface configuration information of the server.
[0133] The first response unit 520 is used to return first interface configuration information to the client in response to the first acquisition request, and the first interface configuration information includes: the status of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server received the first acquisition request.
[0134] The second response unit 530 is used to synchronize the incremental data of the first business data relative to the second business data stored by the client to the client in response to the client's call request for the incremental interface. The call request is sent by the client when it determines to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0135] Optionally, in the case where the service end includes a plurality of server nodes, the apparatus 500 further includes: a writing unit; The writing unit is used to perform the following steps: obtaining the first business data from a data source; Performing a hash calculation on the identification information of the first service data to obtain a first hash value mapped to the first service data on a hash ring, where the hash ring is a virtual ring generated based on a fixed hash range; Compare the first hash value with a plurality of second hash values, where the plurality of second hash values are hash values mapped to the hash ring by the plurality of server nodes; Based on the comparison result, determining a first target server node; The first service data is written into the first target server node.
[0136] Optionally, in the case where the server includes multiple server nodes, the second response unit 530 may perform the following steps when synchronizing the incremental data of the first business data relative to the second business data stored in the client to the client in response to the client's call request for the incremental interface: responding to the client's call request for the incremental interface, the call request carrying a version identifier of the second business data; Determine, based on a version identifier of the first business data and a version identifier of the second business data, identification information of incremental data of the first business data relative to the second business data; Determine a second target server node storing the incremental data based on a first index table corresponding to the version identifier of the first business data and a second index table corresponding to the version identifier of the second business data, wherein the first index table includes index information of the first business data, and the second index table includes index information of the second business data, and the index information of each business data is generated based on the identification information of the business data and the identification information of the server node storing the business data; Sending a query request to the second target server node, wherein the query request carries identification information of the incremental data; Receive the incremental data returned by the second target server node, and send the incremental data to the client.
[0137] Obviously, the service data synchronization device provided in the embodiment of the present application can be used as Figure 2 The execution subject of the business data synchronization method shown is, for example Figure 2 In the business data synchronization method shown in FIG. 1 , step S202 may be performed by Figure 5 The receiving unit 510 in the service data synchronization device 500 shown in FIG. 1 is executed, and step S204 can be performed by Figure 5 The first response unit 520 in the service data synchronization device 500 shown in FIG. 1 is executed, and step S206 can be performed by Figure 5 The second responding unit 530 in the business data synchronization device 500 is shown to execute.
[0138] According to another embodiment of the present application, Figure 4 or Figure 5The various units in the business data synchronization device shown can be separately or completely combined into one or several other units to constitute, or one (some) of the units can be further divided into multiple functionally smaller units to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In actual applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the business data synchronization device may also include other units. In actual applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0139] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 1 or Figure 2 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 4 or Figure 5 The business data synchronization device shown in and the business data synchronization method of the embodiment of the present application are implemented. The computer program can be recorded on, for example, a computer-readable storage medium, and transferred to an electronic device through the computer-readable storage medium and run therein.
[0140] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 6 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0141] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0142] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0143] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: Sending a first acquisition request to a server, where the first acquisition request is used to acquire interface configuration information of the server; Receive first interface configuration information returned by the server, where the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; Determining whether a calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information including a version identifier of the second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client.
[0144] Alternatively, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations: Receive a first acquisition request sent by a client, where the first acquisition request is used to acquire interface configuration information of the server; In response to the first acquisition request, returning first interface configuration information to the client, the first interface configuration information including: the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server received the first acquisition request; In response to the client's call request for the incremental interface, the incremental data of the first business data relative to the second business data stored by the client is synchronized to the client. The call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0145] The above application Figure 4 or Figure 5 The method performed by the service data synchronization device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in software form. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0146] The electronic device may also perform Figure 1 or Figure 2 The method and the service data synchronization device are implemented in Figure 1 , Figure 2 , Figure 4 and Figure 5 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0147] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0148] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations: Sending a first acquisition request to a server, where the first acquisition request is used to acquire interface configuration information of the server; Receive first interface configuration information returned by the server, where the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; Determining whether a calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information including a version identifier of the second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client.
[0149] Alternatively, when the instruction is executed by a portable electronic device including a plurality of application programs, the portable electronic device may be enabled to execute Figure 2 The method of the embodiment shown is specifically used to perform the following operations: Receive a first acquisition request sent by a client, where the first acquisition request is used to acquire interface configuration information of the server; In response to the first acquisition request, returning first interface configuration information to the client, the first interface configuration information including: the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server received the first acquisition request; In response to the client's call request for the incremental interface, the incremental data of the first business data relative to the second business data stored by the client is synchronized to the client. The call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
[0150] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
[0151] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0152] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0153] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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 process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0154] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A method for synchronizing business data, characterized in that: Applied to the client, including: Sending a first acquisition request to a server, where the first acquisition request is used to acquire interface configuration information of the server; Receive first interface configuration information returned by the server, where the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; Determining whether a calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information including a version identifier of the second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; If so, the incremental interface is called to synchronize the incremental data of the first business data relative to the second business data to the client.
2. The method according to claim 1, characterized in that The determining whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client includes: If the state of the incremental interface is an available state, comparing the version identifier of the first service data with the version identifier of the second service data to obtain a first comparison result; Compare the duration between the time point of the first acquisition request and the time point of the second acquisition request with a preset duration range to obtain a second comparison result; Based on the first comparison result and the second comparison result, it is determined whether a calling condition of the incremental interface is met.
3. The method according to claim 2, characterized in that The determining whether a calling condition of the incremental interface is met based on the first comparison result and the second comparison result includes: If the version identifier of the first business data is different from the version identifier of the second business data, and the duration between the time point of the first acquisition request and the time point of the second acquisition request is within a preset duration range, it is determined that the calling condition of the incremental interface is met.
4. The method according to claim 1, characterized in that: After determining whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the method further includes: When the calling condition of the incremental interface is not met, the full interface is called to synchronize the first business data to the client.
5. The method according to any one of claims 1 to 4, characterized in that After determining whether the calling condition of the incremental interface is met based on the first interface configuration information and the second interface configuration information recorded by the client, the method further includes: Updating the version identifier of the second service data stored in the client to the version identifier of the first service data; The time point of the second acquisition request stored by the client is updated to the time point of the first acquisition request.
6. A method for synchronizing business data, characterized in that: Applied to the server, including: Receive a first acquisition request sent by a client, where the first acquisition request is used to acquire interface configuration information of the server; In response to the first acquisition request, returning first interface configuration information to the client, the first interface configuration information including: the state of the incremental interface of the server, the version identifier of the first business data stored by the server, and the time point when the server received the first acquisition request; In response to the client's call request for the incremental interface, the incremental data of the first business data relative to the second business data stored by the client is synchronized to the client. The call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client. The second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request. The second acquisition request is an acquisition request sent to the server before the first acquisition request.
7. The method according to claim 6, characterized in that The server includes multiple server nodes; The method further comprises: Acquire the first business data from a data source; Performing a hash calculation on the identification information of the first service data to obtain a first hash value mapped to the first service data on a hash ring, where the hash ring is a virtual ring generated based on a fixed hash range; Compare the first hash value with a plurality of second hash values, where the plurality of second hash values are hash values mapped to the hash ring by the plurality of server nodes; Based on the comparison result, determining a first target server node; The first service data is written into the first target server node.
8. The method according to claim 6, characterized in that The server includes multiple server nodes; The step of synchronizing incremental data of the first business data relative to second business data stored in the client to the client in response to the client's call request for the incremental interface includes: In response to a call request from the client to the incremental interface, the call request carries a version identifier of the second business data; Determine, based on a version identifier of the first business data and a version identifier of the second business data, identification information of incremental data of the first business data relative to the second business data; Determine a second target server node storing the incremental data based on a first index table corresponding to the version identifier of the first business data and a second index table corresponding to the version identifier of the second business data, wherein the first index table includes index information of the first business data, and the second index table includes index information of the second business data, and the index information of each business data is generated based on the identification information of the business data and the identification information of the server node storing the business data; Sending a query request to the second target server node, wherein the query request carries identification information of the incremental data; Receive the incremental data returned by the second target server node, and send the incremental data to the client.
9. A service data synchronization device, characterized in that: Applied to the client, including: A sending unit, configured to send a first acquisition request to a server, wherein the first acquisition request is used to acquire interface configuration information of the server; A receiving unit, configured to receive first interface configuration information returned by the server, wherein the first interface configuration information includes: a state of an incremental interface of the server, a version identifier of first business data stored by the server, and a time point at which the server receives the first acquisition request; a determining unit, configured to determine whether a calling condition of the incremental interface is met based on the first interface configuration information and second interface configuration information recorded by the client, wherein the second interface configuration information includes a version identifier of second business data stored by the client and a time point when the server receives a second acquisition request, the second acquisition request being an acquisition request sent to the server before the first acquisition request; A synchronization unit is used to, if yes, call the incremental interface to synchronize incremental data of the first business data relative to the second business data to the client.
10. A service data synchronization device, characterized in that: Applied to the server, including: A receiving unit, configured to receive a first acquisition request sent by a client, wherein the first acquisition request is used to acquire interface configuration information of the server; A first response unit, configured to return first interface configuration information to the client in response to the first acquisition request, wherein the first interface configuration information includes: a state of the incremental interface of the server, a version identifier of the first business data stored by the server, and a time point when the server receives the first acquisition request; A second response unit is used to synchronize the incremental data of the first business data relative to the second business data stored by the client to the client in response to the client's call request for the incremental interface, the call request is sent by the client when it is determined to call the incremental interface based on the first interface configuration information and the second interface configuration information recorded by the client, the second interface configuration information includes the version identifier of the second business data stored by the client and the time point when the server receives the second acquisition request, and the second acquisition request is an acquisition request sent to the server before the first acquisition request.
Citation Information
Cited By
Message processing method and device and storage medium
CN120935131A