Data synchronization method and device, electronic equipment and storage medium
By using a cache server and judging the device pressure value during the data synchronization process, the problems of excessive device pressure and excessive resource consumption are solved, and efficient and stable data synchronization is achieved.
Patent Information
- Application Number
- CN202411997337.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2044-12-31
AI Technical Summary
When the prior art realizes data synchronization, it leads to excessive equipment pressure and excessive resource consumption, affecting network stability and equipment service life.
The target synchronization request is obtained through the cache server, and judge whether to write the target synchronization data to the cache server based on the pressure value of the target device, reducing the direct interaction between the device and the synchronization server.
An efficient, stable and controllable data synchronization process is achieved, which significantly improves the efficiency and reliability of data synchronization, reduces equipment pressure and optimizes the use of service resources.
Smart Images

Figure CN119865507A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data synchronization, and in particular to a method, device, electronic device and storage medium for data synchronization. Background Art
[0002] In modern communication networks, wavelength division multiplexing technology has become a key means to achieve high-capacity data transmission. Especially in optical networks, box-type wavelength division multiplexing equipment, as a core component, needs to frequently synchronize data with the network management controller to ensure real-time monitoring of the network and smooth operation of the business.
[0003] However, traditional data synchronization technology mainly uses multi-threading to interact with devices. The multi-threaded synchronization method causes the device to frequently read and transmit data. Especially when the device processing power is limited or the network environment is unstable, the device may experience abnormalities due to excessive pressure, such as extended response time or even disconnection, affecting the stability of the network and the service life of the device. At the same time, too many threads of synchronization requests will cause a significant increase in the system resource consumption of the synchronization service, thereby causing service anomalies such as memory overflow and excessive CPU usage, affecting the normal operation of the synchronization service and the overall performance of the system. In addition, in high-concurrency scenarios, due to competition and waiting between threads, the efficiency of data synchronization is severely restricted, the synchronization delay is increased, and it cannot meet business needs with high real-time requirements.
[0004] To address the above problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a method, device, electronic device and storage medium for data synchronization, so as to at least solve the technical problems of the prior art that excessive pressure on the device and excessive consumption of resources are caused when implementing data synchronization.
[0006] According to one aspect of an embodiment of the present invention, a method for data synchronization is provided, including: obtaining a target synchronization request from a cache server, the target synchronization request being sent by the synchronization server to the cache server; obtaining a target pressure value of a target device; in response to the target pressure value being less than a preset threshold, writing target synchronization data to the cache server, wherein the target synchronization data is stored in the target device.
[0007] Optionally, obtaining a target synchronization request from a cache server includes: obtaining a judgment result of the synchronization server on a target health value of a target device; in response to the judgment result indicating that the target health value is less than a preset value, querying whether there is a target synchronization request in the cache server; in response to the existence of a target synchronization request in the cache server, obtaining the target synchronization request from the cache server.
[0008] Optionally, the data synchronization method further includes: in response to a judgment result indicating that the target health value is greater than or equal to a preset value, receiving a target synchronization request sent by a synchronization server.
[0009] Optionally, the data synchronization method further includes: in response to the target pressure value being greater than a preset threshold, performing cyclic detection on the target pressure value; in response to detecting that the target pressure value is less than the preset threshold, writing the target synchronization data to the cache server.
[0010] According to another aspect of an embodiment of the present invention, a method for data synchronization is also provided, including: obtaining a target health value of a target device; in response to the target health value being less than a preset value, sending a target synchronization request to a cache server; cyclically querying whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag; in response to the existence of target synchronization data in the cache server, performing a write operation on the target synchronization data.
[0011] Optionally, the data synchronization method further includes: in response to the target health value being greater than or equal to a preset value, sending a target synchronization request to the target device.
[0012] According to another aspect of an embodiment of the present invention, a data synchronization device is also provided, including: a first acquisition module, used to obtain a target synchronization request from a cache server, the target synchronization request is sent by the synchronization server to the cache server; a second acquisition module, used to obtain a target pressure value of a target device; a first writing module, used to write target synchronization data to the cache server in response to the target pressure value being less than a preset threshold, wherein the target synchronization data is stored in the target device.
[0013] Optionally, the first acquisition module also includes: obtaining the judgment result of the synchronization server on the target health value of the target device; in response to the judgment result indicating that the target health value is less than a preset value, querying whether there is a target synchronization request in the cache server; in response to the existence of the target synchronization request in the cache server, obtaining the target synchronization request from the cache server.
[0014] Optionally, the first acquisition module further includes: in response to the judgment result indicating that the target health value is greater than or equal to a preset value, receiving a target synchronization request sent by the synchronization server.
[0015] Optionally, the first writing module further includes: in response to the target pressure value being greater than a preset threshold, performing cyclic detection on the target pressure value; in response to detecting that the target pressure value is less than the preset threshold, writing the target synchronization data to the cache server.
[0016] According to another aspect of an embodiment of the present invention, a data synchronization device is also provided, including: a third acquisition module, used to obtain a target health value of a target device; a first sending module, used to send a target synchronization request to a cache server in response to the target health value being less than a preset value; a query module, used to cyclically query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag; and an execution module, used to perform a write operation on the target synchronization data in response to the existence of the target synchronization data in the cache server.
[0017] Optionally, the first sending module further includes: in response to the target health value being greater than or equal to a preset value, sending a target synchronization request to the target device.
[0018] According to another aspect of an embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any of the above data synchronization methods.
[0019] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute any of the above data synchronization methods when running on a computer or a processor.
[0020] In an embodiment of the present invention, a target synchronization request is obtained from a cache server, and the target synchronization request is sent from the synchronization server to the cache server; a target pressure value of a target device is obtained; in response to the target pressure value being less than a preset threshold, target synchronization data is written to the cache server, wherein the target synchronization data is stored in the target device. The present invention achieves the purpose of realizing an efficient, stable, and controllable data synchronization process by utilizing a cache server and judging the target pressure value of a target device, thereby achieving the technical effect of significantly improving the efficiency and reliability of data synchronization, reducing device pressure, and optimizing the use of service resources, thereby solving the technical problem of the prior art causing excessive device pressure and excessive resource consumption when realizing data synchronization. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0022] Figure 1 is a flowchart of a first data synchronization method according to one embodiment of the present invention;
[0023] Figure 2 is a flowchart of a second data synchronization method according to one embodiment of the present invention;
[0024] Figure 3 is a flowchart of a method for data synchronization according to one embodiment of the present invention;
[0025] Figure 4 is a structural block diagram of a first data synchronization device according to one embodiment of the present invention;
[0026] Figure 5 is a structural block diagram of a second data synchronization device according to one embodiment of the present invention. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0029] According to an embodiment of the present invention, an embodiment of a method for data synchronization is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system containing at least one set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] The method embodiment may also be performed in an electronic device, a similar control device or an electronic device including a memory and a processor. Taking an electronic device as an example, the electronic device may include one or more processors and a memory for storing data. Optionally, the electronic device may also include a communication device and a display device for communication functions. It will be understood by those skilled in the art that the above structural description is only illustrative and does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components than the above structural description, or have a configuration different from the above structural description.
[0031] The processor may include one or more processing units. For example, the processor may include a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microcontroller unit (MCU), a field-programmable gate array (FPGA), a neural-network processing unit (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, and other processing devices. Among them, different processing units may be independent components or integrated into one or more processors. In some instances, the electronic device may also include one or more processors.
[0032] The memory can be used to store computer programs, such as storing computer programs corresponding to the data synchronization method in the embodiment of the present invention. The processor implements the above-mentioned data synchronization method by running the computer program stored in the memory. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the electronic device via a grid. Examples of the above-mentioned grid include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0033] Figure 1 is a flow chart of a first data synchronization method according to one embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0034] Step S101, obtaining a target synchronization request from a cache server, wherein the target synchronization request is sent from the synchronization server to the cache server.
[0035] Specifically, the target device obtains the target synchronization request pre-sent by the synchronization server from the cache server periodically or when triggered by a specific event.
[0036] It should be noted that in the traditional data synchronization method, the synchronization server directly sends a request to the device, while the present application stores the request in the cache server, and the device selectively obtains the request information according to its own task requirements and pressure conditions. In the present application, the direct interaction between the synchronization server and the device is replaced by indirect processing by the cache server, which reduces the direct communication burden of the device and avoids excessive consumption of device resources due to frequent synchronization requests. At the same time, as an intermediate layer, the cache server can flexibly schedule and store synchronization requests according to the real-time status of the device and the overall resource status of the system, making data exchange more efficient and intelligent. Through the intervention of the cache server, even if the synchronization server or the network fails, the device can still obtain the request information from the cache server, ensuring the continuity and reliability of the data synchronization process.
[0037] Step S102, obtaining a target pressure value of a target device.
[0038] Specifically, before processing a synchronization request, the target device needs to evaluate its own status, that is, obtain a target stress value. This stress value includes but is not limited to the device's CPU usage, memory usage, network bandwidth usage, and device health status. The purpose of obtaining the target stress value of the target device is to ensure that the device does not suffer from performance degradation or abnormal behavior due to insufficient resources when processing a synchronization request.
[0039] Specifically, the device's built-in monitoring system regularly checks the device's operating status, including hardware resource usage and software operating status, to determine the stress value. The device will feed back the monitored stress value to the synchronization server or cache server in real time or periodically as a basis for subsequent data synchronization decisions.
[0040] Step S103, in response to the target pressure value being less than a preset threshold, writing the target synchronization data to the cache server, wherein the target synchronization data is stored in the target device.
[0041] Specifically, when the target device determines that its pressure value is less than a preset threshold, it indicates that the device currently has sufficient resources and can undertake the task of data synchronization. At this time, the device starts to collect the target synchronization data and writes it to the cache server instead of directly transmitting it to the synchronization server.
[0042] Specifically, when the device determines that resource conditions permit, it starts to asynchronously collect information that needs to be synchronized from the data source, which reduces the direct connection between data collection and transmission, allowing the device to complete data synchronization without affecting the currently running tasks.
[0043] Specifically, the target synchronization data is stored in the cache server instead of being directly transmitted to the synchronization server, which can alleviate the processing pressure of the synchronization server and improve the efficiency of data transmission.
[0044] Specifically, after the device completes writing data to the cache server, it sets a completion flag to inform the synchronization server that the data is ready and waiting for further processing by the synchronization service. This mechanism ensures the integrity and reliability of the data, and also avoids unnecessary operations of the synchronization server requesting the same data multiple times.
[0045] In an embodiment of the present invention, a target synchronization request is obtained from a cache server, and the target synchronization request is sent from the synchronization server to the cache server; a target pressure value of a target device is obtained; in response to the target pressure value being less than a preset threshold, target synchronization data is written to the cache server, wherein the target synchronization data is stored in the target device. The present invention achieves the purpose of realizing an efficient, stable, and controllable data synchronization process by utilizing a cache server and judging the target pressure value of a target device, thereby achieving the technical effect of significantly improving the efficiency and reliability of data synchronization, reducing device pressure, and optimizing the use of service resources, thereby solving the technical problem of the prior art causing excessive device pressure and excessive resource consumption when realizing data synchronization.
[0046] Optionally, in step S101, obtaining a target synchronization request from a cache server may include the following steps:
[0047] Step S201, obtaining the judgment result of the synchronization server on the target health value of the target device;
[0048] Specifically, the synchronization server continuously monitors the device status and collects the device's performance indicators and health data. The synchronization server comprehensively evaluates the health status of the target device based on the status information, operation logs, and historical performance data reported by the device, and obtains the judgment result of the target health value of the target device.
[0049] Specifically, the target health value is an important indicator to measure the current operating status of the device, reflecting the device's processing power, network connection status, and overall health status of the device. The acquisition of this judgment result can be active, such as the device regularly requests the health status from the synchronization server, or passive, that is, the synchronization server actively sends health status information to the device when it detects a change in the device status.
[0050] Specifically, the synchronization server conducts a comprehensive analysis of the collected data and calculates the target health value of the device based on a preset algorithm or model. This value can be dynamically adjusted to adapt to different device characteristics and network environments.
[0051] Step S202, in response to the judgment result indicating that the target health value is less than a preset value, querying whether there is a target synchronization request in the cache server;
[0052] Specifically, after receiving the health value judgment result, the device will make the next decision based on the result.
[0053] Specifically, if the judgment result shows that the target health value of the device is lower than the preset threshold, this usually means that the device is currently under high load or unstable state. Directly processing the synchronization request may increase the burden on the device or even cause device abnormality. Therefore, the device does not directly respond to the synchronization request, but turns to the cache server to query whether there is a pending synchronization request. The cache server serves as a storage and scheduling center for synchronization requests, where the device can query and obtain pending requests, avoiding the direct communication burden of the device under high pressure.
[0054] The above operations reduce the direct communication pressure of the device. By using the cache server as an intermediary, the device can flexibly choose whether to process the synchronization request and when to process the synchronization request according to its own status.
[0055] Step S203: in response to the existence of the target synchronization request in the cache server, obtaining the target synchronization request from the cache server.
[0056] Specifically, if there are target synchronization requests in the cache server, the target device will read and obtain these requests from the cache server and start the data synchronization process.
[0057] It should be noted that the device intelligently obtains synchronization requests from the cache server based on its own health status, rather than passively waiting for direct requests from the synchronization server, which makes the data synchronization process more flexible and efficient. At the same time, the cache server needs to ensure the integrity and timeliness of data updates so that the target device can obtain accurate and latest data when querying and obtaining synchronization requests.
[0058] In addition, the asynchronous processing mechanism allows the device to actively process synchronization requests in the cache when the pressure is low, avoiding data processing under high-pressure conditions, while ensuring the stability and reliability of data synchronization.
[0059] Optionally, the data synchronization method further includes: in response to a judgment result indicating that the target health value is greater than or equal to a preset value, receiving a target synchronization request sent by a synchronization server.
[0060] Specifically, if the evaluation result of the synchronization server indicates that the health value of the target device is greater than or equal to a preset value, this indicates that the device is currently in a good state and can effectively process the synchronization request.
[0061] Specifically, after confirming that the target device is in good condition, it will directly receive the synchronization request from the synchronization server and start the data collection and synchronization process according to the request content. This process includes but is not limited to data reading, formatting, data packet construction, and data uploading, and finally completes the processing of the synchronization request and returns a response to the synchronization server. When the device is in good health, this process can be carried out quickly and efficiently, thereby improving the overall speed of data synchronization and system performance.
[0062] Specifically, after the device completes the processing of the synchronization request, it will report the latest status information to the synchronization server, which will update the health value of the target device accordingly and provide the latest data support for subsequent synchronization request decisions. This mechanism ensures the real-time update of the device health value and provides a more accurate decision-making basis for subsequent data synchronization.
[0063] It is understandable that after confirming that the target device is in a stable and healthy state, the synchronization server will directly send the target synchronization request without passing through the cache server. Direct connection and data exchange reduce the intermediate links of data transmission, improve the real-time and efficiency of data synchronization, and also reduce the burden on the cache server and optimize the allocation of system resources.
[0064] It should be noted that the setting of preset values needs to comprehensively consider the processing capacity of the device and the resource requirements of the synchronization request, to ensure that when the device status is stable or the resources are sufficient, the synchronization request can be directly received to improve data synchronization efficiency.
[0065] Optionally, the data synchronization method further includes the following steps:
[0066] Step S301, in response to the target pressure value being greater than a preset threshold, performing cyclic detection on the target pressure value;
[0067] Specifically, when the pressure value of the target device, i.e., the target pressure value (such as CPU usage, memory usage, network bandwidth usage, etc.) exceeds a preset threshold, it indicates that the device is currently in a high-load state and may not be able to effectively process additional data synchronization tasks, and may even cause device failure. To avoid this situation, the present invention adopts a cyclic detection mechanism to continuously monitor the pressure value of the device until it falls back to a safe range.
[0068] Specifically, the built-in monitoring system of the target device or the external monitoring service continuously monitors the operating status of the target device, including the usage of hardware resources and the running status of software, to ensure that the pressure changes of the device can be discovered in time.
[0069] Specifically, once it is detected that the device pressure value exceeds the preset threshold, the system will immediately take measures to stop receiving new synchronization requests to avoid further overload of the device.
[0070] It should be noted that after the device enters a high-pressure state, the system will not stop data synchronization immediately, but will continue to monitor the pressure changes of the target device through a cyclic detection mechanism until it returns to below the preset threshold.
[0071] Step S302, in response to detecting that the target pressure value is less than a preset threshold, writing the target synchronization data to the cache server.
[0072] Specifically, when the cyclic detection mechanism confirms that the stress value of the device has dropped to a safe level, that is, less than the preset threshold, the target device starts to process the data synchronization task. However, in order to prevent the target device from being under excessive pressure again, the synchronization data is not sent directly to the synchronization server, but is first written to the cache server, which is then uniformly scheduled and managed by the cache server.
[0073] Specifically, the device uses the cache server as a temporary storage for data to avoid direct data exchange with the synchronization server under high-pressure conditions, thereby achieving reasonable allocation of resources and effective relief of pressure.
[0074] Specifically, when the data is written to the cache server, the working thread of the synchronization service will be awakened and start processing the data to achieve the final synchronization of the data into the database, thereby ensuring the integrity and timeliness of the data.
[0075] Specifically, data written to the cache server can be shared and processed by multiple worker threads, without relying on the direct response of a single synchronization service, thereby improving the stability and efficiency of data synchronization.
[0076] By adopting a cyclic detection mechanism when the device pressure value exceeds the preset threshold, and writing data to the cache server after the pressure value returns to a safe level, the device failure due to resource overload is effectively avoided, while ensuring the continuity and efficiency of data synchronization. This intelligent pressure management and data caching solution provides strong technical support for the stable operation and data synchronization of box-type wavelength division equipment in large-scale communication networks, and has important innovative significance and application value.
[0077] Figure 2 is a flow chart of a second data synchronization method according to one embodiment of the present invention. Figure 2 As shown, the method comprises the following steps:
[0078] Step S401, obtaining a target health value of a target device.
[0079] Specifically, the synchronization server continuously monitors the operating status of the target device, collects the real-time performance indicators of the device, such as CPU usage, memory usage, network latency, and abnormal report frequency, and calculates the target health value of the target device.
[0080] The acquisition of the target health value is based on the status information and operation logs reported by the device, as well as the comprehensive analysis of the synchronization server. The target health value can accurately reflect the actual operating status and carrying capacity of the device.
[0081] It should be noted that it is necessary to monitor and evaluate the target health status of the target device in real time to ensure that the data synchronization strategy can be flexibly adjusted according to the real-time health status of the device to avoid the device running under high pressure, thereby reducing the equipment failure rate.
[0082] Step S402, in response to the target health value being less than a preset value, sending a target synchronization request to a cache server.
[0083] Specifically, when the synchronization server detects that the health value of the target device is lower than the preset threshold, it indicates that the device may be under high pressure and it is not suitable to directly receive and process synchronization requests. In order to avoid increasing the burden on the device, the synchronization server sends the target synchronization request to the cache server instead of directly sending it to the target device.
[0084] By using the cache server as an intermediate link, it is possible to effectively avoid the device from directly processing synchronization requests under high-pressure conditions, reduce the device's immediate burden, and improve the overall stability and efficiency of the system.
[0085] It should be noted that the setting of the preset values is based on the understanding of the normal operating status of the equipment, ensuring that when the equipment is in poor health, appropriate measures can be taken to protect the stable operation of the equipment.
[0086] Step S403: cyclically query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag.
[0087] Specifically, after sending the target synchronization request to the cache server, the synchronization server will periodically or continuously query whether there is synchronization data uploaded by the target device in the cache server.
[0088] Specifically, during the query process, the target synchronization data is marked with a target synchronization flag so that the synchronization server can accurately identify and process it.
[0089] At the same time, the circular query mechanism ensures timely synchronization of data, avoids data backlog and loss, and also reduces the synchronization server's direct dependence on device status, improving the utilization efficiency of system resources.
[0090] Step S404: in response to the existence of the target synchronization data in the cache server, a write operation is performed on the target synchronization data.
[0091] Specifically, when the synchronization server detects the synchronization data uploaded by the target device from the cache server, it will immediately perform a write operation on the data and store it in the database of the synchronization service to complete the final synchronization of the data.
[0092] Specifically, the database write operation needs to ensure the integrity and consistency of the data, and also needs to process duplicate data to avoid data redundancy in the database.
[0093] Through timely data writing operations, the continuity and efficiency of data synchronization are ensured, and through the repeated data processing mechanism, the consistency and reliability of data are guaranteed.
[0094] The data synchronization method of the present invention intelligently schedules data synchronization requests to the cache server when the device is in a poor health state, then loops through the cache server to query whether there is synchronization data uploaded by the target device, and finally executes the data write operation, effectively avoiding direct data processing of the device under high pressure, reducing the immediate burden of the device, while ensuring the continuity and efficiency of data synchronization, achieving dynamic matching between the device health state and the data synchronization strategy, and improving the overall stability and efficiency of the system. This data synchronization scheme provides a more intelligent, efficient and stable data synchronization solution for box-type wavelength division equipment in large-scale communication networks, and has important technical value and application prospects.
[0095] Optionally, the data synchronization method further includes: in response to the target health value being greater than or equal to a preset value, sending a target synchronization request to the target device.
[0096] Specifically, when the health status evaluation result of the target device shows that its target health value meets the preset standard, the synchronization service will directly send a data synchronization request to the target device, skipping the transfer link of the cache server.
[0097] The advantages of this strategy are: direct communication reduces the intermediate links in data transmission, improves the real-time and response speed of data synchronization, and ensures that data can be quickly updated to the synchronization service; because the current state of the device is suitable for processing synchronization requests, direct communication avoids the additional scheduling of cache servers and the consumption of data storage resources, improves the efficiency of data synchronization, and reduces the waste of system resources; when the device is in good health, direct communication will not bring additional pressure to the device, which helps to maintain the stable operation of the device and extend the service life of the device.
[0098] Specifically, after receiving the synchronization request, the target device starts collecting and processing data according to the request content. After processing, the device returns the synchronization data directly to the synchronization service without the need for transfer through the cache server, further improving the efficiency and real-time performance of data transmission.
[0099] Figure 3 is a flowchart of a method for data synchronization according to one embodiment of the present invention. Figure 3 As shown in the figure, the specific steps to achieve data synchronization include:
[0100] The first step is to calculate the health value of the target device and use the health value to measure the actual operating status and carrying capacity of the device;
[0101] The second step is to compare the calculated health value of the target device with the preset health value. If the health value of the target device is greater than or equal to the preset health value, the target device is determined to be in a healthy state. If the health value of the target device is less than the preset health value, the target device is determined to be in an unhealthy state.
[0102] In the third step, if the target device is in a healthy state, the synchronization server directly sends the target synchronization request to the target device;
[0103] Step 4: If the target device is in an unhealthy state, the synchronization server adds the target synchronization request to the request queue and sends it to the cache server;
[0104] Step 5: The target device evaluates its own hardware resource usage and software running status to determine its target pressure value. If the current target pressure value is within a safe range, the target device actively obtains a synchronization request from the cache server and performs a synchronization operation.
[0105] Step 6: After the target data has processed the data that needs to be synchronized, it returns the synchronized data to the cache server;
[0106] In the seventh step, the synchronization server continuously queries the cache server whether there is synchronization data uploaded by the target device. When the synchronization server detects the synchronization data uploaded by the target device from the cache server, it wakes up the working thread, performs a write operation on the uploaded synchronization data, and stores it in the database of the synchronization service. The final synchronization of the data is completed, and the working thread enters the thread sleep state.
[0107] In the embodiments of the present invention, two data synchronization devices are also provided, which are used to implement the above embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0108] Figure 4 is a structural block diagram of a first data synchronization device 500 according to one embodiment of the present invention, such as Figure 4 As shown, the device includes: a first acquisition module 501, used to obtain a target synchronization request from a cache server, and the target synchronization request is sent from the synchronization server to the cache server; a second acquisition module 502, used to obtain a target pressure value of a target device; a first writing module 503, used to write target synchronization data to the cache server in response to the target pressure value being less than a preset threshold, wherein the target synchronization data is stored in the target device.
[0109] Optionally, the first acquisition module 501 is also used to: obtain the judgment result of the synchronization server on the target health value of the target device; in response to the judgment result indicating that the target health value is less than a preset value, query whether there is a target synchronization request in the cache server; in response to the existence of the target synchronization request in the cache server, obtain the target synchronization request from the cache server.
[0110] Optionally, the first acquisition module 501 is further used to: in response to the judgment result indicating that the target health value is greater than or equal to a preset value, receive a target synchronization request sent by the synchronization server.
[0111] Optionally, the first writing module 503 is further used to: in response to the target pressure value being greater than a preset threshold, perform cyclic detection on the target pressure value; in response to detecting that the target pressure value is less than the preset threshold, write the target synchronization data to the cache server.
[0112] Figure 5 is a structural block diagram of a second data synchronization device 600 according to one embodiment of the present invention. Figure 5 As shown, the device includes: a third acquisition module 601, used to obtain the target health value of the target device; a first sending module 602, used to send a target synchronization request to the cache server in response to the target health value being less than a preset value; a query module 603, used to cyclically query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag; an execution module 604, used to perform a write operation on the target synchronization data in response to the existence of the target synchronization data in the cache server.
[0113] Optionally, the first sending module 602 is further used to: in response to the target health value being greater than or equal to a preset value, send a target synchronization request to the target device.
[0114] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the data synchronization method described in any of the above embodiments.
[0115] Optionally, in this embodiment, the processor in the above electronic device may be configured to run a computer program to perform the following steps:
[0116] Step S101, obtaining a target synchronization request from a cache server, the target synchronization request is sent by the synchronization server to the cache server;
[0117] Step S102, obtaining a target pressure value of a target device;
[0118] Step S103, in response to the target pressure value being less than a preset threshold, writing the target synchronization data to the cache server, wherein the target synchronization data is stored in the target device.
[0119] Optionally, the processor in the above-mentioned electronic device can be configured to run a computer program to perform the following steps: obtain the judgment result of the synchronization server on the target health value of the target device; in response to the judgment result indicating that the target health value is less than a preset value, query whether there is a target synchronization request in the cache server; in response to the existence of the target synchronization request in the cache server, obtain the target synchronization request from the cache server.
[0120] Optionally, the processor in the above electronic device can be configured to run a computer program to perform the following steps: in response to a judgment result indicating that the target health value is greater than or equal to a preset value, receiving a target synchronization request sent by a synchronization server.
[0121] Optionally, the processor in the above electronic device can be configured to run a computer program to perform the following steps: in response to the target pressure value being greater than a preset threshold, performing cyclic detection on the target pressure value; in response to detecting that the target pressure value is less than a preset threshold, writing the target synchronization data to the cache server.
[0122] Optionally, in this embodiment, the processor in the above electronic device may be configured to run a computer program to perform the following steps:
[0123] Step S401, obtaining a target health value of a target device.
[0124] Step S402, in response to the target health value being less than a preset value, sending a target synchronization request to a cache server.
[0125] Step S403: cyclically query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag.
[0126] Step S404: in response to the existence of the target synchronization data in the cache server, a write operation is performed on the target synchronization data.
[0127] Optionally, the processor in the above electronic device can be configured to run a computer program to perform the following steps: in response to the target health value being greater than or equal to a preset value, sending a target synchronization request to the target device.
[0128] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the data synchronization method described in any of the above embodiments when running on a computer or a processor.
[0129] Optionally, in this embodiment, the above-mentioned computer program may be configured to store a computer program for performing the following steps:
[0130] Step S101, obtaining a target synchronization request from a cache server, the target synchronization request is sent by the synchronization server to the cache server;
[0131] Step S102, obtaining a target pressure value of a target device;
[0132] Step S103, in response to the target pressure value being less than a preset threshold, writing the target synchronization data to the cache server, wherein the target synchronization data is stored in the target device.
[0133] Optionally, the above-mentioned computer program can be configured to store a computer program for executing the following steps: obtaining the judgment result of the synchronization server on the target health value of the target device; in response to the judgment result indicating that the target health value is less than a preset value, querying whether there is a target synchronization request in the cache server; in response to the existence of the target synchronization request in the cache server, obtaining the target synchronization request from the cache server.
[0134] Optionally, the above-mentioned computer program may be configured to store a computer program for executing the following steps: in response to a judgment result indicating that the target health value is greater than or equal to a preset value, receiving a target synchronization request sent by a synchronization server.
[0135] Optionally, the above-mentioned computer program can be configured to store a computer program for executing the following steps: in response to the target pressure value being greater than a preset threshold, performing cyclic detection on the target pressure value; in response to detecting that the target pressure value is less than the preset threshold, writing the target synchronization data to the cache server.
[0136] Optionally, in this embodiment, the above-mentioned computer program may be configured to store a computer program for performing the following steps:
[0137] Step S401, obtaining a target health value of a target device.
[0138] Step S402, in response to the target health value being less than a preset value, sending a target synchronization request to a cache server.
[0139] Step S403: cyclically query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag.
[0140] Step S404: in response to the existence of the target synchronization data in the cache server, a write operation is performed on the target synchronization data.
[0141] Optionally, the computer program may be configured to store a computer program for executing the following steps: in response to a target health value being greater than or equal to a preset value, sending a target synchronization request to a target device.
[0142] Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0143] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0144] In some embodiments provided in the present application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0145] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0146] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0147] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server or a grid device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc., which can store program codes.
[0148] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for data synchronization, characterized in that: include: Obtaining a target synchronization request from the cache server, wherein the target synchronization request is sent by the synchronization server to the cache server; Get the target pressure value of the target device; In response to the target pressure value being less than a preset threshold, writing target synchronization data to the cache server, wherein the target synchronization data is stored in the target device.
2. The data synchronization method according to claim 1, characterized in that: Acquiring the target synchronization request from the cache server includes: Obtaining a determination result of the synchronization server on the target health value of the target device; In response to the judgment result indicating that the target health value is less than a preset value, querying whether the cache server has the target synchronization request; In response to the target synchronization request existing in the cache server, the target synchronization request is obtained from the cache server.
3. The data synchronization method according to claim 2, characterized in that: The method further comprises: In response to the judgment result indicating that the target health value is greater than or equal to the preset value, the target synchronization request sent by the synchronization server is received.
4. The method for data synchronization according to claim 1, characterized in that: The method further comprises: In response to the target pressure value being greater than the preset threshold, performing cyclic detection on the target pressure value; In response to detecting that the target pressure value is less than the preset threshold, the target synchronization data is written to the cache server.
5. A method for data synchronization, characterized in that: include: Get the target health value of the target device; In response to the target health value being less than a preset value, sending a target synchronization request to a cache server; Circularly query whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag; In response to the target synchronization data being stored in the cache server, a write operation is performed on the target synchronization data.
6. The method for data synchronization according to claim 5, characterized in that: The method further comprises: In response to the target health value being greater than or equal to the preset value, sending the target synchronization request to the target device.
7. A data synchronization device, characterized in that: include: A first acquisition module, configured to acquire a target synchronization request from a cache server, wherein the target synchronization request is sent from the synchronization server to the cache server; A second acquisition module is used to acquire a target pressure value of a target device; The first writing module is used for writing target synchronization data to the cache server in response to the target pressure value being less than a preset threshold, wherein the target synchronization data is stored in the target device.
8. A data synchronization device, characterized in that: include: The third acquisition module is used to obtain the target health value of the target device; A first sending module, configured to send a target synchronization request to a cache server in response to the target health value being less than a preset value; A query module, used for cyclically querying whether there is target synchronization data in the cache server, wherein the target synchronization data includes a target synchronization flag; The execution module is used for executing a write operation on the target synchronization data in response to the target synchronization data being stored in the cache server.
9. An electronic device, comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the data synchronization method described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program is configured to execute the data synchronization method described in any one of claims 1 to 6 when running on a computer or a processor.
Citation Information
Patent Citations
Distributed cache synchronization system and method
CN102333108A
Data synchronization system, method and device, equipment and storage medium
CN110765206A
Method and system for synchronizing data, and movable platform and readable storage medium
CN110809874A
Alarm information synchronization method and device, computer equipment and storage medium
CN111211925A
High-concurrency service request processing method and device, electronic equipment and storage medium
CN114244902A
Cited By
Request delivery control method, electronic equipment and storage medium
CN121309479A