Transaction traffic limiting method, device, equipment, medium and product
By customizing multi-dimensional global flow control rules, limiting current for transaction requests in financial transaction systems, solving the problem that traditional token bucket algorithms cannot cope with high concurrency in private domains, and achieving improved system stability and robustness.
Patent Information
- Application Number
- CN202510594609.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-08
AI Technical Summary
The traditional global current limiting scheme based on token bucket algorithm cannot effectively deal with high concurrency scenarios in different fields in the private domain dimension, resulting in system crash or unavailability.
By customizing multi-dimensional global flow control rules, obtain transaction requests, perform dimension matching, determine the target flow control rules, and determine the token bucket for transaction response based on the number of transaction requests in the target time period and set the threshold.
Effectively prevent system crashes caused by excessive concurrent requests, improve the flow control prevention and emergency response capabilities of the financial transaction system, and improve the robustness of the system.
Smart Images

Figure CN120455378A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a transaction flow limiting method, device, equipment, medium and product. Background Art
[0002] With the rapid development of digital banking services in recent years, the number of users and requests in digital financial systems has also continued to increase, posing significant challenges to system performance and stability. As a key means of ensuring stable system operation, rate limiting is widely used in various services and applications. The core purpose of rate limiting is to limit the number of requests within a specific time window, maintaining system availability and stability and preventing slowdowns or downtime caused by excessive concurrency.
[0003] The token bucket algorithm is one of the most commonly used flow control algorithms in global rate limiting strategies. Its concept is to add a specified number of tokens to a bucket at a constant interval. If the number of tokens reaches the bucket's capacity, no new tokens will be added. When a new request arrives, an attempt is made to obtain a token from the bucket. If a token is obtained, subsequent logic is executed. If no token is available, the service is blocked or denied.
[0004] However, the traditional global flow limiting solution based on the token bucket algorithm can only control the flow of common fields in the public domain dimension of the transaction message, and does not support trial flow control of different fields in the private domain dimension, and cannot effectively deal with various high-concurrency scenarios that appear instantly. Summary of the Invention
[0005] The present invention provides a transaction flow limiting method, device, equipment, medium and product to implement customized multi-dimensional global flow control rules for different transaction requests and achieve global flow limiting.
[0006] According to a first aspect of the present invention, a transaction flow limiting method is provided, comprising:
[0007] Get pending transaction requests;
[0008] Performing dimension matching on the pending transaction request according to the generated rules to determine the target flow control rule corresponding to the pending transaction request;
[0009] According to the target flow control rule, the total number of transaction requests within the target time period and the set threshold, the token bucket belonging to the pending transaction request is determined and a transaction response is performed.
[0010] According to a second aspect of the present invention, a transaction flow limiting device is provided, comprising:
[0011] Request acquisition module, used to obtain pending transaction requests;
[0012] A rule determination module, configured to perform dimension matching on the pending transaction request according to the generated rule, and determine a target flow control rule corresponding to the pending transaction request;
[0013] The response determination module is used to determine the token bucket belonging to the pending transaction request and perform a transaction response based on the target flow control rule, the total number of transaction requests within the target time period and the set threshold.
[0014] According to a third aspect of the present invention, there is provided an electronic device, comprising:
[0015] at least one processor; and
[0016] a memory communicatively connected to the at least one processor; wherein,
[0017] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the transaction flow limiting method described in any embodiment of the present invention.
[0018] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction flow limiting method described in any embodiment of the present invention when executed.
[0019] According to a fifth aspect of the present invention, an embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the transaction flow limiting method of any embodiment of the present invention.
[0020] The technical solution of the embodiment of the present invention obtains pending transaction requests; performs dimension matching on the pending transaction requests according to generation rules to determine the target flow control rules corresponding to the pending transaction requests; and determines the token bucket belonging to the pending transaction requests and performs transaction responses based on the target flow control rules, the total number of transaction requests within the target time period, and a set threshold. By customizing multi-dimensional global flow control rules for different transaction requests, including public and private domains, and performing global flow limiting, it can effectively prevent service unavailability or system crashes caused by excessive concurrent requests, further effectively enhance the flow control prevention and emergency response capabilities of the financial transaction system, and improve the robustness of the transaction system.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 This is a flow chart of a transaction flow limiting method provided according to the first embodiment of the present invention;
[0024] Figure 2 This is an example flow chart of a transaction flow limiting method provided according to the first embodiment of the present invention;
[0025] Figure 3 This is a flow chart of a transaction flow limiting method provided according to the second embodiment of the present invention;
[0026] Figure 4 This is an example flow chart of a transaction flow limiting method provided according to the second embodiment of the present invention;
[0027] Figure 5 This is a structural diagram of a transaction current limiting device provided according to the third embodiment of the present invention;
[0028] Figure 6 It is a schematic structural diagram of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] Example 1
[0032] Figure 1 A flowchart of a transaction flow limiting method is provided for the first embodiment of the present invention. This embodiment is applicable to the situation of global flow limiting of transaction requests in the financial field. The method can be executed by a transaction flow limiting device, which can be implemented in the form of hardware and / or software and can be configured in an electronic device. Figure 1 As shown, the method includes:
[0033] S110: Obtain a pending transaction request.
[0034] In this embodiment, the pending transaction request can be understood as a request message for a financial transaction, such as a transfer request, which may include transaction code, account number, transaction amount and other transaction-related information.
[0035] Specifically, the processor may obtain transaction messages sent by the public domain and the private domain, and obtain transaction requests to be responded to.
[0036] S120: Dimension matching is performed on the transaction request to be responded to according to the generated rules, and the target flow control rule corresponding to the transaction request to be responded to is determined.
[0037] In this embodiment, the generation rule can be understood as a method for generating flow control rules set according to different transaction dimensions. The target flow control rule can be understood as a rule for controlling the response rate of pending transaction requests.
[0038] Specifically, the processor can parse the pending transaction request and extract corresponding dimension data from the parsed data according to the dimension in the generated rule, and then match the dimension value. If an established flow control rule matches the dimension value, the established flow control rule will be used as the target flow control rule for the pending transaction request. If there is no corresponding established flow control rule, the processor can create a new target flow control rule based on the dimension value of the pending transaction request.
[0039] S130: Determine the token bucket for the pending transaction request and perform a transaction response based on the target flow control rule, the total number of transaction requests within the target time period, and the set threshold.
[0040] In this embodiment, the target time period can be understood as a time period set for determining the global transaction request situation. The total number can be understood as the total number of transaction requests obtained within the target time period, which can be transactions belonging to the same merchant or category. The set threshold can be understood as the number threshold used to determine whether it is a hot account. The token bucket can be understood as an algorithm applied to network traffic shaping (Traffic Shaping) and rate limiting (Rate Limiting), which controls the data transmission rate by simulating the generation and consumption of "tokens".
[0041] Specifically, the processor can use the target flow control rules as a query basis to determine whether a token bucket has been established for the transaction request to be responded to. The processor can also combine the total number of transaction requests in the target time period with the set threshold to determine whether the parameters of the token bucket need to be changed, and then determine the token bucket belonging to the transaction request to be responded to, and respond to the transaction using the remaining tokens in the token bucket.
[0042] The technical solution of the embodiment of the present invention obtains pending transaction requests; performs dimension matching on the pending transaction requests according to generation rules to determine the target flow control rules corresponding to the pending transaction requests; and determines the token bucket belonging to the pending transaction requests and performs transaction responses based on the target flow control rules, the total number of transaction requests within the target time period, and a set threshold. By customizing multi-dimensional global flow control rules for different transaction requests, including public and private domains, and performing global flow limiting, it can effectively prevent service unavailability or system crashes caused by excessive concurrent requests, further effectively enhance the flow control prevention and emergency response capabilities of the financial transaction system, and improve the robustness of the transaction system.
[0043] As a first optional embodiment of the first embodiment, based on the above embodiment, it further includes:
[0044] When changes in flow control parameter rules are detected, the token bucket corresponding to the flow control parameter rules is updated.
[0045] In this embodiment, the change of flow control parameter rules can be understood as the change of flow control parameters or flow control rules that trigger the change of token bucket, for example, it may include the change of rules that affect the change of token bucket parameters or the unavailability of flow control parameter rules, etc. The flow control parameters or flow control rules can be allocated manually or by setting programs.
[0046] Specifically, the processor can monitor changes in flow control parameters and flow control rules and respond to customized events. When changes in flow control parameter rules are monitored, the processor can query the corresponding token bucket based on the flow control parameter rules. There are two situations, one is that the token bucket has been established, and the other is that the token bucket has not been established. If the token bucket has been established, the parameters of the token bucket can be updated according to the flow control parameter rules. If it has not been established, a new token bucket can be added to achieve the hot refresh function of global flow control, and perform operations such as adjusting token bucket parameters, adding token buckets, and setting token bucket expiration.
[0047] Furthermore, the steps for updating the token bucket corresponding to the flow control parameter rule can be refined as follows:
[0048] When the flow control parameter rule changes the flow limit value, if the changed flow control rule to which the flow limit value belongs is an existing flow control rule, the token bucket parameters of the changed flow control rule are modified, and when the changed flow control rule is a dynamic flow control rule, the token bucket generated by the old rule is fuzzy deleted; otherwise, a new token bucket is added according to the changed flow control rule; when the flow control parameter rule is an expired flow control rule that is unavailable, the token bucket of the expired flow control rule is set to expire.
[0049] In this embodiment, the flow limit value can be understood as a value used to control the transmission rate. It can be understood that when the flow limit value is modified, the corresponding flow control rule to which it belongs will usually be changed. For example, if the flow limit value of flow control rule A is modified, the changed flow control rule is A. Dynamic flow control rules can be understood as dynamically added flow control rules, such as the rules with default dimension values in the generation rules mentioned below. Fuzzy deletion can be understood as a data deletion data strategy. The core goal is to retain some related information or blur sensitive content when deleting data, rather than completely erase it. Expired flow control rules can be understood as flow control rules that have reached expiration conditions, such as no transaction requests have been received for a period of time.
[0050] Specifically, when the flow control parameter rule changes the flow control value (for example, if the trading volume is high during the day and it is busier, the flow control value can be lowered, and if the trading volume is low at night, the flow control value can be increased), if the flow control rule to which the flow control value is changed is an existing flow control rule, that is, a rule for which a token bucket has been established, the processor can modify the token bucket parameters of the changed flow control rule, and when the flow control rule is changed to a dynamic flow control rule, a fuzzy deletion method is used to delete the old rule and generate a new token bucket. When the flow control rule to which the flow control value is changed is not an existing flow control rule, the processor can add a token bucket according to the changed flow control rule. When the flow control parameter rule is that an expired flow control rule is unavailable, the processor can set the token bucket of the expired flow control rule to expire.
[0051] For example, the updating process of the change rule group can be demonstrated through a specific example. Figure 2This is an example flow chart of a transaction flow limiting method provided in the first embodiment of the present invention. Figure 2 As shown, the steps may be: first obtain the rule group with changes (i.e. the above-mentioned flow control parameter rules), first determine whether the rules are available, and if not, set the token bucket of the expired flow control rules to expire; if the rules are available, determine whether the changed flow control rules are existing flow control rules, and if so, update the token bucket parameters of the changed flow control rules, and when the changed flow control rules are dynamic flow control rules, fuzzy delete the old rules to generate token buckets; if it is not an established token bucket rule, a new token bucket can be added according to the changed flow control rules.
[0052] The first optional embodiment of the first embodiment of the present invention realizes the hot refresh function of global flow control by monitoring the changes in flow control parameters and flow control rules and customizing the response processing of events, and performs operations such as adjusting token bucket parameters, adding token buckets and setting token bucket expiration, thereby providing support for global dynamic flow limiting.
[0053] Furthermore, the goal of global flow control is to reject the flow exceeding the expected value before the financial transaction enters the business process. Therefore, the present invention places the whole step as a flow limiting component at the entrance of the financial transaction program. In addition, when the flow control component has a service exception, it should not affect the normal external service of the application. For this reason, the present invention designs a health check module to enhance the fault tolerance of the component, ensure the reliability of the component, and realize the flow control service degradation and recovery. The component sets a global flow control master switch, whose value is determined by the program configuration file; another health status Boolean value is set, which is dynamically controlled by the program. Whether the global flow control function is available is determined by the global flow control master switch and the service health status. The control logic of the service health status is as follows: (1) Flow control service degradation strategy: when the application starts the overall transaction system, if the flow limiting service is unavailable, the global flow control function will be initialized to an unavailable state, and there is no strong association between the program startup and the successful initialization of the flow control component; during the application service process, if the abnormal handling strategy in the health check module (the number of abnormalities within the specified time window exceeds the set threshold, and the abnormalities include connection failure, connection timeout, unknown abnormalities, etc.) determines that the flow control service is abnormal, then the global flow control is set to unavailable. Notify personnel to check. (2) Flow control service recovery strategy: When the application starts, after the flow control component is initialized, the health check timer task is started. By regularly checking the service status of the flow control cluster (multiple flow control components), when the available nodes are lower than the preset health threshold, the global flow control service is set to unavailable state. On the contrary, if it is higher than the threshold, it is restored to available state.
[0054] Example 2
[0055] Figure 3 This is a flow chart of a transaction flow limiting method provided by the second embodiment of the present invention. This embodiment is a further refinement of the above embodiments. Figure 3As shown, the method includes:
[0056] S301: Obtain a pending transaction request.
[0057] S302: Analyze the transaction request to be responded to and obtain the analysis result.
[0058] S303: If the flow control parameter in the analysis result exceeds the flow limiting threshold, the pending transaction request is not released, and the performance log status value of the pending transaction request is modified to the first value.
[0059] In this embodiment, flow control parameters can be understood as parameters related to flow control, such as the resource access required to respond to pending transaction requests. The flow limiting threshold can be understood as the maximum number of requests or resource accesses allowed per unit time in the system where the processor resides, used to prevent service overload and ensure system stability. Performance logs can be understood as log data recording key performance indicators during the system's flow control process, with their status values reflecting the status of each transaction by carrying flow control fields. The first value can be understood as a numerical representation of the error mode of the pending transaction request.
[0060] Specifically, relevant personnel can pre-set the flow limiting threshold, for example, it can be set for each transaction or uniformly. After receiving the pending transaction request, the processor can parse the pending transaction request and compare the flow control parameters in the parsing result with the flow limiting threshold. If the flow limiting threshold is exceeded, the pending transaction request will not be released, and the performance log status value of the pending transaction request will be modified to the first value, and a setting statement will be thrown, such as throwing a "triggering global flow control rule" error. For example, the first value can be 2, which corresponds to triggering flow limiting.
[0061] S304. Otherwise, extract the dimension data of the parsing result according to the generation rules to obtain the target dimension value.
[0062] In this embodiment, dimension data can be understood as data representing dimensions of interest related to the rule, such as transaction code, account number, transaction amount, transaction channel, transaction scenario, etc. The target dimension value can be understood as the dimension value that matches the generated rule.
[0063] Specifically, when the flow control parameter does not exceed the flow limiting threshold, the processor can extract the dimension data of the parsing result according to the generation rule and determine the target dimension value of interest in the generation rule.
[0064] S305. If the target dimension value matches the generated flow control rule, the matched flow control rule is used as the target flow control rule corresponding to the transaction request to be responded to.
[0065] Specifically, the processor can match the target dimension value with the generated flow control rules to find out whether a flow control rule has been generated under the target dimension value. If so, the processor can use the matched flow control rule as the target flow control rule corresponding to the transaction request to be responded to.
[0066] S306. Otherwise, replace the default dimension value in the generated rule based on the target dimension value to obtain the target flow control rule.
[0067] In this embodiment, the default dimension value can be understood as the dimension value to be filled in.
[0068] Specifically, if there is no matching generated flow control rule, the processor can fill the target dimension value into the default dimension value position in the generated rule to obtain the target flow control rule, and use it as the key of the token bucket to enter the subsequent flow control logic.
[0069] For example, the transaction message for a pending transaction request is: "Public Domain": {"Transaction Code": "ABCD", ...}, "Private Domain": {"Debit Account Number": "1234", ...}. The corresponding generation rule is: "Transaction Code & Debit Account Number = ABCD & ?", where ABCD represents the transaction code corresponding to the pending transaction request, and the question mark is the default dimension value, corresponding to the debit account number dimension. The resulting target flow control rule is: "Transaction Code & Debit Account Number#ABCD & 1234", which is used as the token bucket key to enter the subsequent flow control logic.
[0070] S307. If the target flow control rule is not an established token bucket rule, determine whether it is a hot account based on the target flow control rule, the total number of transaction requests in the target time period, and the set threshold, and generate a token bucket for the transaction requests to be responded to based on the judgment result.
[0071] Hotspot accounts generally refer to accounts that are frequently updated. For example, a large number of account balance update requests are concentrated on a small number of accounts within a short period of time. Although these accounts are few in number, they are updated frequently. Improper handling can cause serious performance issues and affect the normal read and write operations of other accounts.
[0072] Specifically, the processor can first determine whether the target flow control rule has already established a token bucket. If the target flow control rule does not have an established token bucket rule, the processor can determine the total number of transaction requests that fall under the target flow control rule within the target time period and compare it with the set threshold to determine whether the pending transaction request is a hot account. If it is a hot account, the processor can dynamically generate flow control thresholds and time windows and other flow control-related parameters based on the relative hot account to generate a token bucket for the pending transaction request. If it is not a hot account, the processor can generate a token bucket according to the flow control threshold pre-set by the target flow control rule.
[0073] For example, in the token bucket algorithm flow control process, each rule corresponds to an instance, and each instance can be identified by the following three sets of key-value pairs: (1) Configuration parameters: The key is the token name, which is stored using the hash type and includes the time window and quantity of token production. In the present invention, the time window is set to a constant value of 1S, and the number of tokens in the time window is the flow control threshold of the corresponding flow control rule. (2) The remaining number of tokens: The key is "{token name}:value", which is stored using the string type and is used to record the number of currently available tokens. (3) Granted token records: The key is "{token name}:permits", which is stored using the zset type and is used to record the information of tokens that have been granted and not "reclaimed" (including the granting timestamp). "Reclaiming" means deleting expired token records and counting the number. The flow control information is stored in the HashTag method to ensure that individual data is stored in the same instance, and under the same key, requests are processed serially, ensuring data consistency and achieving the purpose of global flow control in a distributed scenario. The logic of the token bucket algorithm is divided into two cases: (1) First access: directly initialize the remaining number of tokens to the number of tokens generated within the time window, then perform a subtraction operation on the remaining number of tokens and record the information of the granted tokens. (2) Non-first access: first clear the records of expired and granted tokens and count them, then add the recovered data back to the remaining number of tokens, then perform a subtraction operation on the remaining number of tokens and record the information of the granted tokens. Throughout the process, the rate limiter will ensure that the number of remaining tokens does not exceed the token upper limit of this window based on the rate limit value. Ultimately, the success of the application operation is determined by whether there are enough available tokens. If it fails, the rate limiter will also calculate the approximate waiting time and return it to the applicant.
[0074] S308. Otherwise, the target flow control rule is used as the target key, and the token bucket corresponding to the target key is determined.
[0075] In this embodiment, the target key can be understood as a method for searching a token bucket.
[0076] Specifically, when the target flow control rule is an established token bucket rule, the processor may use the target flow control rule as a target key to query the corresponding token bucket.
[0077] S309: Response to the pending transaction is performed based on the preset current limiting related information, the number of remaining tokens in the token bucket, and the number of tokens applied for by the pending transaction.
[0078] In this embodiment, the preset flow control related information can be understood as the flow control related information corresponding to the target flow control rule, for example, the time window and quantity, and the flow control threshold corresponding to the target flow control rule, etc. The remaining token number can be understood as the number of tokens remaining in the token bucket that can be granted.
[0079] Specifically, when the number of token applications is less than or equal to the upper limit of tokens in the window in the preset current limiting related information, the processor can perform token granting related operations based on the remaining number of tokens according to the token bucket algorithm logic to respond to the transaction to be responded to. If the remaining number of tokens is 0, the processor can respond by refusing access and returning.
[0080] The technical solution of the embodiment of the present invention pre-screens the transaction requests to be responded to by using the flow limiting threshold, and realizes the early warning, alarm and flow control view functions of the traffic in the form of carrying the flow control field in the performance log. When the flow limiting threshold is not reached, the multi-dimensional global flow control rules are customized for different transaction requests containing public and private domains, and the multi-dimensional global flow limiting of the public and private domains of the message is supported. By determining the total number of transaction requests corresponding to the target flow control rule and combining it with the set threshold, it is judged whether the account to which the transaction request to be responded belongs is a hot account, and based on the judgment result and the target flow control rule, a token bucket belonging to the transaction request to be responded is generated, thereby realizing the dynamic identification and automatic flow limiting of hot accounts in the transaction message, which can effectively improve the flow control prevention and emergency response capabilities of the financial transaction system.
[0081] As a first optional embodiment of the second embodiment, based on the above embodiment, it also includes:
[0082] If the flow control parameter exceeds the warning threshold and does not reach the flow limiting threshold, the pending transaction request will be released, the performance status value of the pending transaction request will be modified to the second value and an early warning will be triggered; if the flow control parameter does not exceed the warning threshold, the pending transaction request will be released and the performance status value will be modified to the third value.
[0083] In this embodiment, the warning threshold value can be understood as a value used to issue a warning prompt, which is less than the current limiting threshold value. The second value can be understood as a value used to indicate that the warning is triggered, for example, it can be 1. The third value can be understood as a value that indicates that the warning is not triggered, for example, it can be 0.
[0084] Specifically, the processor can compare the flow control parameter with the warning threshold. If the flow control parameter exceeds the warning threshold and does not reach the flow limiting threshold, the pending transaction request is released, the performance status value of the pending transaction request is modified to the second value and an early warning is triggered; if the flow control parameter does not exceed the warning threshold, the pending transaction request is released, and the performance status value is modified to the third value.
[0085] In the first optional embodiment of the second embodiment, a flow early warning function is realized by carrying a flow control field in the performance log through such a setting.
[0086] For example, the overall process of this method is demonstrated with a specific example. Figure 4This is an example flow chart of a transaction flow limiting method provided in the second embodiment of the present invention. Figure 4 As shown, it can be divided into three aspects: flow control components, flow control aspects, and transaction logic. First, the transaction logic performs transaction preprocessing on the pending transaction request, that is, it parses and obtains flow control dimension data. When the flow control dimension data is obtained, the flow control aspect determines whether the flow control master switch is on based on the flow control dimension data (that is, accounts that do not need to be subject to flow control can be pre-set through transaction accounts, etc.). If it is not on, the transaction subsequent processing is directly performed on the pending transaction request. If it is on, the generated flow control rules can be matched against the flow control dimension data. If the match is successful, the token is directly obtained from the token bucket. If the token can be obtained, the transaction subsequent processing is performed. If the token cannot be obtained, the transaction rejection is constructed and returned. If the match fails, the target flow control rule can be generated according to the flow control dimension data, and a token bucket is established to obtain the token from it. The flow control component performs health check tasks on schedule, and the global flow control rules and global flow limiting components are used to limit the flow. The system log center generates performance logs and modifies the status value of each transaction.
[0087] Example 3
[0088] Figure 5 This is a structural diagram of a transaction current limiting device provided by the third embodiment of the present invention. Figure 5 As shown, the device includes:
[0089] The request acquisition module 51 is used to obtain the transaction request to be responded to;
[0090] A rule determination module 52 is configured to perform dimension matching on the pending transaction request according to the generated rule, and determine a target flow control rule corresponding to the pending transaction request;
[0091] The response determination module 53 is used to determine the token bucket belonging to the pending transaction request and perform a transaction response based on the target flow control rule, the total number of transaction requests within the target time period and a set threshold.
[0092] The technical solution of the embodiment of the present invention obtains pending transaction requests; performs dimension matching on the pending transaction requests according to generation rules to determine the target flow control rules corresponding to the pending transaction requests; and determines the token bucket belonging to the pending transaction requests and performs transaction responses based on the target flow control rules, the total number of transaction requests within the target time period, and a set threshold. By customizing multi-dimensional global flow control rules for different transaction requests, including public and private domains, and performing global flow limiting, it can effectively prevent service unavailability or system crashes caused by excessive concurrent requests, further effectively enhance the flow control prevention and emergency response capabilities of the financial transaction system, and improve the robustness of the transaction system.
[0093] Furthermore, the rule determination module 52 is specifically configured to:
[0094] Parsing the pending transaction request to obtain a parsing result;
[0095] If the flow control parameter in the analysis result exceeds the flow limit threshold, the pending transaction request is not released, and the performance log status value of the pending transaction request is modified to the first value;
[0096] Otherwise, extracting the dimension data of the parsing result according to the generation rule to obtain the target dimension value;
[0097] If the target dimension value matches the generated flow control rule, the matched flow control rule is used as the target flow control rule corresponding to the pending transaction request;
[0098] Otherwise, the default dimension value in the generated rule is replaced based on the target dimension value to obtain the target flow control rule.
[0099] Optionally, the device further comprises:
[0100] an early warning module configured to release the pending transaction request, modify the performance status value of the pending transaction request to a second value, and trigger an early warning if the flow control parameter exceeds the early warning threshold but does not reach the flow limiting threshold;
[0101] If the flow control parameter does not exceed the warning threshold, the pending transaction request is released and the performance status value is modified to a third value.
[0102] Furthermore, the response determination module 53 is specifically configured to:
[0103] If the target flow control rule is not an established token bucket rule, then based on the target flow control rule, the total number of transaction requests in the target time period and the set threshold, determine whether it is a hot account, and generate a token bucket belonging to the pending transaction request based on the judgment result;
[0104] Otherwise, the target flow control rule is used as the target key, and the token bucket corresponding to the target key is determined;
[0105] Perform a transaction response to the pending transaction based on preset current limiting related information, the number of remaining tokens in the token bucket, and the number of token applications for the pending transaction.
[0106] Optionally, the device further comprises:
[0107] The parameter update module is used to update the token bucket corresponding to the flow control parameter rule when a change in the flow control parameter rule is monitored.
[0108] Furthermore, the parameter updating module is specifically used to:
[0109] When the flow control parameter rule is a flow limit value change, if the flow control rule to which the flow limit value is changed is an existing flow control rule, the token bucket parameter of the changed flow control rule is modified, and when the changed flow control rule is a dynamic flow control rule, the token bucket generated by the old rule is fuzzy deleted;
[0110] Otherwise, add a new token bucket according to the change flow control rules;
[0111] When the flow control parameter rule is an expired flow control rule that is unavailable, the token bucket of the expired flow control rule is set to expire.
[0112] The transaction flow limiting device provided in the embodiment of the present invention can execute the transaction flow limiting method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0113] Example 4
[0114] Figure 6 A schematic diagram of the structure of an electronic device 60 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0115] like Figure 6 As shown, the electronic device 60 includes at least one processor 61 and a memory, such as a read-only memory (ROM) 62, a random access memory (RAM) 63, etc., which is communicatively connected to the at least one processor 61. The memory stores a computer program that can be executed by the at least one processor. The processor 61 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 62 or the computer program loaded from the storage unit 68 into the random access memory (RAM) 63. Various programs and data required for the operation of the electronic device 60 can also be stored in the RAM 63. The processor 61, ROM 62, and RAM 63 are connected to each other via a bus 64. An input / output (I / O) interface 65 is also connected to the bus 64.
[0116] Multiple components in the electronic device 60 are connected to the I / O interface 65, including an input unit 66, such as a keyboard, a mouse, etc.; an output unit 67, such as various types of displays, speakers, etc.; a storage unit 68, such as a magnetic disk, an optical disk, etc.; and a communication unit 69, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 69 allows the electronic device 60 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0117] Processor 61 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of processor 61 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any other suitable processor, controller, microcontroller, etc. Processor 61 executes the various methods and processes described above, such as the transaction flow limiting method.
[0118] In some embodiments, the transaction flow limiting method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 68. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 60 via ROM 62 and / or communication unit 69. When the computer program is loaded into RAM 63 and executed by processor 61, one or more steps of the transaction flow limiting method described above can be performed. Alternatively, in other embodiments, processor 61 can be configured to execute the transaction flow limiting method in any other suitable manner (e.g., via firmware).
[0119] Various embodiments of the systems and techniques described herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system comprising at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0120] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0121] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0122] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0123] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0124] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0125] In one embodiment, the present invention further includes a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the transaction flow limiting method of any embodiment of the present invention.
[0126] The computer program product may be implemented by writing computer program code for performing the operations of the present invention in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0127] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0128] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A transaction flow limiting method, characterized in that: include: Get pending transaction requests; Performing dimension matching on the pending transaction request according to the generated rules to determine the target flow control rule corresponding to the pending transaction request; According to the target flow control rule, the total number of transaction requests within the target time period and the set threshold, the token bucket belonging to the pending transaction request is determined and a transaction response is performed.
2. The method according to claim 1, characterized in that The performing dimension matching on the pending transaction request according to the generated rule to determine the target flow control rule corresponding to the pending transaction request includes: Parsing the pending transaction request to obtain a parsing result; If the flow control parameter in the analysis result exceeds the flow limit threshold, the pending transaction request is not released, and the performance log status value of the pending transaction request is modified to the first value; Otherwise, extracting the dimension data of the parsing result according to the generation rule to obtain the target dimension value; If the target dimension value matches the generated flow control rule, the matched flow control rule is used as the target flow control rule corresponding to the pending transaction request; Otherwise, the default dimension value in the generated rule is replaced based on the target dimension value to obtain the target flow control rule.
3. The method according to claim 2, characterized in that Also includes: If the flow control parameter exceeds the warning threshold but does not reach the flow limiting threshold, the pending transaction request is released, the performance status value of the pending transaction request is modified to a second value, and a warning is triggered; If the flow control parameter does not exceed the warning threshold, the pending transaction request is released and the performance status value is modified to a third value.
4. The method according to claim 1, wherein The determining, based on the target flow control rule, the total number of transaction requests within the target time period, and the set threshold, of a token bucket belonging to the pending transaction request and performing a transaction response, includes: If the target flow control rule is not an established token bucket rule, then based on the target flow control rule, the total number of transaction requests in the target time period and the set threshold, determine whether it is a hot account, and generate a token bucket belonging to the pending transaction request based on the judgment result; Otherwise, the target flow control rule is used as the target key, and the token bucket corresponding to the target key is determined; Perform a transaction response to the pending transaction according to the preset current limiting related information, the number of remaining tokens in the token bucket, and the number of token applications for the pending transaction.
5. The method according to claim 1, wherein Also includes: When a change in a flow control parameter rule is detected, the token bucket corresponding to the flow control parameter rule is updated.
6. The method according to claim 5, characterized in that The updating of the token bucket corresponding to the flow control parameter rule includes: When the flow control parameter rule is a flow limit value change, if the flow control rule to which the flow limit value is changed is an existing flow control rule, the token bucket parameter of the changed flow control rule is modified, and when the changed flow control rule is a dynamic flow control rule, the token bucket generated by the old rule is fuzzy deleted; Otherwise, add a new token bucket according to the change flow control rules; When the flow control parameter rule is an expired flow control rule that is unavailable, the token bucket of the expired flow control rule is set to expire.
7. A transaction current limiting device, characterized in that: include: Request acquisition module, used to obtain pending transaction requests; A rule determination module, configured to perform dimension matching on the pending transaction request according to the generated rule, and determine a target flow control rule corresponding to the pending transaction request; The response determination module is used to determine the token bucket belonging to the pending transaction request and perform a transaction response based on the target flow control rule, the total number of transaction requests within the target time period and the set threshold.
8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the transaction flow limiting method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the transaction flow limiting method according to any one of claims 1 to 6 when executed.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program implements the transaction flow limiting method according to any one of claims 1 to 6.
Citation Information
Cited By
Interface current limiting method based on token bucket algorithm
CN122160330A