A dual-active-counting system and method

By deploying a master-slave database and counter service unit in a remote active-active counting system, the performance and data consistency issues of the remote active-active counting method are resolved, and efficient and reliable counting data processing is achieved.

CN117332010BActive Publication Date: 2026-04-21BEIJING SKYFAITH TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING SKYFAITH TECH CO LTD
Filing Date
2023-10-16
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

Existing off-site active-active counting methods suffer from poor performance and are prone to data inconsistency or data loss.

Method used

A dual-active counter system is adopted, which consists of service units deployed in two different geographical areas, including master-slave databases and counter service units. Data consistency and reliability are ensured through data synchronization between the master-slave databases and the calculation of the counter.

Benefits of technology

It improves system performance and scalability, ensures data consistency, high availability and high reliability, and enables seamless switching in the event of node failure, ensuring the integrity and accuracy of counting data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117332010B_ABST
    Figure CN117332010B_ABST
Patent Text Reader

Abstract

This invention relates to the field of computer technology, specifically to a geographically distributed active-active counting system and method. The system includes a first service unit and a second service unit deployed in two different geographical regions. Each service unit includes a local master database and a geographically distributed slave database. The local master database stores the locally recorded counts, while the geographically distributed slave database synchronizes with the corresponding data in the master database. Service nodes within the service unit can read data from both the master and slave databases and calculate the total recorded count. It is understood that the counting scheme provided by this invention offers strong performance, good scalability, and guarantees data consistency, high availability, and high reliability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and specifically to a remote dual-active counting system and method. Background Technology

[0002] Active-active multi-site counters are a key technology in distributed systems used to achieve high availability and high reliability. They allow multiple servers to simultaneously access and update a shared counter, and seamlessly switch to another server to continue providing service when one server fails.

[0003] In existing technologies, off-site active-active counting is mainly implemented based on distributed databases or distributed caching systems.

[0004] A distributed database is a database system that utilizes multiple computers to work collaboratively to handle large-scale data processing and storage tasks. It offers advantages such as high availability, high scalability, and high performance, ensuring data integrity and consistency. However, distributed databases may encounter performance bottlenecks and single points of failure when handling a large number of concurrent read and write requests.

[0005] A distributed caching system is a caching system that utilizes the memory resources of multiple computers to store frequently accessed data, thereby reducing the load on the database. It offers advantages such as high performance, high availability, and high scalability, significantly improving system response speed and concurrency capabilities. However, distributed caching systems may experience data inconsistency or data loss.

[0006] Therefore, the existing off-site active-active counting method has problems such as poor performance and easy data inconsistency or data loss. Summary of the Invention

[0007] In view of this, the purpose of the present invention is to provide a remote dual-active counting system and method to solve the problems of poor performance, data inconsistency or data loss in the prior art remote dual-active counting method.

[0008] According to a first aspect of the present invention, a remote dual-active counting system is provided, comprising:

[0009] The first and second service units are deployed in two different geographical regions;

[0010] The first service unit includes a first service node, and a first master database and a second slave database respectively connected to the first service node; the first master database is used to store the number of records at the first service unit.

[0011] The second service unit includes a second service node, and a second master database and a first slave database respectively connected to the second service node; the second master database is used to store the number of records at the second service unit;

[0012] The first slave database can maintain data synchronization with the first master database; the second slave database can maintain data synchronization with the second master database.

[0013] The first service node can read the first master database and the second slave database, and calculate the total number of records.

[0014] Preferably, the system further includes:

[0015] A counter service unit, wherein the counter service unit includes at least one counter;

[0016] When the first service node or the second service node determines that the total number of records has reached a preset threshold, it sends a counting request to the counter; the counting request includes the number of records in the first main database or the number of records in the second main database.

[0017] The counter can calculate the total number of records based on the number of records in the first master database and the number of records in the second master database.

[0018] Preferably, the counter can also communicate with the first slave database and the second slave database respectively to obtain the number of records in the first slave database and the number of records in the second slave database;

[0019] The counter can also calculate the total number of records by using all the recorded counts when a counting request is received.

[0020] Preferably, the counter service unit further includes:

[0021] A counter agent node is used to select an available counter from at least one counter to receive and execute the counting request.

[0022] According to a second aspect of the present invention, a remote dual-active counting method is provided, applied to the remote dual-active counting system described in any one of the above embodiments, comprising:

[0023] When the first or second service node receives a business request, it reads the number of records in the local master database and the number of records in the remote slave database.

[0024] The total number of records is calculated based on the number of records in the local master database and the number of records in the remote slave database;

[0025] Send service data containing the total number of records to the sender of the service request.

[0026] Preferably, after calculating the total number of records, the method further includes:

[0027] When the total number of records exceeds a preset threshold, the first service node or the second service node sends a counting request to the counter. The counting request includes the number of records in the first main database or the number of records in the second main database, so that the counter can calculate and update the total number of records based on the number of records in the first main database and the number of records in the second main database.

[0028] Preferably, the counter calculates and updates the total number of records based on the number of records in the first master database and the number of records in the second master database, including:

[0029] When the counter receives a counting request sent by the first service node, it obtains the number of records in the second slave database; compares the number of records in the second slave database with the number of records in the second master database to obtain the maximum value of the second recorded number; and sums the number of records in the first master database with the maximum value of the second recorded number to obtain and update the total number of records.

[0030] When the counter receives a counting request sent by the second service node, it obtains the number of records in the first slave database; compares the number of records in the first slave database with the number of records in the first master database to obtain the maximum value of the first recorded number; and sums the number of records in the second master database with the maximum value of the first recorded number to obtain and update the total number of records.

[0031] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects:

[0032] It is understood that the off-site active-active counting system provided by this invention includes a first service unit and a second service unit deployed in two different geographical areas; the first service unit includes a first service node, and a first master database and a second slave database respectively connected to the first service node; the first master database is used to store the recorded count at the first service unit; the second service unit includes a second service node, and a second master database and a first slave database respectively connected to the second service node; the second master database is used to store the recorded count at the second service unit; the first slave database can maintain data synchronization with the first master database; the second slave database can maintain data synchronization with the second master database; the first service node can read the first master database and the second slave database and calculate the total recorded count. It is understood that the counting scheme provided by this invention has strong performance, good scalability, and ensures data consistency, high availability, and high reliability.

[0033] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description

[0034] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0035] Figure 1 This is a schematic block diagram illustrating a remote dual-active counting system according to an exemplary embodiment;

[0036] Figure 2 This is a schematic block diagram of a counter service unit according to an exemplary embodiment;

[0037] Figure 3 This is a schematic diagram of the operation process according to an exemplary embodiment;

[0038] Figure 4 This is a schematic diagram illustrating the steps of a remote dual-active counting method according to an exemplary embodiment. Detailed Implementation

[0039] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0040] Example 1

[0041] Figure 1 This is a schematic block diagram illustrating a remote dual-active counting system according to an exemplary embodiment. See also: Figure 1 A remote dual-active counting system is provided, comprising:

[0042] A first service unit 100 and a second service unit 200 are deployed in two different geographical areas;

[0043] The first service unit 100 includes a first service node 101, and a first master database 102 and a second slave database 103 respectively connected to the first service node 101; the first master database 102 is used to store the number of records at the first service unit 100.

[0044] The second service unit 200 includes a second service node, and a second master database 202 and a first slave database 203 respectively connected to the second service node; the second master database 202 is used to store the number of records at the second service unit 200;

[0045] The first slave database 203 can maintain data synchronization with the first master database 102; the second slave database 103 can maintain data synchronization with the second master database 202;

[0046] The first service node 101 can read the first master database 102 and the second slave database 103, and calculate the total number of records.

[0047] In practice, Redis can be used as the database, employing a master-slave replication model to establish a master-slave replication system for geographically distributed Redis services. For example, a geographically distributed active-active service might be divided into a first service unit (100) and a second service unit (200). Each service unit would have two Redis nodes (one local master and one geographically distributed slave): one master node for local service and one slave node for geographically distributed service. The local Redis master node would record the quantities used locally, while the geographically distributed Redis slave node would synchronize the quantities from the other master node.

[0048] In practical applications, service nodes can be connected to external business systems. When a business system sends a corresponding business request, the remote active-active system can execute the corresponding counting business. When executing the business, the business system only reads the number of times the local Redis master node and the number of times the remote Redis slave node has been used. The sum of the numbers recorded by the two nodes is taken as the total number of times the data has been used.

[0049] It is understood that the off-site active-active counting system provided in this embodiment includes a first service unit 100 and a second service unit 200 deployed in two different geographical areas. The first service unit 100 includes a first service node 101, and a first master database 102 and a second slave database 103 respectively connected to the first service node 101. The first master database 102 is used to store the recorded quantity at the first service unit 100. The second service unit 200 includes a second service node, and a second master database 202 and a first slave database 203 respectively connected to the second service node. The second master database 202 is used to store the recorded quantity at the second service unit 200. The first slave database 203 can maintain data synchronization with the first master database 102. The first service node 101 can read the first master database 102 and the second slave database 103 and calculate the total recorded quantity. It is understood that the counting scheme provided in this embodiment has strong performance, good scalability, and ensures data consistency, high availability, and high reliability. Meanwhile, the off-site dual-active counting system shown in this embodiment uses two counting nodes located in different geographical areas. They can complete the counting task independently, always ensuring that the counter counts in the two locations are consistent. When a node fails, the counting operation can be automatically switched to the other node, ensuring the integrity and accuracy of the counter data after the switch.

[0050] It should be noted that, see Figure 2 The system further includes:

[0051] A counter service unit 300, wherein the counter service unit 300 includes at least one counter;

[0052] When the first service node 101 or the second service node determines that the total number of records has reached a preset threshold, it sends a counting request to the counter; the counting request includes the number of records in the first main database 102 or the number of records in the second main database 202;

[0053] The counter can calculate the total number of records based on the number of records in the first main database 102 and the number of records in the second main database 202.

[0054] In practice, to ensure the efficiency and accuracy of the remote active-active counting system, the working mode of the remote active-active counting system can be divided into fast mode and slow mode, and a working mode switching threshold can be set. When the threshold is not reached, the remote active-active counting system works in fast mode, and when the threshold is reached, the remote active-active counting system works in slow mode.

[0055] In the fast mode of the geographically distributed active-active counting system, the local service node only needs to access the stored records in the local master and slave databases to obtain the total number of records. Once a threshold is reached, the system switches to slow mode, where each service node sends a count request from its local database to the counter via remote communication. This allows the counter to perform more accurate calculations and obtain a more precise total number of records.

[0056] For example, assuming the total number is 1000 and the threshold is 900, when the count range is 0 to 900, the remote active-active counting system runs in fast mode. When it reaches 900, the remote active-active counting system runs in slow mode, remotely calling the counter to ensure the accuracy of the count.

[0057] It should be noted that the counter can also communicate with the first slave database 203 and the second slave database 103 respectively to obtain the number of records in the first slave database 203 and the number of records in the second slave database 103;

[0058] The counter can also calculate the total number of records by using all the recorded counts when a counting request is received.

[0059] In practice, due to the certain delay in data synchronization between the master database and the slave database, there may be a temporary data difference between the two. Therefore, the technical solution provided in this embodiment can obtain the number of records in the slave database again and finally calculate the accurate total number of records.

[0060] In practical applications, under slow mode, the geographically distributed active-active technology system needs to request a counter service to determine if there is any remaining quantity. When requesting the counter service, the request must include the quantity already used in the primary Redis node of the local service (assuming the quantity used in the primary Redis node of service A is denoted as Amr, and the quantity used in the primary Redis node of service B is denoted as Bmr). Upon receiving the request, the counter service caches Amr and Bmr (denoted as Ac and Bc). Then, it retrieves the respective used quantities (denoted as Ar and Br) from Redis in both locations and checks if Amr and Bmr exist in the cache. If they exist, the following steps are executed: assuming the request originates from location A, Amr can be obtained from the request; Amr should represent the used quantity in location A. The quantity in location B can be confirmed by comparing Bc and Br and taking the maximum value. Therefore, the formula for calculating the used quantity in both locations is Amr + (Max(Bc, Br)). If the total quantity is greater than or equal to the ordered quantity, the quantity is considered exhausted; otherwise, there is still a remaining quantity.

[0061] It should be noted that the counter service unit 300 further includes:

[0062] Counter agent node 301 is used to select an available counter from at least one counter to receive and execute the counting request.

[0063] In practice, to improve the stability, high availability, and high reliability of the entire system, the counter service unit can be configured with multiple counters (counter A, counter B, counter C, and counter D) and a counter proxy node 301 can be configured. The counter proxy node 301 can select an available counter from the counter cluster, use that counter, and execute the counting request.

[0064] Figure 3 This is a schematic diagram of the operation flow according to an exemplary embodiment, see [link / reference]. Figure 3 When a user processes business data using the off-site active-active counting system, they first send a business request to the service node. The service node will automatically determine whether the threshold for slow mode has been reached. If not, it will directly process the business and return the business data to the user. If the threshold for slow mode has been reached, it will enter slow mode, call the counter service, use the counter to determine whether there is still a margin, and return the counter result to the service node. The service node will then process the business based on the returned result and return the business data to the user.

[0065] Example 2

[0066] Figure 4 This is a schematic diagram illustrating the steps of a remote dual-active counting method according to an exemplary embodiment. See also... Figure 4 A method for remote active-active counting is provided, applied to any of the remote active-active counting systems described above, comprising:

[0067] Step S11: When the first service node or the second service node receives a business request, it reads the number of records in the local master database and the number of records in the remote slave database.

[0068] Step S12: Calculate the total number of records based on the number of records in the local master database and the number of records in the remote slave database;

[0069] Step S13: Send service data containing the total number of records to the sending end of the service request.

[0070] It is understood that the off-site active-active counting method shown in this embodiment has strong performance, good scalability, and ensures data consistency, high availability and high reliability.

[0071] It should be noted that after calculating the total number of records, the following is also included:

[0072] When the total number of records exceeds a preset threshold, the first service node or the second service node sends a counting request to the counter. The counting request includes the number of records in the first main database or the number of records in the second main database, so that the counter can calculate and update the total number of records based on the number of records in the first main database and the number of records in the second main database.

[0073] It should be noted that the counter calculates and updates the total number of records based on the number of records in the first main database and the number of records in the second main database, including:

[0074] When the counter receives a counting request sent by the first service node, it obtains the number of records in the second slave database; compares the number of records in the second slave database with the number of records in the second master database to obtain the maximum value of the second recorded number; and sums the number of records in the first master database with the maximum value of the second recorded number to obtain and update the total number of records.

[0075] When the counter receives a counting request sent by the second service node, it obtains the number of records in the first slave database; compares the number of records in the first slave database with the number of records in the first master database to obtain the maximum value of the first recorded number; and sums the number of records in the second master database with the maximum value of the first recorded number to obtain and update the total number of records.

[0076] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.

[0077] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.

[0078] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.

[0079] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0080] Those skilled in the art will understand that all or part of the steps of the methods described in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it includes one or a combination of the steps of the method embodiments.

[0081] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.

[0082] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.

[0083] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0084] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A remote dual-active counting system, characterized in that, include: The first and second service units are deployed in two different geographical regions; The first service unit includes a first service node, and a first master database and a second slave database respectively connected to the first service node; The first main database is used to store the number of records at the first service unit; The second service unit includes a second service node, and a second master database and a first slave database respectively connected to the second service node; The second main database is used to store the number of records at the second service unit; The first slave database can maintain data synchronization with the first master database; The second slave database can maintain data synchronization with the second master database; The first service node can read the first master database and the second slave database, and calculate the total number of records. A counter service unit, wherein the counter service unit includes at least one counter; When the first service node or the second service node determines that the total number of records has reached a preset threshold, it sends a counting request to the counter; the counting request includes the number of records in the first main database or the number of records in the second main database. The counter can calculate the total number of records based on the number of records in the first master database and the number of records in the second master database.

2. The system according to claim 1, characterized in that, The counter can also communicate with the first slave database and the second slave database respectively to obtain the number of records in the first slave database and the number of records in the second slave database; The counter can also calculate the total number of records by using all the recorded counts when a counting request is received.

3. The system according to claim 1, characterized in that, The counter service unit further includes: A counter agent node is used to select an available counter from at least one counter to receive and execute the counting request.

4. A remote dual-active counting method, applied to the remote dual-active counting system as described in any one of claims 1 to 3, characterized in that, include: When the first or second service node receives a business request, it reads the number of records in the local master database and the number of records in the remote slave database. The total number of records is calculated based on the number of records in the local master database and the number of records in the remote slave database; Send service data containing the total number of records to the sender of the service request.

5. The method according to claim 4, characterized in that, After calculating the total number of records, the following is also included: When the total number of records exceeds a preset threshold, the first service node or the second service node sends a counting request to the counter. The counting request includes the number of records in the first main database or the number of records in the second main database, so that the counter can calculate and update the total number of records based on the number of records in the first main database and the number of records in the second main database.

6. The method according to claim 5, characterized in that, The counter calculates and updates the total number of records based on the number of records in the first master database and the number of records in the second master database, including: When the counter receives a counting request sent by the first service node, it obtains the number of records in the second slave database; compares the number of records in the second slave database with the number of records in the second master database to obtain the maximum value of the second recorded number; and sums the number of records in the first master database with the maximum value of the second recorded number to obtain and update the total number of records. When the counter receives a counting request sent by the second service node, it obtains the number of records in the first slave database; compares the number of records in the first slave database with the number of records in the first master database to obtain the maximum value of the first recorded number; and sums the number of records in the second master database with the maximum value of the first recorded number to obtain and update the total number of records.

Citation Information

Patent Citations

  • Remote active-active implementation method and system applicable to inventory services

    CN107508699A