CN113691604A - Adaptive current limiting method, device, equipment and medium for network request - Google Patents

Adaptive current limiting method, device, equipment and medium for network request Download PDF

Info

Publication number
CN113691604A
CN113691604A CN202110948255.0A CN202110948255A CN113691604A CN 113691604 A CN113691604 A CN 113691604A CN 202110948255 A CN202110948255 A CN 202110948255A CN 113691604 A CN113691604 A CN 113691604A
Authority
CN
China
Prior art keywords
network request
response information
request
network
time period
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110948255.0A
Other languages
Chinese (zh)
Inventor
陈俊全
姚志诚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Dingsheng Computer Technology Co ltd
Original Assignee
Shenzhen Dingsheng Computer Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Dingsheng Computer Technology Co ltd filed Critical Shenzhen Dingsheng Computer Technology Co ltd
Priority to CN202110948255.0A priority Critical patent/CN113691604A/en
Publication of CN113691604A publication Critical patent/CN113691604A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/20Traffic policing

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention discloses a network request self-adaptive current limiting method, a network request self-adaptive current limiting device, network request self-adaptive current limiting equipment and a network request self-adaptive current limiting medium. The method is executed by a request server for sending a network request to a target server; the method comprises the following steps: acquiring a network request from the request queue and sending the network request to a target server; collecting response information of the network request in a first preset time period and a second preset time period; the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio; counting the growth rate of response information of the network request in a second preset time period relative to the first preset time period; and if the increase rate of the response information meets the preset constraint condition, performing adaptive current limiting based on the increase rate of the response information. By executing the scheme, the self-adaptive flow limitation of the network can be realized, various emergency situations can be dealt with, the butt joint efficiency between the financial industry and the financial institution can be improved, and the labor cost can be saved.

Description

Adaptive current limiting method, device, equipment and medium for network request
Technical Field
The embodiment of the invention relates to the technical field of finance, in particular to a network request self-adaptive current limiting method, device, equipment and medium.
Background
The internet financial industry needs to be connected with various financial institutions in a butt joint mode, but due to the fact that the financial institutions have different capabilities, the internet financial enterprise needs to have good business flow control capability, the fact that the financial institutions with different technical capabilities are connected in a butt joint mode is guaranteed, business use is not affected, and network financial current limiting is achieved at the end of business.
In practical application scenarios, however, various complicated emergencies are generated in the process of interfacing the internet financial industry with financial institutions. The current limiting schemes in the related art have advantages, but the provided scheme modes are relatively fixed, and no coping strategies for various emergency situations exist. When an emergency occurs, the emergency can be solved only by manpower, so that a great flow burden is caused to a financial institution, the processing efficiency of financial services is seriously influenced, and the manpower cost is increased.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a medium for adaptive current limiting of a network request, which can implement adaptive flow limiting of a network, can cope with various emergency situations, can improve docking efficiency between a financial industry and a financial institution, and can save labor cost.
In a first aspect, an embodiment of the present invention provides a method for adaptive current limiting of a network request, where the method is performed by a request server, and the request server is connected to a target server and configured to send a network request to the target server; the method comprises the following steps:
acquiring a network request from a request queue and sending the network request to the target server;
collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and if the increase rate of the response information meets a preset constraint condition, performing adaptive current limiting based on the increase rate of the response information.
In a second aspect, an embodiment of the present invention further provides an adaptive current limiting apparatus for network requests, configured at a target server, where the apparatus includes: the network request acquisition module is used for acquiring a network request from the request queue and sending the network request to the target server;
the response information collection module is used for collecting response information of the network request in a first preset time period and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
the growth rate counting module is used for counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and the self-adaptive current limiting module is used for carrying out self-adaptive current limiting based on the growth rate of the response information if the growth rate of the response information meets a preset constraint condition.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the method for adaptive throttling of network requests according to any of the embodiments of the present invention.
In a fourth aspect, the present invention further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the network requested adaptive current limiting method according to any one of the embodiments of the present invention.
According to the technical scheme provided by the embodiment of the invention, the network request is obtained from the request queue and is sent to the target server; collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio; counting the growth rate of response information of the network request in a second preset time period relative to the first preset time period; and if the increase rate of the response information meets the preset constraint condition, performing adaptive current limiting based on the increase rate of the response information. By executing the technical scheme provided by the embodiment of the invention, the self-adaptive flow limitation of the network can be realized, various emergency situations can be dealt with, the butt joint efficiency between the financial industry and the financial institution can be improved, and the labor cost can be saved.
Drawings
Fig. 1 is a flowchart of an adaptive current limiting method for network requests according to an embodiment of the present invention;
fig. 2 is a flowchart of another method for adaptive throttling of network requests according to an embodiment of the present invention;
fig. 3 is a flowchart of another method for adaptively limiting current for network requests according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an adaptive current limiting apparatus for network requests according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
In one application scenario of the present solution, when an upstream system, such as a user, sends requests (e.g., requests to generate assets or loan requests) to a request server, the request server first stores the requests in a request queue in a certain order. A number of requests are then sequentially retrieved from the request queue and sent to a target server of a downstream system (e.g., a financial institution). If the target server is working properly, the completion request is processed and responded to the requesting server very quickly. If the load of the target server is too large or abnormal occurs, abnormal information can be fed back to the request server or problems such as access timeout, access interface errors and the like can be caused. At this time, if the request server still sends requests to the target server at a fixed speed or in a fixed number, the target server of the financial institution may be crashed, so that the service processing interface may have problems, and the consequences for the financial industry that needs to process financial services frequently are not obvious.
Fig. 1 is a flowchart of a network requested adaptive current limiting method according to an embodiment of the present invention, where the method may be performed by a network requested adaptive current limiting apparatus, which may be implemented by software and/or hardware, and the apparatus may be configured in an electronic device such as a server. The method is applied to the scene that the financial industry accesses financial institutions through the Internet. As shown in fig. 1, the technical solution provided by the embodiment of the present invention specifically includes:
and S110, acquiring the network request from the request queue and sending the network request to the target server.
The request queue may be an asynchronous queue that stores network requests sent by an upstream system. The network request may be an access request sent by an upstream system over the internet. Each network request carries a request timestamp, and the scheme can score the network requests according to the timestamp, for example, the latest network request has the highest score, the higher the priority, and the network requests can be arranged in a request queue from high to low according to the priority. According to the scheme, a certain number of network requests can be sequentially acquired from the request queue, and the acquired network requests are sent to the target server, so that the target server responds to the network requests to complete corresponding financial services, such as a money putting service.
And S120, collecting response information of the network request in a first preset time period and collecting response information of the network request in a second preset time period.
Wherein the response information comprises at least one dimension of average time consumption, network request outdated quantity ratio and interface error quantity ratio.
Specifically, the first preset time period may be 5min, the first preset time period may also be 10min, and the first preset time period may be set according to actual needs. The second preset time period may be 5min, or 10min, and the second preset time period may be set according to actual needs. The time length of the first preset time period may be the same as the time length of the second preset time period, or the time length of the first preset time period may be different from the time length of the second preset time period, and the time length of the first preset time period is preferably the same as the time length of the second preset time period. After sending the network request to the target server, the target server may generate response information according to a processing result of the network request, and feed back the response information to the request server. The scheme can collect the response information of the network request in the first preset time period, and can collect the response information of the network request in the second preset time period. The response information may be average time consumption generated when the network requests to access the target server, the response information may be a ratio of the number of access interface errors when the network requests to access the target server, the response information may also be a ratio of the number of expired messages when the network requests to access the target server, and the response information may also be other information. For example, if the results of several queries of a network request to the target server are all in progress, the request is considered to be an expired message.
And S130, counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period.
According to the scheme, the increase rate of the response information of the network request in the second preset time period relative to the first preset time period can be counted according to the collected response information of the network request in the first preset time period and the collected response information of the network request in the second preset time period. For example, if the response information is average time consumption, the scheme may count the growth rate of the average access time consumption requested by the network in the second preset time period relative to the first preset time period. If the response information is the ratio of the number of the access interface errors, the scheme can count the increase rate of the ratio of the number of the access interface errors requested by the network in a second preset time period relative to the first preset time period. If the response information is the ratio of the number of expired messages, the scheme can count the increase rate of the ratio of the number of the expired messages requested by the network in a second preset time period relative to the first preset time period. The response information may also be at least two of an average elapsed time, a ratio of a number of access interface errors, and a ratio of a number of network request expired messages.
And S140, if the growth rate of the response information meets a preset constraint condition, performing self-adaptive current limiting based on the growth rate of the response information.
Specifically, the preset constraint condition may be 0.01, the preset constraint condition may also be 0.1, and the preset constraint condition may be set according to actual needs. If the increase rate of the response information meets the preset constraint condition, the scheme performs adaptive flow limitation based on the increase rate of the response information to limit the number of concurrent network requests for accessing the target server, reduce the flow load of the target server and provide the buffer time for the target server. The adaptive current limiting mode may control the generation speed of the tokens or the number of tokens issued in parallel by means of a token bucket algorithm, or may adopt other modes to perform adaptive current limiting.
In this embodiment, optionally, after performing adaptive current limiting based on the increase rate of the response information, the method further includes: and updating the request queue based on at least one dimension of access time consumption information, access request expiration information and access interface error information of each network request in a first preset time period and a second preset time period.
Specifically, the scheme can count the access time consumption of each network request, the number of access interface errors of each network request and whether each network request is an expired message in a first preset time period and a second preset time period. The score, i.e., priority, of each network request in the request queue may be updated according to the time consumed for access of each network request, the number of access interface errors of each network request, and whether each network request is at least one dimension in the expired message. The priority of the network requests which take too long time for access, are out of date and have too many access interface errors is reduced, and the priority of the network requests which just arrive is improved.
Therefore, the request queue is updated through at least one dimension of the access time consumption information, the access request expiration information and the access interface error information based on each network request in the first preset time period and the second preset time period. The network request can be flexibly scheduled, the service processing efficiency of a downstream system can be improved, the deadlock of the downstream system is avoided, and the effective utilization of network resources can be realized.
According to the technical scheme provided by the embodiment of the invention, the network request is obtained from the request queue and is sent to the target server; collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio; counting the growth rate of response information of the network request in a second preset time period relative to the first preset time period; and if the increase rate of the response information meets the preset constraint condition, performing adaptive current limiting based on the increase rate of the response information. By executing the technical scheme provided by the embodiment of the invention, the self-adaptive flow limitation of the network can be realized, various emergency situations can be dealt with, the butt joint efficiency between the financial industry and the financial institution can be improved, and the labor cost can be saved.
Fig. 2 is a flowchart of a network requested adaptive current limiting method according to an embodiment of the present invention, which is optimized based on the foregoing embodiment. As shown in fig. 2, an adaptive current limiting method for network requests in an embodiment of the present invention may include:
s210, obtaining the network request from the request queue and sending the network request to a token bucket.
Specifically, according to the scheme, a certain number of network requests can be acquired from the request queue, and the network requests are sent to the token bucket, so that the network requests acquire the tokens in the token bucket, and the network requests can be sent to the target server.
In a possible implementation manner, optionally, before obtaining the network request from the request queue, the method further includes: at least one network request is received, and each network request is stored in the request queue according to the request timestamp of each network request.
According to the scheme, at least one network request can be received, and the score of the last network request of the request timestamp is set to be the highest according to the request timestamp carried in the network request, namely the score of the network request which just arrives is set to be the highest. And storing the network requests into a request queue according to the sequence of scores from high to low, and arranging the network requests according to the priority from high to low. Or, the scheme may also arrange the network requests that have just arrived backward, for example, push the network requests 10s backward for further processing, and preferentially process the network requests 10s ago, so that the network requests 10s ago are preferentially sent by taking the current timestamp as a boundary. The network requests may be ranked according to actual needs.
Therefore, by receiving at least one network request and storing each network request to the request queue according to the request timestamp of each network request, the network requests can be flexibly scheduled, the service processing efficiency of a downstream system can be improved, and the network resources can be effectively utilized.
S220, obtaining the token of the network request from the token bucket, and sending the network request to the target server based on the token.
If enough tokens exist in the token bucket, the scheme can acquire the required number of tokens corresponding to the network request from the token bucket, and send the network request to the target server based on the tokens, so that the target server responds to the network request. If the number of tokens in the token bucket cannot meet the requirement of the network request, the network request cannot take the tokens, and cannot send the network request to the target server, so as to feed back error information to an upstream system.
And S230, collecting response information of the network request in a first preset time period and collecting response information of the network request in a second preset time period.
And S240, counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period.
And S250, if the growth rate of the response information meets a preset constraint condition, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the growth rate of the response information.
Specifically, if the increase rate of the response information meets the preset constraint condition, the scheme can adjust the parallel token issuing quantity of the token bucket and/or adjust the generation speed of the tokens based on the increase rate of the response information. The token parallel issuing quantity represents the quantity of the network requests sent by the request server to the target server simultaneously. The number of parallel token issuing can be 2, the number of parallel token issuing can also be 3, and the number of parallel token issuing can be set according to actual needs. The generation speed of the tokens represents the number of tokens falling into the token bucket in unit time, the generation speed of the tokens can be 5 per second, the generation speed of the tokens can also be 10 per second, and the generation speed of the tokens can be set according to actual needs.
In another possible embodiment, optionally, if the increase rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the response information includes: and if the average time consumption growth rate is larger than a first preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the average time consumption growth rate.
For example, the first preset value may be 0.1, and the first preset value may also be 0.01, and the first preset value may be set according to actual needs. If the first preset time period and the second preset time period are both five minutes, the first preset value is set to 0.1, the average consumed time of all the requests in the second preset time period is 10s, and the average consumed time of all the requests in the first preset time period is 5s, then the increase rate of the average consumed time in the second preset time period relative to the average consumed time in the first preset time period is 1, which is far greater than 0.1, and then the parallel token issuing number and/or the token generation speed can be adjusted according to the increase rate 1 of the average consumed time. For example, the number of tokens issued in parallel by the token bucket may be controlled to be reduced by 1, or the token generation speed may be controlled to be reduced by 20%. The number of parallel tokens issued and the generation speed of the tokens can be set according to actual needs.
Therefore, if the increase rate of the average consumed time is larger than the first preset value, the parallel token issuing quantity of the token bucket is adjusted and/or the generation speed of the tokens is adjusted based on the increase rate of the average consumed time. The method can realize self-adaptive flow limitation according to the average time-consuming growth rate of the network request, reduce the flow burden of the downstream system, ensure the stability of the downstream system and improve the docking efficiency between the upstream system and the downstream system.
In another possible embodiment, optionally, if the increase rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the response information includes: and if the increase rate of the network request expired quantity ratio is greater than a second preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the network request expired quantity ratio.
For example, the second preset value may be 0.1, and the second preset value may also be 0.01, and the second preset value may be set according to actual needs. For a network request, if the response received from the downstream system is all in process when a plurality of requests are made to the downstream system, the network request is considered to be expired. Alternatively, if the access time of a network request exceeds a preset time, the network request is considered to be expired. For example, the preset time may be 3 days, or the preset time may be 1 day, and the preset time may be set according to actual needs. The network request expiration number ratio may be a ratio of expired network requests among all network requests over a period of time. If the first preset time period and the second preset time period are both five minutes, the second preset value is set to 0.1, the ratio of the network request expired quantity in the second preset time period is 30%, and the ratio of the network request expired quantity in the first preset time period is 20%, then the increase rate of the ratio of the network request expired quantity in the second preset time period is 0.5 and is far greater than 0.1, and then the quantity of the tokens issued in parallel and/or the generation speed of the tokens can be adjusted according to the increase rate of the ratio of the network request expired quantity of 0.5. For example, the number of tokens issued in parallel by the token bucket may be controlled to be reduced by 1, or the token generation speed may be controlled to be reduced by 20%. The number of parallel tokens issued and the generation speed of the tokens can be set according to actual needs.
Therefore, if the increase rate of the network request expired quantity ratio is larger than a second preset value, the parallel token issuing quantity of the token bucket is adjusted and/or the generation speed of the tokens is adjusted based on the increase rate of the network request expired quantity ratio. The method can realize self-adaptive current limiting according to the growth rate of the network request overdue quantity ratio, reduce the flow burden of a downstream system, ensure the stability of the downstream system and improve the docking efficiency between the upstream system and the downstream system.
In this embodiment, optionally, if the growth rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the growth rate of the response information includes: and if the increase rate of the interface error quantity ratio is greater than a third preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the interface error quantity ratio.
For example, the third preset value may be 0.1, and the third preset value may also be 0.15, and the third preset value may be set according to actual needs. If the downstream system is abnormal suddenly, when the request server sends a network request to the target server, the information such as an error occurring in the access interface is received. The interface error number ratio may be a ratio of the number of interfaces in which an error occurred to the total number of interfaces over a period of time. If the first preset time period and the second preset time period are both five minutes, the third preset value is set to 0.1, the ratio of the number of interface errors in the second preset time period is 40%, and the ratio of the number of interface errors in the first preset time period is 20%, the ratio of the number of interface errors in the second preset time period to the ratio of the number of interface errors in the first preset time period is 1, which is much greater than 0.1, and the number of parallel token issuing and/or the generation speed of the tokens can be adjusted according to the ratio of the number of interface errors to 1. For example, the number of tokens issued in parallel by the token bucket may be controlled to be reduced by 1, or the token generation speed may be controlled to be reduced by 20%. The number of parallel tokens issued and the generation speed of the tokens can be set according to actual needs.
Therefore, if the increase rate of the interface error quantity ratio is larger than the third preset value, the parallel token issuing quantity of the token bucket is adjusted and/or the generation speed of the tokens is adjusted based on the increase rate of the interface error quantity ratio. The method can realize self-adaptive current limiting according to the increase rate of the interface error number ratio, reduce the flow burden of a downstream system, ensure the stability of the downstream system and improve the docking efficiency between the upstream system and the downstream system.
According to the technical scheme provided by the embodiment of the invention, the network request is obtained from the request queue and sent to the token bucket, the token of the network request is obtained from the token bucket, the network request is sent to the target server based on the token, the response information of the network request in the first preset time period is collected, the response information of the network request in the second preset time period is collected, the growth rate of the response information of the network request in the second preset time period relative to the first preset time period is counted, and if the growth rate of the response information meets the preset constraint condition, the parallel token issuing quantity of the token bucket and/or the generation speed of the token are/is adjusted based on the growth rate of each response information. By executing the scheme, the self-adaptive flow limitation of the network can be realized, various emergency situations can be dealt with, the stability of a downstream system can be ensured, the butt joint efficiency between the financial industry and financial institutions can be improved, and the labor cost can be saved.
The internet financial industry needs to connect various financial institutions, but the capabilities of the financial institutions are different, and the traffic from the internet cannot be accepted, so that the internet financial enterprise needs to make good business flow control capability. The financial institutions with different technical capabilities are ensured not to be influenced by service use.
The current limiting schemes in the related art mainly include a leaky bucket algorithm and a token bucket algorithm, but the algorithms cannot perform adaptive current limiting according to actual service processing conditions.
To more clearly express the technical solution of the present invention, fig. 3 is a flowchart of a network requested adaptive current limiting method provided in an embodiment of the present invention, and as shown in fig. 3, the technical solution provided in the embodiment of the present invention may include the following steps:
step 1, asynchronous current limiting.
Firstly, an asynchronous request queue is constructed according to the actual service condition, and the real-time requests from the Internet are firstly put into the asynchronous request queue. Wherein each request corresponds to an order number, namely the assetID. The construction of the asynchronous request queue is realized through zset of redis, and the network requests are arranged according to the score of zset. And then, a preset number of network requests in the zset are fished through a scheduling algorithm and are sent to a target server, a token bucket algorithm is used when the network requests are sent, a certain number of network requests are sent to a downstream system (bank, trust, insurance and the like) in parallel, and a buffer is guaranteed to be provided for the downstream system, namely, a flow value which can be accepted by the downstream system. However, only through asynchronous current limiting, the token bucket needs to be allocated by people continuously, the generation speed has higher labor cost, and the timeliness is difficult to ensure particularly during the manual rest time. By asynchronous flow control, the flow peak can not break down a downstream system, and good peak elimination is realized.
And 2, self-adaptive current limiting.
According to the service dimension, because an asynchronous mode is adopted, network requests are stored in a queue, and the queue has message backlog. And the MQ is used as a message queue, if a network request comes, recording is carried out from three dimensions of expired message number, request time consumption and interface error number, and a recording result is sent to the dynamic limiterMetricMQLister. The dynamic limitter metric QListener counts response information requested by the network in a first preset time period (for example, a statistical window is set according to 5 minutes) and a second preset time period (for example, a statistical window is set according to 5 minutes), and if the increase rate of the response information in the second preset time period meets a preset constraint condition relative to the first preset time period, the token parameter is adjusted by returning: for example, the token parameter is adjusted based on the rate of increase of the two adjacent 5 minute expired message rate statistics. The token parameters are adjusted according to the accumulation of the elapsed time of two adjacent 5-minute calls to the downstream system, and then the increase rate of the average elapsed time is calculated. The parameters are tokenized according to the rate of increase of the error number ratio of two adjacent 5-minute calls to the downstream interface. The token parameters include the generation speed of the tokens and the parallel issuing quantity of the tokens, namely a parallel threshold value. The threshold value of the current limiting is continuously adjusted according to the actual service condition through three dimensions, so that the effect of self-adaptive current limiting is achieved. Meanwhile, the network requests can be re-scored according to the recording results of three dimensions of the number of expired messages, the time consumption of the requests and the number of interface errors of each network request in the MQ, and the request queue is updated
The adaptive current limiting adjusts a token bucket generation algorithm in asynchronous current limiting according to actual service conditions, so that the effect of controlling the flow by adjusting the generation rate of the token bucket is achieved. If the downstream system has strong processing capacity, the generation speed can be fast, and if the downstream system has poor capacity, the generation speed can be slowed down to protect the downstream system. And carrying out dynamic flow control according to the actual service to protect a system of a downstream mechanism.
The technical scheme provided by the embodiment of the invention carries out dynamic flow control according to the specific conditions of the service, adapts to the current Internet financial service and solves the flow control problem when the Internet financial service is connected with an external or internal payment service system. The stability of the downstream system is guaranteed, the downstream system is guaranteed to be protected, and services such as internet finance are supported.
Fig. 4 is a schematic structural diagram of an adaptive current limiting apparatus for network requests according to an embodiment of the present invention, where the apparatus may be configured in an electronic device such as a server, as shown in fig. 4, the apparatus includes:
a network request obtaining module 410, configured to obtain a network request from a request queue, and send the network request to the target server;
a response information collecting module 420, configured to collect response information of the network request in a first preset time period, and collect response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
the growth rate counting module 430 is configured to count a growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and an adaptive current limiting module 440, configured to perform adaptive current limiting based on the increase rate of the response information if the increase rate of the response information meets a preset constraint condition.
Optionally, the network request obtaining module 410 is specifically configured to: acquiring a network request from the request queue and sending the network request to a token bucket; obtaining a token of the network request from the token bucket, and sending the network request to the target server based on the token; correspondingly, the adaptive current limiting module 440 is specifically configured to: and adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the response information.
Optionally, the apparatus further includes a network request storing module, configured to receive at least one network request before obtaining a network request from a request queue, and store each network request to the request queue according to a request timestamp of each network request.
Optionally, the apparatus further includes a request queue updating module, configured to update the request queue based on at least one dimension of access time consumption information, access request expiration information, and access interface error information of each network request in a first preset time period and a second preset time period after performing adaptive current limiting based on an increase rate of the response information.
Optionally, the adaptive current limiting module 440 is specifically configured to: and if the average time consumption growth rate is larger than a first preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the average time consumption growth rate.
Optionally, the adaptive current limiting module 440 is specifically configured to: and if the increase rate of the network request expired quantity ratio is greater than a second preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the network request expired quantity ratio.
Optionally, the adaptive current limiting module 440 is specifically configured to: and if the increase rate of the interface error quantity ratio is greater than a third preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the interface error quantity ratio.
The device provided by the embodiment can execute the network request self-adaptive current limiting method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
Fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 5, the electronic device includes:
one or more processors 510, one processor 510 being illustrated in FIG. 5;
a memory 520;
the apparatus may further include: an input device 530 and an output device 540.
The processor 510, the memory 520, the input device 530 and the output device 540 of the apparatus may be connected by a bus or other means, and fig. 5 illustrates the connection by a bus as an example.
The memory 520 is a non-transitory computer readable storage medium, and can be used for storing software programs, computer executable programs, and modules, such as program instructions/modules corresponding to a network requested adaptive current limiting method in the embodiments of the present invention. The processor 510 executes various functional applications and data processing of the computer device by executing software programs, instructions and modules stored in the memory 520, namely, implementing an adaptive current limiting method for network requests of the above method embodiment, that is:
acquiring a network request from a request queue and sending the network request to the target server;
collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and if the increase rate of the response information meets a preset constraint condition, performing adaptive current limiting based on the increase rate of the response information.
The memory 520 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of the computer device, and the like. Further, the memory 520 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 520 may optionally include memory located remotely from processor 510, which may be connected to a terminal device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 530 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the computer apparatus. The output device 540 may include a display device such as a display screen.
An embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements an adaptive current limiting method for network requests according to an embodiment of the present invention, that is:
acquiring a network request from a request queue and sending the network request to the target server;
collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and if the increase rate of the response information meets a preset constraint condition, performing adaptive current limiting based on the increase rate of the response information.
Any combination of one or more computer-readable media may be employed. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. The adaptive current limiting method of the network request is characterized in that the method is executed by a request server, and the request server is connected with a target server and used for sending the network request to the target server; the method comprises the following steps:
acquiring a network request from a request queue and sending the network request to the target server;
collecting response information of the network request in a first preset time period, and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and if the increase rate of the response information meets a preset constraint condition, performing adaptive current limiting based on the increase rate of the response information.
2. The method of claim 1, wherein obtaining the network request from the request queue and sending the network request to the target server comprises:
acquiring a network request from the request queue and sending the network request to a token bucket;
obtaining a token of the network request from the token bucket, and sending the network request to the target server based on the token;
correspondingly, the adaptive current limiting is carried out based on the increase rate of the response information, and comprises the following steps:
and adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the response information.
3. The method of claim 1 or 2, wherein before obtaining the network request from the request queue, further comprising:
at least one network request is received, and each network request is stored in the request queue according to the request timestamp of each network request.
4. The method of claim 1, further comprising, after adaptively limiting current based on a rate of increase of the response information:
and updating the request queue based on at least one dimension of access time consumption information, access request expiration information and access interface error information of each network request in a first preset time period and a second preset time period.
5. The method of claim 2, wherein if the growth rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the growth rate of the response information comprises:
and if the average time consumption growth rate is larger than a first preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the average time consumption growth rate.
6. The method of claim 2, wherein if the growth rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the growth rate of the response information comprises:
and if the increase rate of the network request expired quantity ratio is greater than a second preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the network request expired quantity ratio.
7. The method of claim 2, wherein if the growth rate of the response information satisfies a preset constraint condition, adjusting the number of parallel token issuing of the token bucket and/or adjusting the generation speed of the tokens based on the growth rate of the response information comprises:
and if the increase rate of the interface error quantity ratio is greater than a third preset value, adjusting the parallel token issuing quantity of the token bucket and/or adjusting the generation speed of the tokens based on the increase rate of the interface error quantity ratio.
8. An apparatus for network requested adaptive current limiting, comprising:
the network request acquisition module is used for acquiring a network request from the request queue and sending the network request to the target server;
the response information collection module is used for collecting response information of the network request in a first preset time period and collecting response information of the network request in a second preset time period; wherein the response information comprises at least one dimension of average time consumption, network request overdue quantity ratio and interface error quantity ratio;
the growth rate counting module is used for counting the growth rate of the response information of the network request in the second preset time period relative to the first preset time period;
and the self-adaptive current limiting module is used for carrying out self-adaptive current limiting based on the growth rate of the response information if the growth rate of the response information meets a preset constraint condition.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the network requested adaptive current limiting method of any of claims 1-7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method for adaptive current limiting of network requests according to any one of claims 1 to 7.
CN202110948255.0A 2021-08-18 2021-08-18 Adaptive current limiting method, device, equipment and medium for network request Pending CN113691604A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110948255.0A CN113691604A (en) 2021-08-18 2021-08-18 Adaptive current limiting method, device, equipment and medium for network request

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110948255.0A CN113691604A (en) 2021-08-18 2021-08-18 Adaptive current limiting method, device, equipment and medium for network request

Publications (1)

Publication Number Publication Date
CN113691604A true CN113691604A (en) 2021-11-23

Family

ID=78580831

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110948255.0A Pending CN113691604A (en) 2021-08-18 2021-08-18 Adaptive current limiting method, device, equipment and medium for network request

Country Status (1)

Country Link
CN (1) CN113691604A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080294810A1 (en) * 2007-05-23 2008-11-27 Nec Electronics Corporation Response control method and device
CN110099009A (en) * 2018-01-31 2019-08-06 北京易真学思教育科技有限公司 Dynamic current limiting method and computer-readable medium based on interface response time trend
CN110166371A (en) * 2019-05-16 2019-08-23 北京达佳互联信息技术有限公司 Flow control methods, device, electronic equipment and storage medium
CN113225265A (en) * 2021-04-28 2021-08-06 北京百度网讯科技有限公司 Flow control method, device, equipment and computer storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080294810A1 (en) * 2007-05-23 2008-11-27 Nec Electronics Corporation Response control method and device
CN110099009A (en) * 2018-01-31 2019-08-06 北京易真学思教育科技有限公司 Dynamic current limiting method and computer-readable medium based on interface response time trend
CN110166371A (en) * 2019-05-16 2019-08-23 北京达佳互联信息技术有限公司 Flow control methods, device, electronic equipment and storage medium
CN113225265A (en) * 2021-04-28 2021-08-06 北京百度网讯科技有限公司 Flow control method, device, equipment and computer storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李达;肖晓强;谢波;宋宏斌;: "基于自适应流量采集的网络可靠性分析***实现", 微计算机信息, no. 33 *

Similar Documents

Publication Publication Date Title
CN109684358B (en) Data query method and device
US7912949B2 (en) Systems and methods for recording changes to a data store and propagating changes to a client application
US20060149787A1 (en) Publisher flow control and bounded guaranteed delivery for message queues
CN109672627A (en) Method for processing business, platform, equipment and storage medium based on cluster server
US7818386B2 (en) Repeatable message streams for message queues in distributed systems
CN108667916B (en) Data access method and system for Web application
CN112445857A (en) Resource quota management method and device based on database
CN111756646A (en) Network transmission control method, network transmission control device, computer equipment and storage medium
CN113032233A (en) Distributed service cluster runtime parameter adaptive processing method, device and system
US8458725B2 (en) Computer implemented method for removing an event registration within an event notification infrastructure
CN110008187B (en) File transmission scheduling method, device, equipment and computer readable storage medium
CN111913660B (en) Dotting data processing method and system
CN111309442B (en) Method, device, system, medium and equipment for adjusting number of micro-service containers
CN112764919A (en) Distributed service self-adaptive load balancing method and device
CN113691604A (en) Adaptive current limiting method, device, equipment and medium for network request
CN116436713A (en) Traffic scheduling method and device, medium and electronic equipment
CN113905091B (en) Method and device for processing access request
CN116095005A (en) Traffic management method, apparatus, device, medium, and program product
CN115002033A (en) Flow control method, device, equipment, storage medium and computer product
CN114283007A (en) Method and device for solving payment hotspot account problem and electronic equipment
CN113391927A (en) Method, device and system for processing business event and storage medium
CN114612212A (en) Business processing method, device and system based on risk control
CN114090409A (en) Message processing method and device
CN111432357A (en) Information processing method and system and computing equipment
CN112612621B (en) Data processing method and related equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination