CN114157719A - Gateway current limiting method based on API - Google Patents
Gateway current limiting method based on API Download PDFInfo
- Publication number
- CN114157719A CN114157719A CN202111310136.9A CN202111310136A CN114157719A CN 114157719 A CN114157719 A CN 114157719A CN 202111310136 A CN202111310136 A CN 202111310136A CN 114157719 A CN114157719 A CN 114157719A
- Authority
- CN
- China
- Prior art keywords
- api
- current
- flow value
- request
- target
- 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
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/66—Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L47/00—Traffic control in data switching networks
- H04L47/10—Flow control; Congestion control
- H04L47/29—Flow control; Congestion control using a combination of thresholds
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
- Computer And Data Communications (AREA)
Abstract
The invention discloses a gateway current limiting method based on an API. The method comprises the following steps: 1. obtaining an API request and determining a target user (hereinafter referred to as target) corresponding to the request; 2. calculating the current unit flow value corresponding to the target; 3. judging whether the current unit flow value exceeds a unit flow threshold value; A. if not, receiving an API request; B. if the current unit flow value exceeds the preset flow value, sending the current unit flow value to a cluster counter; 4. acquiring a current total flow value from a cluster counter, and judging whether the current total flow value exceeds a total flow threshold of the target; A. if not, receiving an API request; B. if yes, rejecting the API request; 5. and (4) other options are provided. The invention reduces the influence of the API gateway on the processing capability of the API access request, which is generated by the current limiting operation.
Description
Technical Field
The invention relates to the technical field of API access and gateway access flow limitation, in particular to a gateway flow limiting method based on an API.
Background
In an internet distributed system, for a certain request resource (API), an API (Application Programming Interface) is some predefined interfaces (such as a function, an HTTP Interface), or refers to a convention for linking different components of a software system.
The API gateway is usually a cluster based on load balancing, and in order to protect each service system behind the API gateway from being unavailable due to large-traffic access, a current limiting operation needs to be performed on access requests. One of the existing current limiting methods is a cluster counter method. The counter is incremented by 1 each time a request is received by the gateway and decremented by 1 each time a request is processed. The counter has a maximum value, which is set as required, and a minimum value, which corresponds to a buffer, beyond which the gateway will no longer receive requests. In the method, before receiving an API request each time, the gateway server needs to interact with the cluster counter, so that the capability of the API gateway for processing the API request is reduced.
In summary, the present invention designs a gateway current limiting method based on API.
Disclosure of Invention
Aiming at the defects in the prior art, the invention aims to provide the gateway current limiting method based on the API, which reduces the influence of the API gateway on the processing capacity of the API access request, which is generated by the current limiting operation.
In order to achieve the purpose, the invention is realized by the following technical scheme: an API-based gateway current limiting method comprises the following steps:
1. obtaining an API request and determining a target user (hereinafter referred to as target) corresponding to the request;
2. calculating the current unit flow value corresponding to the target;
3. judging whether the current unit flow value exceeds a unit flow threshold value;
A. if not, receiving an API request;
B. if the current unit flow value exceeds the preset flow value, sending the current unit flow value to a cluster counter;
4. acquiring a current total flow value from a cluster counter, and judging whether the current total flow value exceeds a total flow threshold of the target;
A. if not, receiving an API request;
B. if yes, rejecting the API request;
5. and (4) other options are provided.
Preferably, the step5 includes the following steps:
A. before the current total flow value is judged to exceed the total flow threshold value, the total flow threshold value corresponding to the target can be obtained from the shared memory component;
B. after receiving the API request, the API access request may also be forwarded to the application server;
C. if the current unit flow value exceeds the unit flow threshold, the API access request corresponding to the target can be obtained after the current unit flow value is sent to the cluster counter.
The invention has the beneficial effects that: the invention can well solve the influence of the API gateway on the processing capability of the API access request.
Drawings
The invention is described in detail below with reference to the drawings and the detailed description;
FIG. 1 is a flow chart of an embodiment of the present invention.
Detailed Description
In order to make the technical means, the creation characteristics, the achievement purposes and the effects of the invention easy to understand, the invention is further described with the specific embodiments.
The specific implementation mode adopts the following technical scheme: an API-based gateway current limiting method comprises the following steps:
1. obtaining an API request and determining a target user (hereinafter referred to as target) corresponding to the request;
2. calculating the current unit flow value corresponding to the target;
3. judging whether the current unit flow value exceeds a unit flow threshold value;
A. if not, receiving an API request;
B. if the current unit flow value exceeds the preset flow value, sending the current unit flow value to a cluster counter;
4. acquiring a current total flow value from a cluster counter, and judging whether the current total flow value exceeds a total flow threshold of the target;
A. if not, receiving an API request;
B. if yes, rejecting the API request;
5. other options are as follows:
A. before the current total flow value is judged to exceed the total flow threshold value, the total flow threshold value corresponding to the target can be obtained from the shared memory component;
B. after receiving the API request, the API access request may also be forwarded to the application server;
C. if the current unit flow value exceeds the unit flow threshold value, an API access request corresponding to the target can be acquired after the current unit flow value is sent to the cluster counter;
the embodiment segments the calculation judgment of the flow threshold value into a plurality of units, reduces the interaction with the cluster counter, and further improves the processing capacity of the gateway to the API request.
Example 1: a specific flow of the API-based gateway current limiting method of this embodiment is shown in fig. 1, and includes the following specific steps:
step 1: acquiring an API request to be received;
step 2: determining a target corresponding to the API request;
step 3: calculating the current unit flow value corresponding to the target;
step 4: judging whether the unit flow value exceeds a single flow threshold value or not;
1. if not, receiving the API request, executing step8 and ending the process;
2. if the current unit flow value exceeds the preset value, sending the current unit flow value to a value cluster counter, and executing step 5;
step 5: sending a current unit flow value to a value cluster counter;
step 6: acquiring the current total flow value from a counter, and judging whether the current total flow value exceeds a total flow threshold of the target;
1. if yes, rejecting the API request, executing step7, and ending the process;
2. if not, receiving the API request, executing step8, and ending the process;
step 7: rejecting the API request;
step 8: an API request is received.
The foregoing shows and describes the general principles and broad features of the present invention and advantages thereof. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, which are described in the specification and illustrated only to illustrate the principle of the present invention, but that various changes and modifications may be made therein without departing from the spirit and scope of the present invention, which fall within the scope of the invention as claimed. The scope of the invention is defined by the appended claims and equivalents thereof.
Claims (2)
1. An API-based gateway current limiting method is characterized by comprising the following steps:
(1) acquiring an API request and determining a target user target corresponding to the request;
(2) calculating the current unit flow value corresponding to the target;
(3) judging whether the current unit flow value exceeds a unit flow threshold value;
(A) if not, receiving an API request;
(B) if yes, sending the current unit flow value to a cluster counter;
(4) acquiring a current total flow value from a cluster counter, and judging whether the current total flow value exceeds a total flow threshold of the target;
(A) if not, receiving an API request;
(B) if yes, rejecting the API request;
(5) and the other is optional.
2. The API-based gateway throttling method of claim 1, wherein said step 5) comprises the steps of:
(A) before the current total flow value is judged to exceed the total flow threshold value, the total flow threshold value corresponding to the target can be obtained from the shared memory component;
(B) after receiving the API request, the API access request can be forwarded to an application server;
(C) and if the current unit flow value exceeds the unit flow threshold value, the API access request corresponding to the target can be acquired after the current unit flow value is sent to the cluster counter.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111310136.9A CN114157719A (en) | 2021-11-05 | 2021-11-05 | Gateway current limiting method based on API |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111310136.9A CN114157719A (en) | 2021-11-05 | 2021-11-05 | Gateway current limiting method based on API |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114157719A true CN114157719A (en) | 2022-03-08 |
Family
ID=80459641
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111310136.9A Pending CN114157719A (en) | 2021-11-05 | 2021-11-05 | Gateway current limiting method based on API |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114157719A (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110768912A (en) * | 2019-10-21 | 2020-02-07 | 中国民航信息网络股份有限公司 | API gateway current limiting method and device |
CN111010339A (en) * | 2019-12-24 | 2020-04-14 | 象辑知源(武汉)科技有限公司 | Enterprise-level high-performance API service gateway design method |
-
2021
- 2021-11-05 CN CN202111310136.9A patent/CN114157719A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110768912A (en) * | 2019-10-21 | 2020-02-07 | 中国民航信息网络股份有限公司 | API gateway current limiting method and device |
CN111010339A (en) * | 2019-12-24 | 2020-04-14 | 象辑知源(武汉)科技有限公司 | Enterprise-level high-performance API service gateway design method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2019100921A1 (en) | Information pushing method and device | |
CN106385459B (en) | Method and device for distributing connection request message | |
CN107800768B (en) | Open platform control method and system | |
CN110858843A (en) | Service request processing method and device and computer readable storage medium | |
EP2692095B1 (en) | Method, apparatus and computer program product for updating load balancer configuration data | |
CN110633442A (en) | Pushing method and device and electronic equipment | |
US9608831B2 (en) | Migrating a chat message service provided by a chat server to a new chat server | |
CN109495467B (en) | Method and device for updating interception rule and computer readable storage medium | |
US10645183B2 (en) | Redirection of client requests to multiple endpoints | |
US10425273B2 (en) | Data processing system and data processing method | |
CN104980472A (en) | Network traffic control method and device | |
CN105447110A (en) | Method for rapidly loading data in batches of database cluster and loading system | |
CN111708637A (en) | Data processing method and device and computer readable medium | |
CN113656176B (en) | Cloud equipment distribution method, device and system, electronic equipment, medium and product | |
CN110581784A (en) | node health check method, device and equipment | |
CN110838987A (en) | Queue current limiting method and storage medium | |
CN108595574B (en) | Database cluster connection method, device, equipment and storage medium | |
CN114157719A (en) | Gateway current limiting method based on API | |
US11323368B1 (en) | System and method for web service atomic transaction (WS-AT) affinity routing | |
CN109144989B (en) | Data cleaning method and device | |
CN109981696B (en) | Load balancing method, device and equipment | |
EP3185611A1 (en) | Method, terminal and system for acquiring mail | |
CN116382892A (en) | Load balancing method and device based on multi-cloud fusion and cloud service | |
CN109428901B (en) | Message processing method and message processing device | |
CN113965367B (en) | Policy object upper limit control method, system, computer and storage medium |
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 |