CN117112576A - Data synchronization method and device, server and storage medium - Google Patents

Data synchronization method and device, server and storage medium Download PDF

Info

Publication number
CN117112576A
CN117112576A CN202210535862.9A CN202210535862A CN117112576A CN 117112576 A CN117112576 A CN 117112576A CN 202210535862 A CN202210535862 A CN 202210535862A CN 117112576 A CN117112576 A CN 117112576A
Authority
CN
China
Prior art keywords
memory data
client
server
data
target rule
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210535862.9A
Other languages
Chinese (zh)
Inventor
杨绪龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Rockwell Technology Co Ltd
Original Assignee
Beijing Rockwell Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Rockwell Technology Co Ltd filed Critical Beijing Rockwell Technology Co Ltd
Priority to CN202210535862.9A priority Critical patent/CN117112576A/en
Publication of CN117112576A publication Critical patent/CN117112576A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The disclosure relates to the field of interaction technology, and in particular, to a data synchronization method and device, a server and a storage medium. Wherein, a data synchronization method, this scheme is carried out by the server, the server is connected with customer machine communication; comprising the following steps: acquiring a heartbeat message sent by the client, wherein the heartbeat message comprises data generated by the client based on rules included in the client; acquiring first memory data corresponding to a client, wherein the first memory data comprises a target rule; and synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data. By adopting the method and the device, the accuracy and the reliability of data synchronization can be improved.

Description

Data synchronization method and device, server and storage medium
Technical Field
The disclosure relates to the field of interaction technology, and in particular, to a data synchronization method and device, a server and a storage medium.
Background
With the development of science and technology, various technologies are also developed more and more rapidly, and accordingly, the requirements of people on data transmission are also increasing. For example, in the related art, each client may initiate a corresponding service to listen for a server message. However, in this process, it is impossible to check whether the data between the client and the server are consistent, so that the data communication between the client and the server is inaccurate and unreliable.
Disclosure of Invention
The present disclosure provides a data synchronization method and apparatus, a server, and a storage medium, and is mainly aimed at improving accuracy and reliability of data synchronization.
According to an aspect of the present disclosure, there is provided a data synchronization method, the method being performed by a server, the server being communicatively connected to a client; comprising the following steps:
acquiring a heartbeat message sent by the client, wherein the heartbeat message comprises data generated by the client based on rules included in the client;
acquiring first memory data corresponding to the client, wherein the first memory data comprises a target rule;
and synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
Optionally, before the obtaining the first memory data corresponding to the client, the method further includes:
acquiring a target rule from a database every other preset time length;
encrypting the target rule to obtain first memory data corresponding to the target rule;
and storing the target rule and the first memory data.
Optionally, the storing the first memory data includes:
Acquiring second memory data, wherein the second memory data is stored before acquiring the target rule;
encrypting the target rule to obtain first memory data corresponding to the target rule;
storing the second memory data under the condition that the second memory data is consistent with the first memory data;
and storing the first memory data under the condition that the second memory data is inconsistent with the first memory data.
Optionally, when the second memory data is inconsistent with the first memory data, after storing the first memory data, the method further includes:
and synchronizing the first memory data to a server cluster so that at least one server in the server cluster acquires the first memory data.
Optionally, when the second memory data is inconsistent with the first memory data, after storing the first memory data, the method further includes:
and storing the first memory data by adopting a relational database.
Optionally, after the heartbeat message sent by the client is obtained, the method further includes:
and updating the heartbeat message to the non-relational database so that at least one server corresponding to the non-relational database acquires the heartbeat message.
According to another aspect of the present disclosure, there is provided a data synchronization apparatus including:
a message obtaining unit, configured to obtain a heartbeat message sent by the client, where the heartbeat message includes data generated by the client based on a rule included in the client;
the data acquisition unit is used for acquiring first memory data corresponding to the client, wherein the first memory data comprises a target rule;
and the rule transmission unit is used for synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
Optionally, the device further includes a rule obtaining unit, configured to obtain, before the obtaining of the first memory data corresponding to the client, a target rule from a database at intervals of a preset duration;
encrypting the target rule to obtain first memory data corresponding to the target rule;
and storing the target rule and the first memory data.
Optionally, the rule obtaining unit is configured to, when storing the first memory data, specifically:
acquiring second memory data, wherein the second memory data is stored before acquiring the target rule;
Encrypting the target rule to obtain first memory data corresponding to the target rule;
storing the second memory data under the condition that the second memory data is consistent with the first memory data;
and under the condition that the second memory data is inconsistent with the first memory data, replacing the second memory data with the first memory data.
Optionally, the apparatus further comprises a data synchronization unit, configured to, in case the second memory data is inconsistent with the first memory data, store the first memory data,
and synchronizing the first memory data to a server cluster so that at least one server in the server cluster acquires the first memory data.
Optionally, the apparatus further comprises a data storage unit, configured to, in case the second memory data is inconsistent with the first memory data, store the first memory data,
and storing the first memory data by adopting a relational database.
Optionally, the device further includes a message updating unit, configured to update the heartbeat message to a non-relational database after acquiring the heartbeat message sent by the client, so that at least one server corresponding to the non-relational database acquires the heartbeat message.
According to another aspect of the present disclosure, there is provided a server including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the preceding aspects.
According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method of any one of the preceding aspects.
According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the method of any one of the preceding aspects.
In one or more embodiments of the present disclosure, the scheme is performed by a server communicatively coupled to a client; the method comprises the steps that a heartbeat message sent by a client is obtained, wherein the heartbeat message comprises data generated by the client based on rules included in the client; acquiring first memory data corresponding to the client, wherein the first memory data comprises a target rule; and synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data. Therefore, communication between the server and the client can be continued by adopting the heartbeat message, and meanwhile, whether rules in the client and the server are consistent or not can be checked by checking data carried in the heartbeat message, so that the situation that the rules in the client and the server are different can be reduced, the server is synchronous with the rules in the client, and the accuracy and the reliability of data synchronization in the client and the server are improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification.
Drawings
The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein:
fig. 1 shows a flow chart of a data synchronization method according to an embodiment of the disclosure;
fig. 2 is a schematic flow chart of a data synchronization method according to an embodiment of the disclosure;
FIG. 3 shows a system architecture diagram of a data synchronization method provided by an embodiment of the present disclosure;
fig. 4 is a schematic flow chart of a data synchronization method according to an embodiment of the disclosure;
FIG. 5 shows a system architecture diagram of a data synchronization method provided by an embodiment of the present disclosure;
fig. 6 illustrates a schematic structural diagram of a data synchronization device according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure;
fig. 8 is a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure;
fig. 9 is a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure;
Fig. 10 is a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure;
fig. 11 is a block diagram of a server for implementing a data synchronization method of an embodiment of the present disclosure.
Detailed Description
Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
With the development of scientific technology, computer technology is mature, and convenience of production and living of users is improved. In the computer application scenario, the user may perform data transmission by using a computer that manages computing resources, that is, a server.
According to some embodiments, when the server transmits data, the server only performs one communication when transmitting information, and a retry mechanism is not provided, so that data of the client and the server cannot be checked, and the communication data between the client and the server is inaccurate and unreliable.
In addition, the server only adopts a single control interface to be responsible for issuing the message to the client, and the client monitors the information issued by the server by starting a corresponding service, so that the utilization rate of the dual cluster system (HA) is not high.
It is easy to understand that the present disclosure, by adopting the heartbeat message to continue communication between the server and the client, and by checking the data carried in the heartbeat message, can reduce the situation that the rules in the client and the server are different, so that the server is synchronous with the rules in the client, and the accuracy and reliability of data synchronization between the client and the server are improved.
The present disclosure is described in detail below with reference to specific examples.
As shown in fig. 1, fig. 1 shows a flow chart of a data synchronization method provided by an embodiment of the present disclosure, where the method is executed by a server, and the server corresponds to a client one by one; the method may be implemented in dependence on a computer program and may be run on a device for data synchronization. The computer program may be integrated in the application or may run as a stand-alone tool class application.
Specifically, the data synchronization method includes:
S101, acquiring heartbeat messages sent by a client;
according to some embodiments, the execution subject of the embodiments of the present disclosure is a server, which may be a server corresponding to a client. The server is not particularly limited to a fixed server, but may be, for example, a single server or a cluster of servers, etc. Wherein the server cluster may include at least one server.
It is readily understood that the client may be, for example, a machine embedded with a business execution program software development kit (Software Development Kit, SDK) for executing an initial rule or a target rule corresponding to the business execution program. When the initial rule is a fusing and current limiting operation, the client is a terminal for executing the specific fusing and current limiting operation. The client may be, for example, a client connected to a server.
According to some embodiments, the heartbeat message is a custom structure sent when specified, the heartbeat message includes data generated by the client based on rules included in the client, the heartbeat message may be a heartbeat packet or a heartbeat frame, and the heartbeat message allows the message receiver to determine that the message sender is online, so as to ensure validity of the data transmission link.
It is easy to understand that the heartbeat message carries encrypted data, which is data that the client generates based on the initial rules in the client. The encrypted data is not particularly specific to certain fixed data. For example, when the encryption algorithm changes, the encrypted data may also change accordingly. For example, when the initial rule changes, the encrypted data may also change accordingly.
According to some embodiments, the rules of the embodiments of the present disclosure may refer to rules set around the real-time state of a resource, which are not specific to a certain fixed rule, including but not limited to flow control rules, fuse degradation rules, system protection rules, custom rules, and the like.
It is readily understood that an initial rule refers to a rule stored in a client, which is not specific to a fixed rule. The initial rule may be, for example, a flow control initial rule, and the initial rule may also be a fuse degradation initial rule.
According to some embodiments, when the server performs the data synchronization method, the server may acquire the heartbeat message sent by the client, that is, the server may acquire the heartbeat message sent by the client every preset time period.
S102, acquiring first memory data corresponding to a client;
according to some embodiments, the first memory data refers to first memory data stored in the server corresponding to the client. The first memory data may be memory data corresponding to the initial rule type determined based on a heartbeat message sent by the client. The first memory data may include a target rule. The first memory data may also be data generated by the server based on the target rule. The first memory data may also be data stored prior to the retrieval of the heartbeat message sent by the client.
It is easy to understand that the first memory data does not refer to a certain fixed data, and when the target rule acquired by the server changes, the first memory data determined by the server based on the target rule may also change correspondingly. When the acquisition time point of the server for acquiring the first memory data changes, the server may change accordingly.
According to some embodiments, when the server performs the data synchronization method, the server may acquire the heartbeat message sent by the client, that is, the server may acquire the heartbeat message sent by the client every preset time period. The server may obtain first memory data corresponding to the client.
S103, synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
According to some embodiments, the target rule refers to a rule currently stored in the server, that is to say, a rule stored in the server upon acquisition of a heartbeat message sent by the client. The target rule does not particularly refer to a fixed rule, and for example, when the time point at which the server acquires the heartbeat message sent by the client changes, the target rule may also change correspondingly. When the rule type corresponding to the target rule changes, the target rule can also change correspondingly.
It is easy to understand that when the server performs the data synchronization method, the server may acquire the heartbeat message sent by the client, that is, the server may acquire the heartbeat message sent by the client every a preset duration. The server may obtain first memory data corresponding to the client. When the server acquires the first memory data and the heartbeat message, the server may detect whether a rule included in the heartbeat message is consistent with a target rule included in the first memory data. The server may synchronize the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data. When the rule included in the heartbeat message is consistent with the target rule included in the first memory data, it is determined that the initial rule stored by the client is consistent with the target rule stored by the server, and the server may not synchronize the target rule to the client.
In the embodiment of the disclosure, by acquiring a heartbeat message sent by a client, the heartbeat message includes data generated by the client based on rules included in the client; acquiring first memory data corresponding to a client, wherein the first memory data comprises a target rule; and synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data. Thus, by employing heartbeat messages, communication between the server and the client may be renewed. Furthermore, by checking the data carried in the heartbeat message, whether the rules in the client and the server are consistent or not can be checked, the situation that the rules in the client and the server are different can be reduced, the server is synchronous with the rules in the client, and the accuracy and the reliability of the data synchronization in the client and the server are improved.
Referring to fig. 2, fig. 2 is a flow chart illustrating a data synchronization method according to an embodiment of the disclosure. Specifically, the data synchronization method includes:
s201, obtaining a heartbeat message sent by a client;
the specific process is as described above, and will not be described here again.
According to some embodiments, the technical solutions of the embodiments of the present disclosure may be applied to a scenario of monitoring an operation state, including but not limited to a scenario of fusing, limiting current, degrading, full link tracking, etc. a service is fused. The technical scheme of the embodiment of the disclosure can be applied to a sentry (Sentinel) monitoring scene, for example.
It is easy to understand that the heartbeat message carries encrypted data, which is data that the client generates based on the initial rules in the client. The client is provided with a port listening service for handling instant messages occurring at the server side, that is to say for handling messages sent at the server side.
According to some embodiments, a heartbeat mechanism is provided in the client for maintaining the client's own state. Due to the existence of the heartbeat mechanism, the client can send heartbeat messages to the server at regular time, so that the client and the server can make a contract, and the server can monitor the state of the client.
Among these, resources are the key concepts of Sentinel. A resource may be a method, a piece of code, an interface provided by an application, or an interface called by an application for other applications.
According to some embodiments, the execution body of the embodiments of the present disclosure is a server, which may be, for example, a server having a control interface, which may be, for example, a Dashbord, for adding, deleting, modifying and checking all rules of the client, and is responsible for issuing the rules stored in the server to the client. The server may also be responsible for monitoring the survival of the client at the same time, for example, by acquiring monitoring index data of the client as metadata of the monitoring alarm system.
According to some embodiments, an application scenario of embodiments of the present disclosure is, for example, throttling a service. For example, assuming that the service a needs to rely on the service B to complete one request of the client, the service B can predict the maximum number of concurrent requests that can be processed by a single node by using the push measurement method, so long as the maximum number of concurrent requests does not exceed the limit service of the service B, the service can stably run. Limiting service B to handle the largest concurrent request is limiting, for example, the limiting condition may be that the number of requests processed per second is 200 requests, and the exceeding requests may be handled by a flow control policy, or directly rejected or queued, which is a limiting degradation application scenario.
According to some embodiments, the encrypted data may be, for example, an MD5 value, which may be, for example, data generated by a client encrypting an initial rule in the client using an MD5 message digest algorithm. The MD5 Message-Digest Algorithm (english: MD5 Message-Digest Algorithm) is a widely used cryptographic hash function, and can generate a 128-bit (16-byte) hash value (hash value) to ensure that the information transmission is completely consistent.
According to some embodiments, the client may also send the client's set of application identifications to the server. The set of application identities does not refer specifically to a fixed set, the set of application identities comprising at least one application identity. When the number of application identifications included in the application identification set changes, the application identification set may also change accordingly.
S202, acquiring target rules from a database every other preset time length;
according to some embodiments, the preset duration refers to an interval duration of the server obtaining the target rule. That is, the time interval between the last time the server obtained the target rule from the database and the current time the server obtained the target rule from the database is the preset duration. The preset time period is not particularly limited to a certain fixed time period. For example, when the server acquires a duration modification instruction for a preset duration, the preset duration may also be changed accordingly.
According to some embodiments, a Database (DB) refers to a collection of data organized and stored in a secondary memory according to some data model. The database is a "repository" that organizes, stores and manages data according to a data structure, and is a collection of large amounts of data that are stored in a server for a long period of time, organized, sharable, and uniformly managed. The database is not specific to a fixed collection. For example, when the data included in the database changes, the database may also change accordingly.
It is readily understood that the target rule refers to a rule stored in a database and periodically acquired by a server. The rule does not refer specifically to a fixed rule. The target rule may also change accordingly, for example, when a modification instruction for the target rule is obtained.
In some embodiments, when the server performs the data synchronization method, the server may acquire the target rule from the database once every preset time period. For example, the server may obtain the target rule once from a MySQL database.
S203, encrypting the target rule to obtain first memory data corresponding to the target rule;
the specific process is as described above, and will not be described here again.
According to some embodiments, the first memory data may be, for example, an MD5 value. When the server obtains the target rule, the server encrypts the target rule by adopting an MD5 information abstract algorithm to obtain first memory data corresponding to the target rule, wherein the first memory data can be, for example, an MD5 value corresponding to the target rule.
S204, storing a target rule and storing first memory data;
according to some embodiments, when the server obtains a target rule from the database once, the server may store the target rule. When the server encrypts the target rule and obtains the first memory data corresponding to the target rule, the server can store the first memory data.
According to some embodiments, when the server stores the first memory data, the server may acquire second memory data, where the second memory data is the memory data stored before the target rule is acquired; encrypting the target rule to obtain first memory data corresponding to the target rule; storing the second memory data under the condition that the second memory data is consistent with the first memory data; and storing the first memory data under the condition that the second memory data is inconsistent with the first memory data.
In some embodiments, when the server stores the first memory data under the condition that the second memory data is inconsistent with the first memory data, the server can replace the second memory data with the first memory data, and through judging the first memory data and the second memory data, the situation that the data storage step is complicated due to the fact that the server directly replaces the second memory data can be reduced, and under the condition that the second memory data is consistent with the first memory data, the memory data can not be modified, and the accuracy of memory data storage can be improved.
According to some embodiments, when the server replaces the second memory data with the first memory data under the condition that the second memory data is consistent with the first memory data, the first memory data can be synchronized to the server cluster in a message queue mode, so that at least one server in the server cluster can acquire the first memory data, the consistency of the data of the whole server side can be improved, and the reliability of a single client in communication with a plurality of servers is improved.
According to some embodiments, a Message Queue (MQ) is a data structure that is "first-in first-out" in the underlying data structure. The method is generally used for solving the problems of application decoupling, asynchronous message, flow peak clipping and the like, and realizing a high-performance, high-availability, scalable and final consistency architecture.
According to some embodiments, when the server stores the first memory data, the server may use a relational database to store the first memory data, so that the security of the first memory data storage may be improved, and the performance pressure of the server may be reduced. The system architecture diagram of the data synchronization method at this time may be as shown in fig. 3, for example.
The specific process is as described above, and will not be described here again.
According to some embodiments, the relational database may be, for example, a MySQL database, which is a relational database management system, and stores data in different tables, instead of placing all data in one large warehouse, which may increase the data storage speed while increasing flexibility.
The execution order of the steps 201 and 202-204 is not limited, that is, the steps 201 may be executed first and then the steps 202-204 may be executed, or the steps 202-204 may be executed first and then the step 201 may be executed.
S205, acquiring first memory data corresponding to a client;
the specific process is as described above, and will not be described here again.
S206, synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
The specific process is as described above, and will not be described here again.
In the embodiment of the disclosure, the heartbeat message sent by the client is acquired, and the heartbeat message includes data generated by the client based on rules included in the client. Thus, by employing heartbeat messages, communication between the server and the client may be renewed. And secondly, the target rule is obtained from the database once every preset time, encryption processing is carried out on the target rule, first memory data corresponding to the target rule is obtained, the target rule is stored, the first memory data is stored, and the accuracy of obtaining the first memory data can be improved. Finally, by acquiring the first memory data corresponding to the client, when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data, the target rule is synchronized to the client. Therefore, by checking the data carried in the heartbeat message, whether the rules in the client and the server are consistent or not can be checked, the situation that the rules in the client and the server are different can be reduced, the server is synchronous with the rules in the client, the accuracy and the reliability of the data synchronization in the client and the server are improved, the integrity of the storage rules in the server can be improved, the accuracy of the encrypted data detection is improved, and the accuracy and the reliability of the data synchronization are improved.
Referring to fig. 4, fig. 4 is a flow chart illustrating a data synchronization method according to an embodiment of the disclosure. Specifically, the data synchronization method includes:
s301, acquiring a heartbeat message sent by a client;
the specific process is as described above, and will not be described here again.
S302, updating the heartbeat message to the non-relational database so that at least one server corresponding to the non-relational database acquires the heartbeat message;
according to some embodiments, when the server acquires the heartbeat message sent by the client, the server may update the heartbeat information to the non-relational database so that at least one server corresponding to the non-relational database acquires the heartbeat message, that is, the server may synchronize the heartbeat information to the non-relational database so that at least one server corresponding to the non-relational database acquires the heartbeat message. The system architecture diagram of the data synchronization method at this time may be as shown in fig. 5, for example.
In some embodiments, the non-relational database may be, for example, a NoSQL database, a database that is generated in the context of large data, and that can handle data that is distributed, large-scale, type-uncertain, and of no guarantee of integrity. The non-relational database is adopted to improve the read-write performance of the data.
According to some embodiments, since the client has a heartbeat mechanism to renew to the server end at regular time and the change is not too large, the client is not too large in the data synchronization method and sudden increase is not caused, so the server can store the heartbeat message of the client in the non-relational database, the heartbeat message can be ensured to be visible to the whole server cluster, and the availability performance can be improved.
S303, acquiring first memory data corresponding to a client;
the specific process is as described above, and will not be described here again.
S304, synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
The specific process is as described above, and will not be described here again.
In the technical scheme of the disclosure, the related processes of collecting, storing, using, processing, transmitting, providing, disclosing and the like of the personal information of the user accord with the regulations of related laws and regulations, and the public order colloquial is not violated.
In a related embodiment, the heartbeat message is updated to the non-relational database by acquiring the heartbeat message sent by the client, so that at least one server corresponding to the non-relational database acquires the heartbeat message, the heartbeat message is visible to the whole server cluster, the usability can be improved, secondly, when a rule included in the heartbeat message is inconsistent with a target rule included in the first memory data by acquiring the first memory data corresponding to the client, the target rule is synchronized to the client, the communication between the server and the client can be continued by adopting the heartbeat message, meanwhile, whether the rules in the client and the server are consistent or not can be checked by checking the data carried in the heartbeat message, the condition that the rules in the client and the server are different can be reduced, the data in the server and the client are synchronized, and the accuracy and the reliability of the data synchronization between the client and the server are improved.
The following are device embodiments of the present disclosure that may be used to perform method embodiments of the present disclosure. For details not disclosed in the embodiments of the apparatus of the present disclosure, please refer to the embodiments of the method of the present disclosure.
Referring to fig. 6, a schematic structural diagram of a first data synchronization device according to an exemplary embodiment of the present disclosure is shown. The data synchronization device may be implemented as all or part of the device by software, hardware, or a combination of both. The data synchronization device 600 includes a message acquisition unit 601, a data acquisition unit 602, and a rule transmission unit 603, wherein:
a message obtaining unit 601, configured to obtain a heartbeat message sent by a client, where the heartbeat message includes data generated by the client based on rules included in the client;
a data obtaining unit 602, configured to obtain first memory data corresponding to a client, where the first memory data includes a target rule;
the rule transmission unit 602 is configured to synchronize the target rule to the client when the rule included in the heartbeat message and the target rule included in the first memory data are inconsistent.
Fig. 7 is a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure. As shown in fig. 7, the apparatus 600 further includes a rule obtaining unit 604, configured to obtain, before obtaining the first memory data corresponding to the client, the target rule from the database at intervals of a preset duration;
Encrypting the target rule to obtain the target rule, and encrypting the target rule to obtain first memory data corresponding to the target rule;
and storing the target rule and storing the first memory data.
According to some embodiments, the rule obtaining unit 604 is configured to, when storing the first memory data, specifically:
acquiring second memory data, wherein the second memory data is stored before acquiring a target rule;
encrypting the target rule to obtain first memory data corresponding to the target rule;
storing the second memory data under the condition that the second memory data is consistent with the first memory data;
and under the condition that the second memory data is inconsistent with the first memory data, replacing the second memory data with the first memory data.
Fig. 8 illustrates a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure. As shown in fig. 8, the apparatus 600 further comprises a data synchronization unit 605 for, in case the second memory data is inconsistent with the first memory data, storing the first memory data,
and synchronizing the first memory data to the server cluster so that at least one server in the server cluster acquires the first memory data.
Fig. 9 illustrates a schematic structural diagram of a data synchronization device according to an embodiment of the disclosure. As shown in fig. 9, the apparatus 600 further comprises a data storage unit 606 for, in case the second memory data is inconsistent with the first memory data, storing the first memory data,
and storing the first memory data by adopting a relational database.
Fig. 10 illustrates a schematic structural diagram of a data synchronization device according to an embodiment of the present disclosure. As shown in fig. 10, the apparatus 600 further includes a message updating unit 607, configured to update the heartbeat message to the non-relational database after acquiring the heartbeat message sent by the client, so that at least one server corresponding to the non-relational database acquires the heartbeat message.
It should be noted that, when the data synchronization apparatus provided in the foregoing embodiment performs the data synchronization method, only the division of the foregoing functional modules is used as an example, and in practical application, the foregoing functional allocation may be performed by different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules, so as to complete all or part of the functions described above. In addition, the data synchronization device and the data synchronization method provided in the foregoing embodiments belong to the same concept, which embody the detailed implementation process in the method embodiment, and are not described herein again.
The foregoing embodiment numbers of the present disclosure are merely for description and do not represent advantages or disadvantages of the embodiments.
In the embodiment of the disclosure, a heartbeat message sent by a client is acquired through a message acquisition unit, wherein the heartbeat message comprises data generated by the client based on rules included in the client; the method comprises the steps that a data acquisition unit acquires first memory data corresponding to a client, wherein the first memory data comprises a target rule; the rule transmission unit synchronizes the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data. Therefore, communication between the server and the client can be continued by adopting the heartbeat message, meanwhile, whether rules in the client and the server are consistent or not can be checked by checking data carried in the heartbeat message, the situation that the rules in the client and the server are different can be reduced, the server and the rules in the client are synchronous, and the accuracy and the reliability of data synchronization are improved.
In the technical scheme of the disclosure, the acquisition, storage, application and the like of the related user personal information all conform to the regulations of related laws and regulations, and the public sequence is not violated.
The following are system embodiments of the present disclosure that may be used to perform method embodiments of the present disclosure. For details not disclosed in the embodiments of the disclosed system, please refer to the embodiments of the disclosed method.
According to embodiments of the present disclosure, the present disclosure also provides a server, a readable storage medium, and a computer program product.
FIG. 11 illustrates a schematic block diagram of an example server 1100 that may be used to implement embodiments of the present disclosure. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the disclosure described and/or claimed herein.
As shown in fig. 11, the server 1100 includes a computing unit 1101 that can perform various appropriate actions and processes according to a computer program stored in a Read Only Memory (ROM) 1102 or a computer program loaded from a storage unit 1108 into a Random Access Memory (RAM) 1103. In the RAM 1103, various programs and data required for the operation of the server 1100 can also be stored. The computing unit 1101, ROM 1102, and RAM 1103 are connected to each other by a bus 1104. An input/output (I/O) interface 1105 is also connected to bus 1104.
A number of components in the server 1100 are connected to the I/O interface 1105, including: an input unit 1106 such as a keyboard, a mouse, etc.; an output unit 1107 such as various types of displays, speakers, and the like; a storage unit 1108, such as a magnetic disk, optical disk, etc.; and a communication unit 1109 such as a network card, modem, wireless communication transceiver, or the like. The communication unit 1109 allows the server 1100 to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
The computing unit 1101 may be a variety of general purpose and/or special purpose processing components having processing and computing capabilities. Some examples of computing unit 1101 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various computing units running machine learning model algorithms, a Digital Signal Processor (DSP), and any suitable processor, controller, microcontroller, etc. The calculation unit 1101 performs the respective methods and processes described above, for example, the area determination method. For example, in some embodiments, the data synchronization method may be implemented as a computer software program tangibly embodied on a machine-readable medium, such as storage unit 1108. In some embodiments, some or all of the computer programs may be loaded and/or installed onto the server 1100 via the ROM 1102 and/or the communication unit 1109. When a computer program is loaded into the RAM 1103 and executed by the computing unit 1101, one or more steps of the above-described region determination method may be performed. Alternatively, in other embodiments, the computing unit 1101 may be configured to perform the region determination method by any other suitable means (e.g. by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
Program code for carrying out methods of the present disclosure may be written in any combination of one or more programming languages. These program code may be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus such that the program code, when executed by the processor or controller, causes the functions/operations specified in the flowchart and/or block diagram to be implemented. The program code may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), the internet, and blockchain networks.
The computer system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service ("Virtual Private Server" or simply "VPS") are overcome. The server may also be a server of a distributed system or a server that incorporates a blockchain.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps recited in the present disclosure may be performed in parallel or sequentially or in a different order, provided that the desired results of the technical solutions of the present disclosure are achieved, and are not limited herein.
The above detailed description should not be taken as limiting the scope of the present disclosure. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present disclosure are intended to be included within the scope of the present disclosure.

Claims (10)

1. A method of data synchronization, the method being performed by a server, said server being communicatively coupled to a client; comprising the following steps:
acquiring a heartbeat message sent by the client, wherein the heartbeat message comprises data generated by the client based on rules included in the client;
acquiring first memory data corresponding to the client, wherein the first memory data comprises a target rule;
And synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
2. The method of claim 1, wherein prior to retrieving the first memory data corresponding to the client, further comprising:
acquiring a target rule from a database every other preset time length;
encrypting the target rule to obtain first memory data corresponding to the target rule;
and storing the target rule and the first memory data.
3. The method of claim 2, wherein storing the first memory data comprises:
acquiring second memory data, wherein the second memory data is stored before acquiring the target rule;
encrypting the target rule to obtain first memory data corresponding to the target rule;
storing the second memory data under the condition that the second memory data is consistent with the first memory data;
and storing the first memory data under the condition that the second memory data is inconsistent with the first memory data.
4. The method of claim 3, wherein, in the case where the second memory data is inconsistent with the first memory data, after storing the first memory data, further comprising:
and synchronizing the first memory data to a server cluster so that at least one server in the server cluster acquires the first memory data.
5. The method of claim 2, wherein, in the case where the second memory data is inconsistent with the first memory data, after storing the first memory data, further comprising:
and storing the first memory data by adopting a relational database.
6. The method of claim 1, wherein after the obtaining the heartbeat message sent by the client, further comprising:
and updating the heartbeat message to the non-relational database so that at least one server corresponding to the non-relational database acquires the heartbeat message.
7. A data synchronization device, comprising:
a message obtaining unit, configured to obtain a heartbeat message sent by the client, where the heartbeat message includes data generated by the client based on a rule included in the client;
The data acquisition unit is used for acquiring first memory data corresponding to the client, wherein the first memory data comprises a target rule;
and the rule transmission unit is used for synchronizing the target rule to the client when the rule included in the heartbeat message is inconsistent with the target rule included in the first memory data.
8. A server, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; it is characterized in that the method comprises the steps of,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
9. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-6.
10. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-6.
CN202210535862.9A 2022-05-17 2022-05-17 Data synchronization method and device, server and storage medium Pending CN117112576A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210535862.9A CN117112576A (en) 2022-05-17 2022-05-17 Data synchronization method and device, server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210535862.9A CN117112576A (en) 2022-05-17 2022-05-17 Data synchronization method and device, server and storage medium

Publications (1)

Publication Number Publication Date
CN117112576A true CN117112576A (en) 2023-11-24

Family

ID=88811580

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210535862.9A Pending CN117112576A (en) 2022-05-17 2022-05-17 Data synchronization method and device, server and storage medium

Country Status (1)

Country Link
CN (1) CN117112576A (en)

Similar Documents

Publication Publication Date Title
CN111344706B (en) Method and system for managing transactions on blockchain
WO2022262183A1 (en) Federated computing processing method and apparatus, electronic device, and storage medium
US20130007008A1 (en) Hash algorithm-based data storage method and system
CN109447641B (en) Method and apparatus for transmitting blockchain data to blockchain browser
WO2014131299A1 (en) Method, system, server and client device for message synchronizing
EP2819015B1 (en) Method, terminal, and server for synchronizing terminal mirror
US20220012692A1 (en) Schedule information acquiring method, apparatus, device, storage medium and program product
US11599425B2 (en) Method, electronic device and computer program product for storage management
CN109710502B (en) Log transmission method, device and storage medium
CN113067860B (en) Method, apparatus, device, medium and product for synchronizing information
CN111338834A (en) Data storage method and device
CN117112576A (en) Data synchronization method and device, server and storage medium
JP2023031248A (en) Edge computing network, data transmission method, apparatus, device, and storage medium
CN115543416A (en) Configuration updating method and device, electronic equipment and storage medium
US10250515B2 (en) Method and device for forwarding data messages
CN115529186A (en) SSL certificate unloading method, device and system based on soft load balancing
CN113326038A (en) Method, apparatus, device, storage medium and program product for providing service
CN112860796A (en) Method, apparatus, device and storage medium for synchronizing data
CN113726885A (en) Method and device for adjusting flow quota
CN112860811A (en) Method and device for determining data blood relationship, electronic equipment and storage medium
CN112968876A (en) Content sharing method and device, electronic equipment and storage medium
CN110262756B (en) Method and device for caching data
CN116431523B (en) Test data management method, device, equipment and storage medium
CN114650252B (en) Routing method and device based on enterprise service bus and computer equipment
US9363226B2 (en) Method for double IP address recovery

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination