A method and apparatus for processing a transaction
Patent Information
- Application Number
- CN202310258598.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-16
- Publication Date
- 2026-09-22
- Estimated Expiration
- 2043-03-16
AI Technical Summary
由于批处理交易的高并发和流量大的特点,会出现批处理交易占用大量资源,影响到联机交易的正常进行
[0018]本发明实施例提供的交易的处理方法及装置,能够接收批处理调用端发送的批量调用请求,并为每个批量调用请求设置批量标签;根据批量标签统计当前时段的批量调用请求数量;根据所述当前时段的联机服务预留提供者数量和服务提供者总数,获得当前时段的批处理调用阈值;若判断获知所述当前时段的批处理调用数量大于所述当前时段的批处理调用阈值,则向批处理调用端发送限流指示信息,以使得所述批处理调用端在设定时间段内停止发送批量调用请求,能够在保障联机交易的情况下,减少批量调用请求出现失败的情况,提高批处理服务处理的可靠性。
Smart Images

Figure CN116320020B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a method and apparatus for processing transactions. Background Technology
[0002] Currently, banks can process transactions in two ways: batch processing and online processing. Online transactions have high requirements for real-time performance, while batch transactions usually take a long time to process and consume more resources.
[0003] In existing technologies, online transactions and batch transactions often occur simultaneously during bank business processing. Due to the high concurrency and large volume of batch transactions, they can consume significant resources, affecting the normal operation of online transactions. Therefore, developing a transaction processing method that ensures the smooth operation of online transactions has become a crucial issue that urgently needs to be addressed in this field. Summary of the Invention
[0004] To address the problems in the prior art, embodiments of the present invention provide a transaction processing method and apparatus that can at least partially solve the problems existing in the prior art.
[0005] In a first aspect, the present invention proposes a transaction processing method, comprising:
[0006] Receive batch call requests sent by the batch processing client, each batch call request carrying a batch tag;
[0007] The number of batch call requests in the current time period is counted based on batch tags;
[0008] The batch processing call threshold for the current time period is obtained based on the number of online service reserved providers and the total number of service providers for the current time period; wherein, the number of online service reserved providers for the current time period is obtained in advance;
[0009] If it is determined that the number of batch calls in the current time period is greater than the batch call threshold in the current time period, a rate limiting instruction is sent to the batch call client so that the batch call client stops sending batch call requests.
[0010] Secondly, the present invention provides a transaction processing apparatus, comprising:
[0011] The receiving module is used to receive batch call requests sent by the batch processing client. Each batch call request carries a batch tag.
[0012] The statistics module is used to count the number of batch call requests in the current time period based on batch tags;
[0013] The acquisition module is used to obtain the batch processing call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein, the number of online service reserved providers in the current time period is obtained in advance;
[0014] The sending module is used to send a rate limiting instruction to the batch processing caller after determining that the number of batch processing calls in the current time period is greater than the batch processing call threshold in the current time period, so that the batch processing caller stops sending batch call requests.
[0015] Thirdly, the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the transaction processing method described in any of the above embodiments.
[0016] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the transaction processing method described in any of the above embodiments.
[0017] Fifthly, the present invention provides a computer program product, the computer program product comprising a computer program, which, when executed by a processor, implements the transaction processing method described in any of the above embodiments.
[0018] The transaction processing method and apparatus provided in this embodiment of the invention can receive batch call requests sent by a batch processing caller and set a batch tag for each batch call request; count the number of batch call requests in the current time period based on the batch tag; obtain the batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, a rate limiting instruction is sent to the batch processing caller to cause the batch processing caller to stop sending batch call requests within a set time period. This can reduce the failure of batch call requests while ensuring online transactions and improve the reliability of batch processing services. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings:
[0020] Figure 1This is a schematic diagram of the transaction processing system provided in the first embodiment of the present invention.
[0021] Figure 2 This is a flowchart illustrating the transaction processing method provided in the second embodiment of the present invention.
[0022] Figure 3 This is a flowchart illustrating the transaction processing method provided in the third embodiment of the present invention.
[0023] Figure 4 This is a flowchart illustrating the transaction processing method provided in the fourth embodiment of the present invention.
[0024] Figure 5 This is a schematic diagram of the transaction processing device provided in the fifth embodiment of the present invention.
[0025] Figure 6 This is a schematic diagram of the transaction processing device provided in the sixth embodiment of the present invention.
[0026] Figure 7 This is a schematic diagram of the transaction processing device provided in the seventh embodiment of the present invention.
[0027] Figure 8 This is a schematic diagram of the transaction processing device provided in the eighth embodiment of the present invention.
[0028] Figure 9 This is a schematic diagram of the physical structure of the electronic device provided in the ninth embodiment of the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Here, the illustrative embodiments and their descriptions are used to explain the present invention, but are not intended to limit the present invention. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be arbitrarily combined with each other. The acquisition, storage, use, and processing of data in the technical solutions of this application all comply with relevant laws and regulations. The user information in the embodiments of this application is obtained through legal and compliant means, and the acquisition, storage, use, and processing of user information have been authorized and agreed upon by the customer.
[0030] Figure 1 This is a schematic diagram of the transaction processing system provided in the first embodiment of the present invention, as shown below. Figure 1 As shown, the transaction processing system provided in this embodiment of the invention includes a batch processing call terminal 1, an online call terminal 2, a rate limiting center 3, and a distributed service cluster 4, wherein:
[0031] The rate limiting center 3 is communicatively connected to the batch processing call terminal 1, the online call terminal 2, and the distributed service cluster 4. When processing batch transactions, the batch processing call terminal 1 sends a batch call request to the rate limiting center 3. When processing online transactions, the online call terminal 2 sends an online call request to the rate limiting center 3. The rate limiting center 3 executes the transaction processing method provided in this embodiment of the invention, distinguishes between online traffic and batch processing traffic, controls batch processing traffic, and improves the reliability of online transactions. The rate limiting center 3 distributes batch call requests and / or online call requests to the distributed service cluster 4 for processing.
[0032] Among them, batch processing call terminal 1 can be a server or a server cluster; online call terminal 2 can be a server or a server cluster; rate limiting center 3 includes but is not limited to a server; distributed service cluster 4 includes multiple servers.
[0033] The following describes the specific implementation process of the transaction processing method provided in this embodiment of the invention, taking the rate limiting center as the execution subject as an example.
[0034] Figure 2 This is a flowchart illustrating the transaction processing method provided in the second embodiment of the present invention, as shown below. Figure 2 As shown, the transaction processing method provided in this embodiment of the invention includes:
[0035] S201. Receive batch call requests sent by the batch processing client, each batch call request carrying a batch tag;
[0036] Specifically, each batch processing client can send a batch call request to the rate limiting center. Before sending the batch call request, a batch tag is set for each batch call request. The rate limiting center receives the batch call requests sent by the batch processing clients, and each batch call request carries a batch tag. After receiving each batch call request, the rate limiting center transmits the batch tag along the call chain of the batch processing transaction corresponding to the batch call request, thereby achieving full-link coloring of the batch processing transaction and identifying the batch processing traffic. The batch tag can be an encoding, string, etc., and can be set according to actual needs; this embodiment of the invention does not impose limitations.
[0037] S202. Count the number of batch call requests in the current time period based on the batch tags;
[0038] Specifically, the rate limiting center can count the number of received batch call requests. After the batch transaction corresponding to each batch call request is processed, it receives feedback information indicating that the batch call request processing is complete, thus enabling it to count the number of processed batch call requests. Based on the number of received batch call requests and the number of processed batch call requests, the rate limiting center can calculate the number of batch call requests in the current time period. Here, the current time period refers to the time period to which the current time belongs. Each time period is preset and set according to actual needs; this embodiment of the invention does not impose any limitations.
[0039] For example, if the rate limiting center counts the number of batch tags issued as 'a' and the number of batch tags revoked as 'b', then the number of batch call requests in the current time period is 'c' = 'ab'.
[0040] For example, a day's 24 hours can be divided into 24 equal periods, with each hour being one period.
[0041] S203. Based on the number of online service reserved providers and the total number of service providers in the current time period, obtain the batch processing call threshold for the current time period; wherein, the number of online service reserved providers in the current time period is obtained in advance;
[0042] Specifically, the rate limiting center obtains the batch processing call threshold for the current time period based on the total number of service providers and the number of online service reserved providers for the current time period. The total number of service providers can be the total number of servers in the distributed service cluster. The number of online service reserved providers for the current time period is pre-determined and can vary across different time periods. Typically, there are more online transactions during the day and more batch processing transactions at night. By dynamically adjusting the number of online service reserved providers for each time period, resources are fully utilized to process batch processing transactions while prioritizing online transactions, thus improving the reliability of transaction processing. The number of online service reserved providers for the current time period refers to the number of servers reserved for processing online services.
[0043] For example, the difference between the total number of service providers and the number of online service reserved providers in the current time period is used as the batch call threshold for the current time period.
[0044] S204. If it is determined that the number of batch calls in the current time period is greater than the batch call threshold in the current time period, a rate limiting instruction is sent to the batch call terminal so that the batch call terminal stops sending batch call requests.
[0045] Specifically, the rate limiting center compares the number of batch processing calls in the current time period with the batch processing call threshold for the current time period. If the number of batch processing calls in the current time period exceeds the batch processing call threshold, it indicates that there are no idle resources to process more batch processing services. To prevent batch call requests from failing, the rate limiting center sends a rate limiting instruction to the batch processing caller. After receiving the rate limiting instruction, the batch processing caller stops sending batch call requests to the rate limiting center, so that resources can be used to process the already sent batch call requests. The set time period is determined based on practical experience and is not limited in this embodiment of the invention.
[0046] The transaction processing method provided in this embodiment of the invention can receive batch call requests sent by a batch processing caller and set a batch tag for each batch call request; count the number of batch call requests in the current time period based on the batch tags; obtain the batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, a rate limiting instruction is sent to the batch processing caller to cause the batch processing caller to stop sending batch call requests within a set time period. This can reduce the failure of batch call requests while ensuring online transactions, thereby improving the reliability of batch processing services. Furthermore, since the number of online service reserved providers and the batch call threshold can be dynamically adjusted in each time period, resources can be fully utilized for batch transaction processing while prioritizing online transactions, thus improving resource utilization.
[0047] Figure 3 This is a flowchart illustrating the transaction processing method provided in the third embodiment of the present invention, as shown below. Figure 3 As shown, based on the above embodiments, further, obtaining the number of online service reserved providers for the current time period includes:
[0048] S301. Obtain the online service call frequency corresponding to the current time period based on the number of online service calls in a preset number of historical time periods corresponding to the current time period;
[0049] Specifically, historical data on online service calls can be collected, and the number of connection service calls in each historical period can be statistically analyzed from this data. From the number of connection service calls in each historical period, the number of connection service calls in a preset number of historical periods corresponding to the current period can be obtained. Then, the average of the number of connection service calls in the preset number of historical periods corresponding to the current period can be calculated to obtain the online service call frequency for the current period. The historical periods corresponding to the current period are the same as the current period but different on the same date. The preset number is set according to actual needs, and this embodiment of the invention does not impose a limitation.
[0050] For example, a 24-hour day can be divided into 24 equal time slots, with each hour representing one time slot. The current time slot is 10:00-11:00, and the corresponding historical time slots are the periods from 10:00-11:00 prior to the date to which the current time slot belongs. The number of online service calls for the 15 historical time slots corresponding to the current time slot (10:00-12:00) can be obtained, and the average of these 15 historical time slots can be used as the online service call frequency for the current time slot.
[0051] S302. Obtain the average service time based on the time consumed by each online service within a preset historical time period;
[0052] Specifically, the system can obtain the successfully processed online services and the time consumed by each online service within a preset historical time period. By defining the successfully processed online services within the preset historical time period as the online services within that period, the system can obtain the time consumed by each online service within that period, and then calculate the total number of online services within that period. Finally, the system calculates the quotient of the sum of the time consumed by each online service within the preset historical time period and the total number of online services within that period to obtain the average service time. The preset historical time period can be set according to actual needs, and this embodiment of the invention does not impose any limitations.
[0053] S303. Based on the online service call frequency corresponding to the current time period, the average service consumption time, and the total number of service providers, obtain the number of online service reserved providers for the current time period.
[0054] Specifically, the rate limiting center obtains the number of online service reserved providers for the current time period based on the online service call frequency corresponding to the current time period, the average service consumption time, and the total number of service providers.
[0055] For example, it can be based on the formula Calculate the number of online service reserved providers for the current time period. ,in, This indicates the online service call frequency corresponding to the current time period. This indicates the average service time. This indicates rounding up to the nearest integer.
[0056] Figure 4 This is a flowchart illustrating the transaction processing method provided in the fourth embodiment of the present invention, as shown below. Figure 4 As shown, based on the above embodiments, the transaction processing method provided by the embodiments of the present invention further includes:
[0057] S401. Obtain the current length of the online queue based on the number of received online call requests and the number of processed online call requests;
[0058] Specifically, after receiving an online call request, the rate limiting center counts the number of received online call requests. Since batch call requests carry batch tags, while online call requests do not, the rate limiting center can distinguish between online call requests and batch call requests based on the batch tags. After the online transaction corresponding to the online call request is processed, the rate limiting center receives the processing completion result and counts the number of processed online call requests. The rate limiting center calculates the difference between the number of received online call requests and the number of processed online call requests, and uses this difference as the current length of the online queue.
[0059] S402. Based on the total number of service providers, the response time limit for online services, and the average service time, obtain the maximum length of the online queue; wherein, the average service time is obtained in advance;
[0060] Specifically, the rate limiting center can obtain the maximum length of the online queue based on the total number of service providers, the response time limit for online services, and the average service consumption time. The response time limit for online services refers to the timeframe within which an online service must provide a processing result; this time limit is preset and set according to actual needs, and is not limited in this embodiment of the invention. The average service consumption time is obtained in advance and can be calculated based on the consumption time of various online services within a preset historical time period.
[0061] For example, according to the formula Calculate the maximum length of the online queue. ,in, This indicates that there is a time limit for responding to online service requests. This represents the total number of service providers. This indicates the average service time.
[0062] S403. If it is determined that the ratio of the current length to the maximum length of the online queue is greater than the ratio of the number of online service reserved providers to the total number of service providers in the current time period, then reserve service resources for the online service and update the batch call threshold.
[0063] Specifically, the rate limiting center calculates the ratio of the current length of the online queue to the maximum length of the online queue. And calculate the ratio of the number of online service reserved providers to the total number of service providers. ,if Greater than This indicates a sudden increase in online call requests, necessitating the addition of reserved service resources. The rate limiting center will add reserved service resources for the online service and then update the batch call threshold based on these new resources. When adding reserved service resources for the online service, a set number can be added to the current number of reserved online service providers for the current time period to obtain the updated number of reserved online service providers for the current time period; alternatively, based on the scenario of a sudden increase in online call requests, a reasonable number can be added to the current number of reserved online service providers for the current time period to obtain the updated number of reserved online service providers for the current time period. The rate limiting center calculates the total number of service providers minus the updated number of reserved online service providers for the current time period to obtain the updated batch call threshold for the current time period, thus updating the batch call threshold for the current time period. Adding reserved service resources for the online service in the event of a sudden increase in online call requests further ensures the processing of online transactions and improves the reliability of online transaction processing. The set number is determined based on practical experience and is not limited in this embodiment of the invention.
[0064] For example, according to the formula Calculate the current length of the online queue. Maximum length of online queue ratio According to the formula Calculate the number of online service reserved providers for the current time period. Total number of service providers ratio .
[0065] Based on the above embodiments, the additional reserved service resources for online services further include:
[0066] The number of newly added online service reserved providers is determined based on the total number of service providers, the current length of the online queue, the maximum length of the online queue, and the number of online service reserved providers in the current time period.
[0067] Specifically, in scenarios involving a sudden increase in online call requests, the rate limiting center can determine the number of newly added online service reserved providers based on the total number of service providers, the current length of the online queue, the maximum length of the online queue, and the number of online service reserved providers in the current time period. This precise provision of the number of newly added online service reserved providers improves resource utilization in scenarios with a sudden increase in online call requests.
[0068] For example, it can be based on the formula Calculate the number of newly added online service reserved providers. ,in, Indicates the maximum length of the online queue. Indicates the current length of the online queue. This indicates the number of online service providers reserved for the current time period. Indicates the total number of service providers. This indicates rounding up. The updated number of online service reserved providers for the current time period is... The updated batch call threshold for the current time period is equal to Understandably, Less than or equal to .
[0069] Based on the above embodiments, the transaction processing method provided by the embodiments of the present invention further includes:
[0070] If it is determined that the ratio of the current length to the maximum length of the online queue is less than or equal to the ratio of the number of online service reserved providers to the total number of service providers in the current time period, then the reserved service resources newly added for the online service are released and the batch call threshold is restored.
[0071] Specifically, after the rate limiting center adds reserved service resources for the online service, if the sudden increase in online call requests disappears, the rate limiting center will release the newly added reserved service resources for the online service. The rate limiting center will then recalculate the ratio of the current length of the online queue to the maximum length of the online queue. The ratio of the number of online service reserved providers to the total number of service providers. ,if Less than or equal to This indicates that the sudden increase in online call requests has disappeared. The rate limiting center can then release the newly reserved service resources for online services and restore the batch call threshold. The rate limiting center subtracts the number of newly added online service reserved providers from the updated number of online service reserved providers for the current time period to release the newly added reserved service resources for online services. The rate limiting center then adds the number of newly added online service reserved providers to the updated batch call threshold for the current time period to restore the batch call threshold for the current time period.
[0072] Based on the above embodiments, the batch call request is further sent by the batch processing caller after triggering the batch call request and randomly going into sleep mode.
[0073] Specifically, due to the high concurrency of batch transactions, the batch processing client employs a random sleep mode after a batch call request is triggered. This random sleep mode means that the batch call request is not processed immediately after being triggered, but rather sleeps for t seconds (where t is randomly generated). After the sleep period, the batch call request is then sent to the rate limiting center. The triggering of the batch call request can be based on a set time or set conditions, and is configured according to actual needs; this embodiment of the invention does not impose any limitations. Randomly sleeping for a period before each batch call request reduces the concurrency of batch transactions, reduces rate limiting of the batch processing service due to short-term resource contention, and helps to lower the frequency of rate limiting for the batch processing service.
[0074] Based on the above embodiments, the transaction processing method provided by the embodiments of the present invention further includes:
[0075] The batch processing client receives the batch call request sent after receiving the rate limiting instruction information and waiting for a set time period.
[0076] Specifically, after receiving the rate limiting instruction, the batch processing client stops sending batch call requests to the rate limiting center for a set time period to ensure that resources are available to process the already sent batch call requests. After the set time period, the batch processing client will send batch call requests to the rate limiting center to continue processing batch transactions.
[0077] Based on the above embodiments, the transaction processing method provided by the embodiments of the present invention further includes:
[0078] If it is determined that the number of batch calls in the current time period is less than the batch call threshold for the current time period, then a rate limiting release instruction is sent to the batch caller.
[0079] Specifically, after sending the rate limiting instruction to the batch processing client, the rate limiting center recalculates the number of batch processing calls for the current time period. If the recalculated number of batch processing calls for the current time period is less than the batch processing call threshold for that period, it can send a rate limiting release instruction to the batch processing client. Upon receiving the rate limiting release instruction, the batch processing client sends a batch call request to the rate limiting center to initiate batch transaction processing in a timely manner.
[0080] Figure 5 This is a schematic diagram of the transaction processing device provided in the fifth embodiment of the present invention, as shown below. Figure 5 As shown, the transaction processing apparatus provided in this embodiment of the invention includes a receiving module 501, a statistics module 502, an obtaining module 503, and a sending module 504, wherein:
[0081] The receiving module 501 is used to receive batch call requests sent by the batch processing caller, each batch call request carrying a batch tag; the statistics module 502 is used to count the number of batch call requests in the current time period based on the batch tag; the obtaining module 503 is used to obtain the batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein, the number of online service reserved providers in the current time period is obtained in advance; the sending module 504 is used to send rate limiting indication information to the batch processing caller after determining that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, so that the batch processing caller stops sending batch call requests.
[0082] Specifically, each batch processing client can send a batch call request to the receiving module 501. Before sending the batch call request, a batch tag is set for the batch call request. The receiving module 501 receives the batch call requests sent by the batch processing clients, each batch call request carrying a batch tag. After receiving each batch call request, the batch tag is transmitted along the call chain of the batch processing transaction corresponding to the batch call request, thereby achieving full-link coloring of the batch processing transaction and identifying the batch processing traffic. The batch tag can be an encoding, string, etc., and can be set according to actual needs; this embodiment of the invention does not impose limitations.
[0083] The statistics module 502 can count the number of received batch call requests. After the batch transaction corresponding to each batch call request is processed, feedback information indicating that the batch call request processing is complete will be received, thus enabling the counting of the number of processed batch call requests. Based on the number of received batch call requests and the number of processed batch call requests, the statistics module 502 can calculate the number of batch call requests in the current time period. Here, the current time period refers to the time period to which the current time belongs. Each time period is preset and set according to actual needs; this embodiment of the invention does not impose any limitations.
[0084] The obtaining module 503 obtains the batch processing call threshold for the current time period based on the total number of service providers and the number of online service reserved providers for the current time period. The total number of service providers can be the total number of servers in the distributed service cluster. The number of online service reserved providers for the current time period is pre-obtained and can vary across different time periods. Typically, there are more online transactions during the day and more batch processing transactions at night. By dynamically adjusting the number of online service reserved providers for each time period, while prioritizing online transactions, resources are fully utilized to process batch processing transactions, improving the reliability of transaction processing. The number of online service reserved providers for the current time period refers to the number of servers reserved for processing online services.
[0085] The sending module 504 compares the number of batch processing calls in the current time period with the batch processing call threshold for the current time period. If the number of batch processing calls in the current time period is greater than the batch processing call threshold, it indicates that there are no idle resources to process more batch processing services. To avoid batch call requests failing, the sending module 504 sends a rate limiting instruction to the batch processing caller. After receiving the rate limiting instruction, the batch processing caller stops sending batch call requests to the rate limiting center, so that resources are available to process the already sent batch call requests. The set time period is determined based on practical experience and is not limited in this embodiment of the invention.
[0086] The transaction processing apparatus provided in this embodiment of the invention can receive batch call requests sent by a batch processing caller and set a batch tag for each batch call request; count the number of batch call requests in the current time period based on the batch tags; obtain the batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, a rate limiting instruction is sent to the batch processing caller to cause the batch processing caller to stop sending batch call requests within a set time period. This can reduce the failure of batch call requests while ensuring online transactions, thereby improving the reliability of batch processing services. Furthermore, since the number of online service reserved providers and the batch call threshold can be dynamically adjusted in each time period, resources can be fully utilized for batch transaction processing while prioritizing online transactions, thus improving resource utilization.
[0087] Figure 6 This is a schematic diagram of the transaction processing device provided in the sixth embodiment of the present invention, as shown below. Figure 6 As shown, based on the above embodiments, the transaction processing apparatus provided in this embodiment further includes a frequency acquisition module 505, an average service time acquisition module 506, and a calculation module 507, wherein:
[0088] The frequency acquisition module 505 is used to obtain the online service call frequency corresponding to the current time period based on the number of online service calls in a preset number of historical time periods corresponding to the current time period; the average service consumption time acquisition module 506 is used to obtain the average service consumption time based on the consumption time of each online service in a preset historical time period; the calculation module 507 is used to obtain the number of online service reserved providers for the current time period based on the online service call frequency corresponding to the current time period, the average service consumption time, and the total number of service providers.
[0089] Figure 7 This is a schematic diagram of the transaction processing apparatus provided in the seventh embodiment of the present invention, as shown below. Figure 7 As shown, based on the above embodiments, the transaction processing apparatus provided in this embodiment further includes a current length acquisition module 508, a maximum length acquisition module 509, and a resource reservation module 510, wherein:
[0090] The current length acquisition module 508 is used to obtain the current length of the online queue based on the number of received online call requests and the number of processed online call requests; the maximum length acquisition module 509 is used to obtain the maximum length of the online queue based on the total number of service providers, the response time limit of the online service, and the average service consumption time; wherein, the average service consumption time is obtained in advance; the resource reservation module 510 is used to add reserved service resources for the online service and update the batch call threshold after determining that the ratio of the current length to the maximum length of the online queue is greater than the ratio of the number of online service reserved providers in the current time period to the total number of service providers.
[0091] Based on the above embodiments, the resource reservation module 510 is further specifically used for:
[0092] The number of newly added online service reserved providers is determined based on the total number of service providers, the current length of the online queue, the maximum length of the online queue, and the number of online service reserved providers in the current time period.
[0093] Figure 8 This is a schematic diagram of the transaction processing device provided in the eighth embodiment of the present invention, as shown below. Figure 8 As shown, based on the above embodiments, the transaction processing apparatus provided in this embodiment further includes a resource release module 511, wherein:
[0094] The resource release module 511 is used to release the reserved service resources newly added for the online service and restore the batch call threshold after determining that the ratio of the current length to the maximum length of the online queue is less than or equal to the ratio of the number of online service reserved providers to the total number of service providers in the current time period.
[0095] Based on the above embodiments, the batch call request is further sent by the batch processing caller after triggering the batch call request and randomly going into sleep mode.
[0096] Based on the above embodiments, the receiving module 501 is further configured to:
[0097] The receiving module receives the batch call request sent by the batch processing call terminal after receiving the rate limiting indication information and waiting for a set time period.
[0098] The embodiments of the device provided in this invention can be used to execute the processing flow of the above-described method embodiments. Its functions will not be repeated here, but can be referred to the detailed description of the above-described method embodiments.
[0099] It should be noted that the transaction processing method and apparatus provided in the embodiments of the present invention can be used in the financial field, or in any technical field other than the financial field. The embodiments of the present invention do not limit the application field of the transaction processing method and apparatus.
[0100] Figure 9 This is a schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention, as shown below. Figure 9 As shown, the electronic device may include: a processor 901, a communications interface 902, a memory 903, and a communication bus 904, wherein the processor 901, communications interface 902, and memory 903 communicate with each other via the communication bus 904. The processor 901 can call logical instructions in the memory 903 to execute the following methods: receiving batch call requests sent by a batch processing client, each batch call request carrying a batch tag; counting the number of batch call requests in the current time period based on the batch tags; obtaining a batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein the number of online service reserved providers in the current time period is pre-obtained; if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, then sending a rate limiting indication to the batch processing client to cause the batch processing client to stop sending batch call requests.
[0101] Furthermore, the logical instructions in the aforementioned memory 903 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0102] This embodiment discloses a computer program product, which includes a computer program stored on a computer-readable storage medium. The computer program includes program instructions, and when the program instructions are executed by a computer, the computer can execute the methods provided in the above-described method embodiments, such as: receiving batch call requests sent by a batch processing caller, each batch call request carrying a batch tag; counting the number of batch call requests in the current time period based on the batch tag; obtaining a batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein the number of online service reserved providers in the current time period is obtained in advance; if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, then sending a rate limiting indication message to the batch processing caller to cause the batch processing caller to stop sending batch call requests.
[0103] This embodiment provides a computer-readable storage medium storing a computer program that causes the computer to execute the methods provided in the above-described method embodiments. For example, the methods include: receiving batch call requests sent by a batch processing client, each batch call request carrying a batch tag; counting the number of batch call requests in the current time period based on the batch tags; obtaining a batch call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein the number of online service reserved providers in the current time period is obtained in advance; and if it is determined that the number of batch calls in the current time period is greater than the batch call threshold for the current time period, sending a rate limiting indication to the batch processing client to cause the batch processing client to stop sending batch call requests.
[0104] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied 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.
[0105] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0106] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0107] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0108] In the description of this specification, the references to terms such as "an embodiment," "a specific embodiment," "some embodiments," "for example," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0109] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for processing transactions, characterized in that, include: Receive batch call requests sent by the batch processing client, each batch call request carrying a batch tag; The number of batch call requests in the current time period is counted based on batch tags; The batch processing call threshold for the current time period is obtained based on the number of online service reserved providers and the total number of service providers in the current time period; wherein, the number of online service reserved providers in the current time period is obtained in advance; and the batch processing call threshold is obtained by subtracting the number of online service reserved providers in the current time period from the total number of service providers. If it is determined that the number of batch calls in the current time period is greater than the batch call threshold in the current time period, a rate limiting instruction is sent to the batch call client so that the batch call client stops sending batch call requests. The method further includes: The current length of the online queue is obtained based on the number of received online call requests and the number of processed online call requests; The maximum length of the online queue is obtained based on the total number of service providers, the response time limit for online services, and the average service time; wherein the average service time is obtained in advance. If it is determined that the ratio of the current length to the maximum length of the online queue is greater than the ratio of the number of online service reserved providers to the total number of service providers in the current time period, then additional reserved service resources are added for the online service and the batch call threshold is updated.
2. The method according to claim 1, characterized in that, The number of online service reserved providers for the current time period includes: The online service call frequency corresponding to the current time period is obtained based on the number of online service calls in a preset number of historical time periods corresponding to the current time period. The average service time is obtained based on the time spent on each online service within a preset historical time period. The number of online service reserved providers for the current time period is obtained based on the online service call frequency corresponding to the current time period, the average service time, and the total number of service providers.
3. The method according to claim 1, characterized in that, The newly reserved service resources for online services include: The number of newly added online service reserved providers is determined based on the total number of service providers, the current length of the online queue, the maximum length of the online queue, and the number of online service reserved providers in the current time period.
4. The method according to claim 1, characterized in that, Also includes: If it is determined that the ratio of the current length to the maximum length of the online queue is less than or equal to the ratio of the number of online service reserved providers to the total number of service providers in the current time period, then the reserved service resources newly added for the online service are released and the batch call threshold is restored.
5. The method according to claim 1, characterized in that, The batch call request is sent by the batch processing client after triggering the batch call request and randomly going into sleep mode.
6. The method according to any one of claims 1 to 5, characterized in that, Also includes: The batch processing client receives the batch call request sent after receiving the rate limiting instruction information and waiting for a set time period.
7. A transaction processing apparatus, characterized in that, include: The receiving module is used to receive batch call requests sent by the batch processing client. Each batch call request carries a batch tag. The statistics module is used to count the number of batch call requests in the current time period based on batch tags; The acquisition module is used to obtain the batch processing call threshold for the current time period based on the number of online service reserved providers and the total number of service providers in the current time period; wherein, the number of online service reserved providers in the current time period is obtained in advance; and the batch processing call threshold is obtained by subtracting the number of online service reserved providers in the current time period from the total number of service providers. The sending module is used to send rate limiting indication information to the batch processing call terminal after determining that the number of batch processing calls in the current time period is greater than the batch processing call threshold in the current time period, so that the batch processing call terminal stops sending batch call requests. The device further includes: a current length acquisition module, a maximum length acquisition module, and a resource reservation module, wherein: The current length acquisition module is used to obtain the current length of the online queue based on the number of received online call requests and the number of processed online call requests; The maximum length acquisition module is used to obtain the maximum length of the online queue based on the total number of service providers, the response time limit of the online service, and the average service time; wherein the average service time is obtained in advance; The resource reservation module is used to add reserved service resources for online services and update the batch call threshold after determining that the ratio of the current length to the maximum length of the online queue is greater than the ratio of the number of online service reservation providers to the total number of service providers in the current time period.
8. 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, it implements the 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 a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and medium
CN110443695A
Batch data processing method and device, equipment and storage medium
CN113971552A
Method and system of program control having load balancing function
JP2004094711A