Method for ensuring fund account data consistency in cross-machine-room scene
By introducing a single-point service module and a data correction module into an e-commerce system deployed in multiple computer rooms, it centrally processes fund operation requests and synchronizes data asynchronously, solving the problem of fund data consistency, reducing system load and cost, and improving performance and availability. .
Patent Information
- Application Number
- CN202410517939.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-28
- Publication Date
- 2024-08-30
AI Technical Summary
In e-commerce systems deployed in multiple computer rooms, it is difficult for existing technologies to efficiently ensure the consistency of fund data, especially in the case of high concurrency and large-scale user access. The strong consistency algorithm causes synchronization delays and increased costs. Existing solutions such as The Paxos protocol requires multiple computer rooms to participate at the same time, which increases system load and performance overhead.
Introduce a single point service module to receive all fund operation requests and send them to the same computer room for processing. The data correction module monitors and corrects inconsistent data and uses an asynchronous method to synchronize data, which reduces communication and synchronization overhead and avoids the need for multiple computer rooms. Synchronization delays for simultaneous participation.
It simplifies the data synchronization process, reduces system load, improves performance and availability, avoids the problem of inconsistent fund data, and reduces technology and hardware costs.
Smart Images

Figure CN118568104A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of e-commerce, and in particular relates to a method for ensuring the consistency of financial data in a cross-computer room scenario. Background Art
[0002] With the rapid development of the Internet and e-commerce, website systems usually adopt a distributed multi-computer room deployment architecture worldwide to support the huge number of requests. This architecture can improve the availability, fault tolerance and performance of the system and provide users with more stable and efficient services. In a multi-computer room deployment environment, ensuring the consistency of user data becomes a crucial challenge for user request scenarios across computer rooms, especially for user asset data. Since it is related to the user's assets in the system or website, high data consistency is highly valued. Even if the user's fund request on the website is sent to different computer rooms in a short period of time, it is necessary to ensure that the user's asset data will not be wrong due to data synchronization delays between computer rooms.
[0003] The solutions currently used in the market to solve high consistency mainly use complex synchronization mechanisms or strong consistency algorithms, but due to the complexity of implementation, it will inevitably bring higher costs and increase performance overhead, such as expensive hardware and software investment, as well as professional technical support. Especially in the case of high concurrency and large-scale user access, the difficulty of maintaining data consistency will increase significantly. Taking strong consistency protocols such as Paxos as an example, it stipulates that at least more than half of the computer rooms must complete the data write operation before the data synchronization is considered successful. However, such operations will bring additional communication and synchronization overhead, such as network delays, data transmission, and the time required to reach consensus between multiple nodes. Since each synchronization requires multiple computer rooms to participate at the same time, the response events and the overall load of the system are increased, resulting in a decrease in system performance.
[0004] The patent "Method and system for achieving data consistency in the points system in a multi-active environment of a computer room" (application number: 202310874002.2) proposes to save the points consumption data in a log file, and use the time difference of the heartbeat time to obtain the missing consumption data from the log file, ensure data recovery in abnormal computer rooms, and achieve data consistency in multiple computer rooms. However, this technology has the following disadvantages: (1) The log file needs to save the data of each point consumption, and a separate storage space needs to be added. For systems with frequent business data changes, the storage cost will increase significantly, which is not suitable for large business systems. (2) Points data recovery depends on log records, so it is necessary to design a reliable log writing technical solution to ensure that log writing operations will not result in data loss, which increases the workload of the data synchronization solution. (3) Based on the time difference of the heartbeat time, more technology is needed to maintain the data idempotence of the distributed system. For example, if there is data that is successfully written to the log between the heartbeat time and the downtime, when the abnormal computer room is restored, these successfully written consumption data will be treated as unwritten data. Therefore, performing data recovery completely according to the log records may not only cause more serious data inconsistency, but also require more technical costs to solve the problem of data inconsistency.
[0005] Based on this, a technical method with high synchronization efficiency and high cost-effectiveness is needed to solve the problem of financial data consistency under multi-computer room deployment, which can not only break through the strict control of the strong consistency algorithm, but also does not require additional technology and software and hardware costs. Summary of the invention
[0006] In order to solve the existing technical problems, the present invention provides a method for ensuring the consistency of capital account data in a cross-computer room scenario. The present invention receives capital operation requests issued by all computer rooms through a single-point service module, controls all capital operation requests to be sent to the capital service processing in the same computer room, simplifies the frequent real-time synchronization process in the data synchronization scenario, and avoids the problems caused by synchronization delays; at the same time, the data correction module monitors and corrects inconsistent computer room data, reduces the communication and synchronization overhead brought by strong consistency operations, and since each synchronization does not require multiple computer rooms to participate at the same time, the response event and the overall load of the system are reduced, thereby improving system performance.
[0007] The technical solution of the present invention is to provide a method for ensuring the consistency of fund account data in a cross-computer room scenario, and the specific steps include:
[0008] Step 1: Deploy a single-point service module and a data correction service module that are independent of each computer room. The single-point service module and the data correction service module communicate with each computer room through a dedicated network line. The single-point service module is used to manage the computer room to provide financial services, and the data correction service module is used to monitor whether the data in the financial database of each computer room is consistent.
[0009] Step 2: The client submits the user's fund operation request to the single-point service module. The request includes a request ID, a request type and a request amount. The request type includes query, payment, transfer and freeze. Specifically, a specific tag is added to the fund service interface of each computer room. The client calls the fund service interface to process the request. When the specific tag is obtained, the request is submitted to the single-point service module.
[0010] Step 3: The single-point service module obtains the information of the computer room providing the financial service: the single-point service module reads the address information of the financial service, which includes the computer room number, service IP and port; the single-point service module generates a new request ID for the currently received request, and resends the latest request after the updated request ID to the corresponding computer room according to the address information to manage the update of the financial data;
[0011] Step 4: The computer room responds to the processing of the latest request, and the result is fed back to the client through the single-point service module; if the processing needs to change the fund data of the current computer room, the fund data is updated and the result is fed back after the fund data availability of the computer room is verified; if the processing does not need to change the fund data of the current computer room, the result is directly fed back; the updated fund data is synchronized to other computer rooms using asynchronous technology;
[0012] Step 5: The data correction module periodically reads the fund data of multiple computer rooms for comparison; if the fund data in any computer room is inconsistent, the fund data updated in step 3 is read and transmitted to the computer room with inconsistent data to complete the data update.
[0013] In step 1, the single-point service module periodically sends a heartbeat signal to determine whether the financial service of the computer room is available. The specific steps include:
[0014] Step 1-1: The single-point service module continuously requests the heartbeat interface of the financial service of the computer room; if the number of times the heartbeat signal is not received reaches the threshold, the single-point service module modifies the service status of the computer room to unavailable and modifies the enabled status to closed; the preferred heartbeat signal sending time is 1 time / s, and the threshold is 3 times within 10 seconds;
[0015] Step 1-2: The single-point service module selects the computer rooms with available service status, selects the next computer room in ascending order of computer room number, and changes the enabling status of the computer room to on; transfers the financial service to the computer room, and subsequent requests for the financial service will be automatically routed to the computer room.
[0016] In step 3, the single point service module obtains the request ID and the client address from the received request, and saves the mapping relationship between the request ID of the request and the updated request ID;
[0017] In step 4, the verification process for the availability of funds data in the computer room includes: judging whether the conditions for request processing are met based on the funds data in the computer room; the funds data includes account status and available amount; if the account status is normal and the available amount is greater than the requested amount, the funds data is updated according to the operation type and operation amount, and the request processing is successful; otherwise, the funds data update is not performed and the request processing fails.
[0018] In step 4, the single point service module feeds back the result to the client, specifically including: the single point service module obtains the request ID in the result, uses the mapping relationship saved in step 3 to find the client address corresponding to the request ID, and transmits the result to the client.
[0019] The beneficial effects achieved by the present invention are:
[0020] 1) The present invention introduces a single-point service module to receive fund operation requests issued by all computer rooms, and controls all fund operation requests to be sent to the fund service processing in the same computer room, thereby simplifying the frequent real-time synchronization process in the data synchronization scenario and solving the serious problem caused by synchronization delay in multiple computer rooms. Even if the same customer initiates payment requests in different computer rooms within a short period of time, there will be no inconsistency in fund data because the final services are all provided by the fund service of the same computer room.
[0021] 2) The present invention uses an asynchronous method to synchronize data, and monitors the database of each computer room by introducing a data correction module. For computer rooms with inconsistent data, the data correction module uses the data of the computer room that provides financial services as the standard to correct the data of the inconsistent computer room. Compared with the strong consistency protocol, which strictly requires that most computer rooms must complete the data update operation at the same time, the communication and synchronization overhead caused by the strong consistency operation is reduced, such as network delay, data transmission, and the time required to reach a consensus between multiple nodes. Since each synchronization does not require multiple computer rooms to participate at the same time, the response event and the overall load of the system are reduced, and the system performance is improved.
[0022] 3) The present invention manages the activation of financial services in each computer room through a single-point service module, timely discovers the service status of the computer room through network dedicated line communication, and can dynamically switch to the computer room with normal service, ensuring that the user's financial request is responded to in a timely manner, thereby improving the availability of the system. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic diagram of a process for ensuring the consistency of fund data in a cross-computer room scenario in an embodiment of the present invention;
[0024] Figure 2 A schematic diagram of a process of dynamically switching financial services by a single-point service module in an embodiment of the present invention;
[0025] Figure 3 The present invention is a schematic diagram of a system architecture for ensuring consistency of financial data in a cross-computer room scenario according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0027] In the traditional data synchronization architecture, since the data in different computer rooms must be strictly consistent, when the data in one computer room is updated, the data in another computer room must also be updated in time. Especially for financial data, data inconsistency between different computer rooms will cause serious problems. For example, a user initiates fund payment request X and request Y in a very short period of time. Due to changes in the customer network, the WiFi network is switched to the mobile network, so that request X and request Y are sent to computer room A and computer room B respectively; assuming that the user account has 100 yuan, X requests to pay 60 yuan, and Y requests to pay 50 yuan. After computer room A processes request X, the updated available amount is 40. However, due to the high data synchronization delay, the available amount in computer room B has not been updated in time, and the available amount is still 100 yuan. The Y request is still successful, which eventually causes the customer to overpay 10 yuan. From this, it can be seen that it is necessary to ensure the efficiency of data synchronization between different computer rooms.
[0028] Figure 1 A method for ensuring the consistency of fund data in a cross-computer room scenario in the implementation of the present invention includes the following specific steps:
[0029] Step 101: deploy a single-point service module and a data correction service module separately, independently of each computer room; in order to reduce the impact of network delay on data synchronization, the single-point service module, the data correction service module and each computer room communicate through a dedicated network line; the single-point service module manages the computer room to provide financial services, and the computer room with a normal service status and an enabled status of on can provide financial services; the data correction service module monitors whether the financial database of each computer room has consistent data;
[0030] The single-point service module determines whether the computer room can provide financial services by sending heartbeat signals regularly, such as Figure 2 This is a schematic diagram of a process of dynamically switching fund services in a single-point service module in an embodiment of the present invention. The specific process includes:
[0031] Step 101-1: The single-point service module monitors the financial service status of the computer room: the single-point service module continuously requests the heartbeat interface of the financial service of the computer room; if the heartbeat signal is received, the service is normal and the computer room currently providing financial services is maintained; if the number of times the heartbeat signal is not received reaches the threshold, the service is abnormal and step 101-2 is executed;
[0032] Step 101-2: the single-point service module modifies the service status of the computer room to unavailable, and modifies the enabling status to closed;
[0033] The reason for choosing heartbeat detection is that it can sense both service anomalies and high loads at the same time; too frequent heartbeat detection may increase network load, while too long an interval may cause the system to not respond quickly enough when service problems occur. In the embodiment of the present invention, the heartbeat signal is sent at an interval of 1 time / s. If no signal is received for 3 consecutive times within 10 seconds, the service status of the computer room is unavailable.
[0034] Step 101-3: polling and enabling the computer room with normal fund service: the single-point service module selects the computer room with available service status, selects the next computer room in descending order of computer room number, and changes the enabling status of the computer room to open, so as to transfer the fund service from the abnormal computer room to the new computer room without affecting the normal provision of fund service;
[0035] Step 102: The client submits the user's fund operation request to the single-point service module. The request includes a request ID, a request type and a request amount. The request type includes query, payment, transfer and freeze. Specifically, a specific tag is added to the fund service interface of each computer room. The client calls the fund service interface to process the fund operation request. When the specific tag is obtained, the request is submitted to the single-point service module. The client refers to an application running in the computer room.
[0036] Step 103: Obtain the computer room that provides financial services: The single-point service module reads the address information of the financial service, which includes the computer room number, service IP and port, so as to quickly find the financial service in the computer room; the single-point service module generates a new request ID for the currently received financial operation request, and resends the financial operation request with the updated request ID to the financial service module of the corresponding computer room based on the address information; the financial service module is a module in each computer room that provides financial services, and is used to process financial operation requests and update financial data.
[0037] The single-point service module obtains the request ID and the client address from the received fund operation request, and saves the mapping relationship between the request ID and the new request ID;
[0038] Step 104: In response to the processing of the fund operation request, data synchronization is performed: if the processing needs to change the fund data of the current computer room, the fund data is updated after data verification, and the request processing result is fed back to the single point service module; the request processing result includes success and failure; if the processing does not need to change the fund data of the current computer room, the request processing result is directly fed back to the single point service module; the updated fund data is synchronized to other computer rooms;
[0039] The data verification is a verification of the availability of financial data in the computer room, and the specific process includes: judging whether the conditions for request processing are met based on the financial data in the computer room; the financial data includes account status and available amount; if the account status is normal and the available amount is greater than the requested amount, the financial data is updated according to the operation type and operation amount, and the request is deemed to be successfully processed; otherwise, the financial data is not updated, and the request is deemed to have failed.
[0040] Taking payment operation as an example, according to the above specific embodiment, the user continuously initiates fund payment request X and request Y in a very short time. Due to the change of the customer network, the WiFi network is switched to the mobile network, so that request X and request Y are sent to computer room A and computer room B respectively. Although request X and request Y initiated by the client are in computer room A and computer room B, when calling the fund service interface, request X and request Y are successively passed to the single point service module in the order of submission. The single point service module obtains the computer room that provides fund services. Assuming it is computer room C, request X and request Y are sent to computer room C for processing in sequence. After querying, the user's available amount is 100 yuan. X requests to pay 60 yuan. After processing X's request, the available amount is updated to 40; Y requests to pay 50 yuan. At this time, the available amount is not enough for deduction, and request Y will feedback that the processing is unsuccessful. Since the same customer initiates payment requests in different computer rooms in a short period of time, because the same computer room ultimately provides fund services, there will be no data inconsistency problem, avoiding the abnormal fund data caused by untimely synchronization, and solving the data inconsistency problem in the traditional data synchronization architecture.
[0041] In step 104, the updated fund data is synchronized to other computer rooms in an asynchronous manner; the asynchronous manner is a message queue; when the fund data of a computer room is updated, the updated fund data is sent to the message queue, each computer room monitors the message content of the message queue, and updates the fund data of its own computer room according to the message content;
[0042] Step 105: The operation result is fed back to the client via the single point service module: the single point service module obtains the request ID in the result, finds the original request ID and the corresponding client address by using the mapping relationship in step 103, and transmits the operation result to the client; since the feedback of the request result is a resend request issued by the single point service, after receiving it, the single point service module needs to find the original service request corresponding to the request and return the result to the client corresponding to the original request;
[0043] Step 106: Fund data monitoring and inconsistent data correction of multiple computer rooms: the data correction module periodically reads the fund data of all computer rooms for comparison; if inconsistent fund data appears in any computer room, the current fund data in the computer room of step 103 is obtained and transmitted to the computer room with inconsistent data to complete data update;
[0044] Figure 3 The schematic diagram of an architecture for ensuring the consistency of fund data in a cross-computer room scenario in an embodiment of the present invention specifically includes a computer room, a fund service in the computer room, a single-point service module and a data correction service module; the single-point service module and the data correction service module are independently deployed and communicate with the fund service in the computer room through a dedicated network line;
[0045] The fund service in the computer room is used to process fund operation requests and update fund data.
[0046] In an embodiment of the present invention, the business system is deployed in computer room A, computer room B, computer room C and computer room D, and the financial services in the four computer rooms are financial service A, financial service B, financial service C and financial service D in order; the single-point service module manages the financial services in the four computer rooms, and is responsible for routing requests from each computer room to the computer room that provides financial services; the data correction module is used to monitor whether the financial data of each computer room is consistent, and to notify the financial services in the inconsistent computer room to update the financial data. Compared with the strong consistency protocol that strictly requires more than half of the computer rooms to complete the write operation of updating data, the present invention concentrates the processing of financial operations in one computer room, and through asynchronous means, combined with monitoring and correction, reduces the communication and synchronization overhead brought by strong consistency operations, such as network delays, data transmission, and the time required to reach consensus between multiple nodes. Since each synchronization does not require multiple computer rooms to participate at the same time, the overall load of response events and the system is reduced, and the system performance is improved.
[0047] Beneficial effects of the present invention:
[0048] 1) The present invention introduces a single-point service module to receive fund operation requests issued by all computer rooms, and controls all fund operation requests to be sent to the fund service processing in the same computer room, thereby simplifying the frequent real-time synchronization process in the data synchronization scenario and solving the serious problem caused by synchronization delay in multiple computer rooms. Even if the same customer initiates payment requests in different computer rooms within a short period of time, there will be no inconsistency in fund data because the final services are all provided by the fund service of the same computer room.
[0049] 2) The present invention uses an asynchronous method to synchronize data, and monitors the database of each computer room by introducing a data correction module. For computer rooms with inconsistent data, the data correction module uses the data of the computer room that provides financial services as the standard to correct the data of the inconsistent computer room. Compared with the strong consistency protocol, which strictly requires that most computer rooms must complete the data update operation at the same time, the communication and synchronization overhead caused by the strong consistency operation is reduced, such as network delay, data transmission, and the time required to reach a consensus between multiple nodes. Since each synchronization does not require multiple computer rooms to participate at the same time, the response event and the overall load of the system are reduced, and the system performance is improved.
[0050] 3) The present invention manages the activation of financial services in each computer room through a single-point service module, timely discovers the service status of the computer room through network dedicated line communication, and can dynamically switch to the computer room with normal service, ensuring that the user's financial request is responded to in a timely manner, thereby improving the availability of the system.
[0051] The present invention may also have many other implementation modes. The above embodiments do not limit the present invention in any way. Without departing from the spirit and essence of the present invention, technicians familiar with the field may make various corresponding changes and modifications based on the present invention. All other improvements and applications made to the above embodiments in an equivalent transformation manner should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A method for ensuring the consistency of fund account data in a cross-computer room scenario, characterized in that: include: Step 1: Deploy a single-point service module and a data correction service module that are independent of each computer room. The single-point service module and the data correction service module communicate with each computer room through a dedicated network line. The single-point service module is used to manage the computer room to provide financial services, and the data correction service module is used to monitor whether the data in the financial database of each computer room is consistent. Step 2: The client submits the user's fund operation request to the single-point service module. The request includes a request ID, a request type, and a requested amount. The request type includes query, payment, transfer, and freeze. Specifically, a specific tag is added to the financial service interface of each computer room, and the client calls the financial service interface to process the request. When the specific tag is obtained, the request is submitted to the single-point service module; Step 3: The single-point service module obtains the information of the computer room providing the financial service: The single-point service module reads the address information of the financial service, and the address information includes the computer room number, service IP and port; The single-point service module generates a new request ID for the currently received request, and resends the latest request after the updated request ID to the corresponding computer room according to the address information to manage the update of the fund data; Step 4: The computer room responds to the processing of the latest request and feeds back the result to the client through the single-point service module; if the processing needs to change the fund data of the current computer room, the fund data is updated and the result is fed back after the fund data availability of the computer room is verified; if the processing does not need to change the fund data of the current computer room, the result is directly fed back; and the updated fund data is synchronized to other computer rooms using asynchronous technology; Step 5: The data correction module periodically reads the fund data of multiple computer rooms for comparison; if the fund data in any computer room is inconsistent, the fund data updated in step 3 is read and transmitted to the computer room with inconsistent data to complete the data update.
2. A method for ensuring the consistency of fund account data in a cross-computer room scenario as claimed in claim 1, characterized in that: In step 1, the single-point service module periodically sends a heartbeat signal to determine whether the financial service of the computer room is available. The specific steps include: Step 1-1: The single-point service module continuously requests the heartbeat interface of the financial service of the computer room; if the number of times the heartbeat signal is not received reaches the threshold, the single-point service module modifies the service status of the computer room to unavailable and modifies the enabled status to closed; the preferred heartbeat signal sending time is 1 time / s, and the threshold is 3 times within 10 seconds; Step 1-2: The single-point service module selects the computer rooms with available service status, selects the next computer room in ascending order of computer room number, and changes the enabling status of the computer room to on; transfers the financial service to the computer room, and subsequent requests for the financial service will be automatically routed to the computer room.
3. A method for ensuring the consistency of fund account data in a cross-computer room scenario as claimed in claim 2, characterized in that: In step 3, the single-point service module obtains the request ID and the client address from the received request, and saves the mapping relationship between the request ID of the request and the updated request ID.
4. A method for ensuring the consistency of fund account data in a cross-computer room scenario as claimed in claim 3, characterized in that: In step 4, the verification process for the availability of funds data in the computer room includes: judging whether the conditions for request processing are met based on the funds data in the computer room; the funds data includes account status and available amount; if the account status is normal and the available amount is greater than the requested amount, the funds data is updated according to the operation type and operation amount, and the request processing is successful; otherwise, the funds data update is not performed and the request processing fails.
5. A method for ensuring the consistency of fund account data in a cross-computer room scenario as claimed in claim 4, characterized in that: In step 4, the single point service module feeds back the result to the client, specifically including: the single point service module obtains the request ID in the result, uses the mapping relationship saved in step 3 to find the client address corresponding to the request ID, and transmits the result to the client.
Citation Information
Patent Citations
Multi-computer room storage system
CN104980519A
Method, device and system for realizing data consistency among plurality of machine rooms
CN105162879A
Method for guaranteeing data consistency under remote multi-activity architecture
CN109450988A
Service scheduling method, apparatus, apparatus, and storage medium
CN109508912A
Multi-machine-room data processing method based on micro-services, electronic equipment and storage medium
CN110633175A
Cited By
Business processing method and device of distributed business system and electronic equipment
CN119987955A
