Hotspot account bookkeeping method and system

Through asynchronous accounting methods and whitelist weight ratio configuration, the database performance bottleneck problem of the accounting system in high concurrency scenarios is solved, the transaction response rate and user experience are improved, and the transaction success rate is ensured.

CN119168643APending Publication Date: 2024-12-20CITIC AIBANK CORPORATION LIMITED
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411254758.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-09
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

In high concurrency scenarios, the accounting system has caused a database performance bottleneck due to frequent read and write lock balances, which affects transaction response rate and user experience. Although the current limiting measures improve the response rate, they reduce the success rate and affect user experience.

Method used

Using the asynchronous accounting method, determine whether the accounting request meets the asynchronous conditions by configuring the whitelist and weight ratio. If it is met, the transaction amount will be accumulated to the cache queue, register the asynchronous accounting flow table and write it to the message queue, and after applying for the token Conduct synchronous accounting to ensure transaction success rate.

Benefits of technology

Without affecting the transaction success rate, the high concurrency pressure of the accounting system is alleviated, the transaction response rate is improved, the peaks and valleys are cut, the overall database is slowed down, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119168643A_ABST
    Figure CN119168643A_ABST
Patent Text Reader

Abstract

The invention relates to a hot account bookkeeping method and system. The method comprises the following steps: setting an asynchronous bookkeeping condition; acquiring an accounting request, and judging whether the accounting request meets an asynchronous accounting condition or not; if the bookkeeping request meets an asynchronous bookkeeping condition, accumulating a transaction amount and storing the transaction amount in a cache queue; acquiring information corresponding to the bookkeeping request, registering an asynchronous bookkeeping flow table, and acquiring a registration result; whether the registration result is successful or not is judged, and if the registration result is successful, the information is written into a message queue; the payment system reads the information in the message queue and applies for a token; judging whether the token application is successful or not, and if the token application is successful, initiating the bookkeeping request to perform synchronous bookkeeping; and deducting the transaction amount in the cache queue, and deleting the information in the message queue if the information consumption is successful. The problem of time consumption increase caused by hot account bookkeeping under high concurrency is solved, and meanwhile, the success rate is considered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a hotspot account accounting method and system. Background Art

[0002] As payment demands continue to grow, more and more users are gradually using online payments, and the requirements for the stability and reliability of payment systems are becoming increasingly higher. The response rate of the payment system is directly related to user satisfaction with payment products.

[0003] In this context, for accounting needs in certain specific scenarios, such as high concurrency scenarios for a single account: batch deductions, salary payments, etc., users also require extremely high response rates. Due to the characteristics of the scenarios, the accounting system needs to lock the balance for each transaction, and a large number of lock requests are queued, which increases the overall time consumption. In serious cases, it even affects the entire application cluster or database abnormalities, causing large-scale failures. For such scenarios, the usual practice is to adopt flow limiting measures to reject data that exceeds the flow range. Although the overall response rate is improved and the system security is guaranteed, the success rate is lost, affecting the user experience. At present, the main defect is that the database pressure caused by the high concurrency of the accounting system may slow down the database as a whole, affecting other businesses and even affecting other database instances in the same physical machine cluster. The large number of reading and writing balances in the accounting operation to lock the table will increase the overall transaction time consumption, poor user experience, and it is very easy to exceed the assessment threshold of transaction time consumption of financial institutions such as China UnionPay. The overall success rate is reduced due to flow limiting technology, which leads to new user experience problems. Summary of the invention

[0004] In order to solve at least one of the problems mentioned in the above background technology, the present invention proposes a hotspot account accounting method and system, which solves the database performance bottleneck problem caused by frequent reading and writing of lock balances of hotspot accounts without affecting the transaction success rate.

[0005] To achieve the above objectives, the technical solutions adopted by the present invention include:

[0006] A hotspot account accounting method, comprising:

[0007] Set asynchronous accounting conditions;

[0008] Obtaining an accounting request, and determining whether the accounting request satisfies an asynchronous accounting condition;

[0009] If the accounting request meets the asynchronous accounting condition, the transaction amount is accumulated and stored in the cache queue;

[0010] Obtain information corresponding to the accounting request, register an asynchronous accounting flow table, and obtain a registration result;

[0011] Determine whether the registration result is successful, and if the registration result is successful, write the information into the message queue;

[0012] The payment system reads the information in the message queue and applies for a token;

[0013] Determine whether the token application is successful, and if so, initiate the accounting request to perform synchronous accounting;

[0014] The transaction amount in the cache queue is deducted, the information consumption is successful, and the information in the message queue is deleted.

[0015] Furthermore, the setting of asynchronous accounting conditions includes: configuring a whitelist and setting a weight ratio.

[0016] Further, the obtaining of the accounting request and determining whether the accounting request satisfies the asynchronous accounting condition includes:

[0017] Determine whether the account corresponding to the accounting request is in the whitelist;

[0018] If the account corresponding to the accounting request is in the whitelist, determining whether the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount;

[0019] If the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount, the accounting request meets the asynchronous accounting condition;

[0020] Otherwise, synchronous accounting is performed.

[0021] Further, the method further comprises: writing the message into a database before writing the message into a message queue;

[0022] A scheduled task is set to regularly check and process failed transactions. When the number of failures in writing the same information into the message queue exceeds a threshold, database downgrade processing is adopted.

[0023] Furthermore, the method also includes: setting a maximum number of consumption failures, and when the number of unsuccessful information consumption reaches the maximum number, downgrading the database is performed.

[0024] Furthermore, the method further includes: if the token application fails, giving up the current consumption, re-reading the information, and waiting for the next token application to succeed before continuing the consumption.

[0025] The present invention also relates to a hotspot account accounting system, comprising:

[0026] Setting module, used to set asynchronous accounting conditions;

[0027] A first judgment module is used to obtain an accounting request and judge whether the accounting request meets the asynchronous accounting condition; if the accounting request meets the asynchronous accounting condition, the transaction amount is accumulated and stored in the cache queue;

[0028] The second judgment module is used to obtain information corresponding to the accounting request, register the asynchronous accounting flow table, and obtain the registration result; determine whether the registration result is successful, and if the registration result is successful, write the information into the message queue;

[0029] The third judgment module is used for the payment system to read the information in the message queue and apply for a token; determine whether the token application is successful, and if the token application is successful, initiate the accounting request for synchronous accounting;

[0030] The processing module is used to deduct the transaction amount in the cache queue, and if the information is consumed successfully, delete the information in the message queue.

[0031] The present invention also relates to a computer-readable storage medium, on which a computer program is stored, and the computer program implements the above method when executed by a processor.

[0032] The present invention also relates to an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the above method when executing the computer program.

[0033] The present invention also relates to a computer program product, comprising a computer program and / or instructions, characterized in that the computer program and / or instructions implement the steps of the above method when executed by a processor.

[0034] The beneficial effects of the present invention are:

[0035] The transaction success rate is guaranteed, and the high-concurrency accounting scenarios in online transactions are smoothed out. First, the online pressure of the accounting system is relieved, and second, the overall transaction response rate is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 It is a flow chart of the hotspot account accounting method of the present invention.

[0037] Figure 2 It is a schematic diagram of the structure of the hotspot account accounting system of the present invention. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0039] It should be understood that in the description of the present application, unless the context clearly requires otherwise, words such as "include", "comprises", and the like in the entire specification and claims should be interpreted as having an inclusive meaning rather than an exclusive or exhaustive meaning; that is, the meaning of "including but not limited to".

[0040] It should also be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, "plurality" means two or more.

[0041] It should be noted that the terms "S1", "S2", etc. are only used for the purpose of describing the steps, and do not specifically refer to the order or sequence, nor are they used to limit the present application. They are only for the convenience of describing the method of the present application, and cannot be understood as indicating the order of the steps. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in this field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by the present application.

[0042] The first aspect of the present invention relates to a process of steps as follows Figure 1 The hotspot account accounting method shown includes:

[0043] Set asynchronous accounting conditions;

[0044] Specifically, in the embodiment of the present application, setting the asynchronous accounting conditions includes configuring a whitelist and setting a weight ratio. According to risk prevention and control, the asynchronous accounting whitelist is pre-configured to allow only small transactions (the maximum amount is configurable); and the maximum concurrency (number of token buckets) during asynchronous accounting is set.

[0045] The database configuration is used and saved synchronously in redis. The format example is as follows:

[0046] Key: System Number: Business Scenario: Account Number

[0047] Value:{"open":"1","maxAmtLimit":"20000.00","proportion":"0.7","rate":"30"}

[0048] The following table shows examples of field values:

[0049]

[0050] In this embodiment, necessary parameter, technical and business verification is required. The accounting system is called to query the legality, status and account balance information of the requested accounting account.

[0051] Obtaining an accounting request, and determining whether the accounting request satisfies an asynchronous accounting condition;

[0052] Specifically, in the embodiment of the present application, it is determined whether the account corresponding to the accounting request is in the whitelist;

[0053] If the account corresponding to the accounting request is in the whitelist, determining whether the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount;

[0054] If the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount, the accounting request meets the asynchronous accounting condition; otherwise, synchronous accounting is performed.

[0055] For example, 100 yuan has been cached, the transaction amount is 50 yuan, the account balance is 200 yuan, and the weight ratio is set to 0.7; then 100+50<200*0.7 is not true, the condition is not met, and the asynchronous accounting process is exited and synchronous accounting is used; if the above conditions set the weight ratio to 0.8, then 100+50<200*0.8 is true, and asynchronous accounting is performed. The calculation logic uses redis Lua script to ensure atomic operations.

[0056] Redis data structure example:

[0057] Key: System number: Transaction scenario: Transaction date: Account number

[0058] Value: cache accumulated amount

[0059] If the accounting request meets the asynchronous accounting conditions, the transaction amount is accumulated and stored in a cache queue, such as redis;

[0060] When the asynchronous accounting conditions are not met, synchronous accounting is performed directly and the accounting results are returned to the upstream system.

[0061] Obtain information corresponding to the accounting request, register an asynchronous accounting flow table, and obtain a registration result;

[0062] Determine whether the registration result is successful, and if the registration result is successful, write the information into a message queue, such as an MQ queue;

[0063] If the registration fails, the synchronous accounting will be performed directly and the accounting results will be returned to the upstream system.

[0064] Asynchronous accounting aims to reduce peak loads and fill valleys, and it is necessary to use necessary flow limiting methods, and common flow limiting methods generally include leaky bucket algorithm, token bucket algorithm, sliding window algorithm, etc. The embodiment of the present invention adopts the token bucket algorithm.

[0065] The payment system reads the information in the message queue and applies for a token;

[0066] Determine whether the token application is successful, and if so, initiate the accounting request to perform synchronous accounting;

[0067] The transaction amount in the cache queue is deducted, the information consumption is successful, and the information in the message queue is deleted.

[0068] Specifically, in an embodiment of the present invention, each application in the payment system is a consumer, and reads information from the MQ queue at regular intervals. When the information is read successfully, apply for a token from the token bucket (such as setting the number of tokens per second in the token bucket to 10); when there is too much information in the MQ queue, the application fails to apply for a token, then the current consumption is abandoned, the information is read again, the information is not discarded, and the consumption is continued after the next token application. If the token application is successful, the accounting system is called to complete the accounting. The total amount of the MQ queue cache is deducted, and its value is the current transaction amount. Return consumption success, and delete the information in the message queue.

[0069] In some embodiments, when the MQ queue middleware fails, the database downgrade process is used. Specifically, the message is written to the database before the information is written to the MQ queue; a scheduled task is set to regularly check and process failed transactions. When the number of failures to write the same information to the message queue exceeds a threshold, for example, 3 times, the database downgrade process is used to automatically turn off the overall asynchronous accounting switch, print key logs, monitor alarms, notify the operation and maintenance personnel to find out, and reset the switch after manual confirmation of recovery.

[0070] In some embodiments, when the redis middleware fails, for example, when information consumption fails, it waits for the next time to continue consumption. At the same time, in order to prevent the message content from being incorrect or other problems from causing the message to be consumed unsuccessfully, the maximum number of times the information is consumed is set. For example, the message is set to be consumed at most three times. If it is still unsuccessful, the database is downgraded to ensure that the information can eventually be consumed.

[0071] For another example, the amount in the cache queue cannot be deducted, which is equivalent to a slight increase in the weight. The overall impact is negligible and no special processing is required.

[0072] Another aspect of the present invention also relates to a hotspot account accounting method system, the structure of which is as follows: Figure 2 As shown, including:

[0073] Setting module, used to set asynchronous accounting conditions;

[0074] A first judgment module is used to obtain an accounting request and judge whether the accounting request meets the asynchronous accounting condition; if the accounting request meets the asynchronous accounting condition, the transaction amount is accumulated and stored in the cache queue;

[0075] The second judgment module is used to obtain information corresponding to the accounting request, register the asynchronous accounting flow table, and obtain the registration result; determine whether the registration result is successful, and if the registration result is successful, write the information into the message queue;

[0076] The third judgment module is used for the payment system to read the information in the message queue and apply for a token; determine whether the token application is successful, and if the token application is successful, initiate the accounting request for synchronous accounting;

[0077] The processing module is used to deduct the transaction amount in the cache queue, and if the information is consumed successfully, delete the information in the message queue.

[0078] By using this system, the above-mentioned operation processing method can be executed and the corresponding technical effects can be achieved.

[0079] An embodiment of the present invention also provides a computer-readable storage medium capable of implementing all the steps in the scheduled task monitoring method in the above embodiment, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, all the steps in the scheduled task monitoring method in the above embodiment are implemented.

[0080] An embodiment of the present invention also provides an electronic device for executing the above method. As an implementation device of the method, the electronic device has at least a processor and a memory, and in particular, the memory stores data and related computer programs required for executing the method, and the processor calls the data and programs in the memory to execute all steps of the implementation method and obtains the corresponding technical effect.

[0081] Preferably, the electronic device may include a bus architecture, the bus may include any number of interconnected buses and bridges, and the bus will include various circuits linked together by one or more processors and memories. The bus may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are all well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the receiver and transmitter. The receiver and transmitter may be the same component, i.e., a transceiver, providing a unit for communicating with various other systems over a transmission medium. The processor is responsible for managing the bus and general processing, while the memory may be used to store data used by the processor when performing operations.

[0082] In addition, the electronic device may further include components such as a communication module, an input unit, an audio processor, a display, and a power supply. The processor (or controller, operation control) used may include a microprocessor or other processor device and / or a logic device, which receives input and controls the operation of various components of the electronic device; the memory may be one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices, which may store the above-mentioned related data information, and may also store a program for executing related information, and the processor may execute the program stored in the memory to realize information storage or processing, etc.; the input unit is used to provide input to the processor, for example, it may be a key or a touch input device; the power supply is used to provide power to the electronic device; the display is used to display display objects such as images and text, for example, it may be an LCD display. The communication module is a transmitter / receiver that sends and receives signals via an antenna. The communication module (transmitter / receiver) is coupled to the processor to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal. Based on different communication technologies, multiple communication modules may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module (transmitter / receiver) is also coupled to a speaker and a microphone via an audio processor to provide an audio output via the speaker and receive an audio input from the microphone, thereby realizing a common telecommunication function. The audio processor may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor is also coupled to a central processor, so that recording can be performed on the machine through the microphone, and the sound stored on the machine can be played through the speaker.

[0083] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0084] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.

[0085] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0086] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0087] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A hotspot account accounting method, characterized in that: include: Set asynchronous accounting conditions; Obtaining an accounting request, and determining whether the accounting request satisfies an asynchronous accounting condition; If the accounting request meets the asynchronous accounting condition, the transaction amount is accumulated and stored in the cache queue; Obtain information corresponding to the accounting request, register an asynchronous accounting flow table, and obtain a registration result; Determine whether the registration result is successful, and if the registration result is successful, write the information into the message queue; The payment system reads the information in the message queue and applies for a token; Determine whether the token application is successful, and if so, initiate the accounting request to perform synchronous accounting; The transaction amount in the cache queue is deducted, the information consumption is successful, and the information in the message queue is deleted.

2. The method according to claim 1, characterized in that The setting of asynchronous accounting conditions includes: configuring a whitelist and setting a weight ratio.

3. The method according to claim 2, characterized in that The obtaining of the accounting request and determining whether the accounting request satisfies the asynchronous accounting condition comprises: Determine whether the account corresponding to the accounting request is in the whitelist; If the account corresponding to the accounting request is in the whitelist, determining whether the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount; If the product of the account balance of the account and the weight ratio is greater than the sum of the total amount of the cache queue and the current transaction amount, the accounting request meets the asynchronous accounting condition; Otherwise, synchronous accounting is performed.

4. The method according to claim 3, characterized in that The method further comprises: writing the message into a database before writing the message into a message queue; A scheduled task is set to regularly check and process failed transactions. When the number of failures in writing the same information into the message queue exceeds a threshold, database downgrade processing is adopted.

5. The method according to claim 4, characterized in that The method further comprises: setting a maximum number of consumption failures, and when the number of unsuccessful information consumption reaches the maximum number, performing database downgrade processing.

6. The method according to any one of claims 1 to 5, characterized in that The method further includes: if the token application fails, giving up the current consumption, re-reading the information, and waiting for the next token application to succeed before continuing the consumption.

7. A hotspot account accounting system, characterized in that: include: Setting module, used to set asynchronous accounting conditions; A first judgment module is used to obtain an accounting request and judge whether the accounting request meets the asynchronous accounting condition; If the accounting request meets the asynchronous accounting condition, the transaction amount is accumulated and stored in the cache queue; The second judgment module is used to obtain information corresponding to the accounting request, register the asynchronous accounting flow table, and obtain the registration result; determine whether the registration result is successful, and if the registration result is successful, write the information into the message queue; The third judgment module is used for the payment system to read the information in the message queue and apply for a token; determine whether the token application is successful, and if the token application is successful, initiate the accounting request for synchronous accounting; The processing module is used to deduct the transaction amount in the cache queue, and if the information is consumed successfully, delete the information in the message queue.

8. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising a computer program and / or instructions, characterized in that: When the computer program and / or the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.