CN109587069A - A kind of current-limiting method and system based on API gateway - Google Patents
A kind of current-limiting method and system based on API gateway Download PDFInfo
- Publication number
- CN109587069A CN109587069A CN201811511051.5A CN201811511051A CN109587069A CN 109587069 A CN109587069 A CN 109587069A CN 201811511051 A CN201811511051 A CN 201811511051A CN 109587069 A CN109587069 A CN 109587069A
- Authority
- CN
- China
- Prior art keywords
- current
- request
- max
- api gateway
- memory
- 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.)
- Granted
Links
Classifications
-
- 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
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
Current-limiting method and system disclosed by the invention based on API gateway, is related to network technique field, by the maximum value V for setting request number of timesmax, using one-way hash function, the identical URL request in address is encrypted, encrypted result is generated and judges V in the validity period T of label key1Whether V is not more thanmax, if so, passing through current request and V1Value add 1, work as V1Greater than VmaxWhen, refuse current request, it realizes the stringent current limliting to the distributed system under cluster environment and the performance of system is lost and be preferably minimized, solving cannot stringent current limliting and the biggish defect of current limliting bring system performance loss to the distributed system under cluster environment.
Description
Technical field
The present invention relates to network technique fields, and in particular to a kind of current-limiting method and system based on API gateway.
Background technique
In the access of big data quantity high concurrent, often will appear service or interface surface causes system can not the request that risen suddenly and sharply
With the case where, or even can cause chain reaction causes whole system to be collapsed.It is cached at this time, service degradation and current limliting,
Wherein current limliting is a kind of most important mode, when requesting to reach certain number of concurrent or rate, just waited, be lined up, degraded,
Refusal service etc..
Current limliting is mainly carried out using counter algorithm, token bucket algorithm, sliding window algorithm and token bucket algorithm in the industry at present.
Wherein, token bucket algorithm mainly pass through control data be injected into the rate of network with the burst flow on smooth network;Token bucket is calculated
Method is a kind of algorithm most-often used in shaping network flow and rate limit, for controlling the number for the data being sent on network
Mesh, and allow the transmission of bursty data;Counter algorithm is simplest algorithm, and the low precision that can regard sliding window as is real
It is existing, since sliding window needs to store more parts of counter, so sliding window needs more memory spaces in realization,
That is the memory space needed is bigger if the precision of sliding window is higher.
The prior art is primarily present the defect of following several respects:
(1) current limliting under distributed system can not be supported completely;
(2) current limliting under cluster environment is not supported;
(3) current limliting that is stringent and giving is not implemented;
(4) current limliting bring system performance loss is larger.
Summary of the invention
To solve the deficiencies in the prior art, the embodiment of the invention provides a kind of current-limiting method based on API gateway and it is
System.
In a first aspect, the current-limiting method provided in an embodiment of the present invention based on API gateway the following steps are included:
S101 sets the maximum value V of request number of timesmax;
S102 encrypts the identical URL request in address using one-way hash function, generates encrypted result, wherein
The encrypted result includes the label key and current request number V of the URL request1;
S103 judges V in the validity period T of the label key1Whether V is not more thanmax, if so, passing through current request
And V1Value add 1, wherein the unit of T is second or minute or hour;
S104 repeats step S103, works as V1Greater than VmaxWhen, refuse current request.
Second aspect, the current limiting system provided in an embodiment of the present invention based on API gateway include:
Setting module, for setting the maximum value V of request number of timesmax;
Encrypting module encrypts the identical URL request in address, generates encryption knot for utilizing one-way hash function
Fruit, wherein the encrypted result includes the label key and current request number V of the request1;
Judgment module, for judging V1Whether V is not more thanmax, if so, passing through current request and V1Value add 1, wherein T
Unit be second or minute or hour;
Refuse module, for refusing current request when V1 is greater than Vmax.
Current-limiting method and system provided in an embodiment of the present invention based on API gateway has following
The utility model has the advantages that
It realizes the stringent current limliting to the distributed system under cluster environment and the performance of system is lost and be preferably minimized.
Detailed description of the invention
Fig. 1 is the flow diagram of the current-limiting method provided in an embodiment of the present invention based on API gateway;
The structural schematic diagram of Fig. 2 current limiting system provided in an embodiment of the present invention based on API gateway.
Specific embodiment
Specific introduce is made to the present invention below in conjunction with the drawings and specific embodiments.
Referring to Fig.1, the current-limiting method provided in an embodiment of the present invention based on API gateway, comprising the following steps:
S101 sets the maximum value V of request number of timesmax。
As a specific embodiment, VmaxValue be set as 10 times.
S102 encrypts the identical URL request in address using one-way hash function, generates encrypted result, wherein
The encrypted result includes the label key and current request number V of the URL request1。
As a specific embodiment,
Https: //www.yourdomain.com/abc/def/createOrder.json? p1=v1&p2=v2,
Https: //www.yourdomain.com/abc/def/createOrder.json? m1=v3&m2=v2 and https: //
The address of tri- URL requests of www.yourdomain.com/abc/def/createOrder.json is identical, is taken as one to ask
It asks and is divided into one group.
S103 judges V in the validity period T of the label key1Whether V is not more thanmax, if so, passing through current request
And V1Value add 1, wherein the unit of T is second or minute or hour;
S104 repeats step S103, works as V1Greater than VmaxWhen, refuse current request.
As a specific embodiment, work as V1When greater than 10, then request to be rejected.
Referring to Fig. 2, the current limiting system provided in an embodiment of the present invention based on API gateway include setting module, encrypting module,
Judgment module and refusal module, wherein
Setting module, for setting the maximum value V of request number of timesmax;
Encrypting module encrypts the identical URL request in address, generates encryption knot for utilizing one-way hash function
Fruit, wherein the encrypted result includes the label key and current request number V of the request1;
Judgment module, for judging V1Whether V is not more thanmax, if so, passing through current request and V1Value add 1, wherein T
Unit be second or minute or hour;
Refuse module, for working as V1Greater than VmaxWhen, refuse current request.
Current-limiting method and system provided in an embodiment of the present invention based on API gateway, by the maximum for setting request number of times
Value Vmax, using one-way hash function, the identical URL request in address is encrypted, encrypted result is generated, in having for label key
In effect phase T, V is judged1Whether V is not more thanmax, if so, passing through current request and V1Value add 1, work as V1Greater than VmaxWhen, refusal
Current request realizes the stringent current limliting to the distributed system under cluster environment and is preferably minimized the performance loss of system.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodiment
Point, reference can be made to the related descriptions of other embodiments.
It is understood that the correlated characteristic in the above method and device can be referred to mutually.In addition, in above-described embodiment
" first ", " second " etc. be and not represent the superiority and inferiority of each embodiment for distinguishing each embodiment.
It is apparent to those skilled in the art that for convenience and simplicity of description, the system of foregoing description,
The specific work process of device and unit, can refer to corresponding processes in the foregoing method embodiment, and details are not described herein.
Algorithm and display are not inherently related to any particular computer, virtual system, or other device provided herein.
Various general-purpose systems can also be used together with teachings based herein.As described above, it constructs required by this kind of system
Structure be obvious.In addition, the present invention is also not directed to any particular programming language.It should be understood that can use various
Programming language realizes summary of the invention described herein, and the description done above to language-specific is to disclose this hair
Bright preferred forms.
In addition, memory may include the non-volatile memory in computer-readable medium, random access memory
(RAM) and/or the forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM), memory includes extremely
A few storage chip.
It should be understood by those skilled in the art that, embodiments herein can provide as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, it wherein includes the computer of computer usable program code that the application, which can be used in one or more,
The computer program implemented in usable storage medium (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.) produces
The form of product.
The application is referring to method, the process of equipment (system) and computer program product according to the embodiment of the present application
Figure and/or block diagram describe.It should be understood that every one stream in flowchart and/or the block diagram can be realized by computer program instructions
The combination of process and/or box in journey and/or box and flowchart and/or the block diagram.It can provide these computer programs
Instruct the processor of general purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for real
The device for the function of being specified in present one or more flows of the flowchart and/or one or more blocks of the block diagram.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device, so that counting
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, thus in computer or
The instruction executed on other programmable devices is provided for realizing in one or more flows of the flowchart and/or block diagram one
The step of function of being specified in a box or multiple boxes.
In a typical configuration, calculating equipment includes one or more processors (CPU), input/output interface, net
Network interface and memory.
Memory may include the non-volatile memory in computer-readable medium, random access memory (RAM) and/
Or the forms such as Nonvolatile memory, such as read-only memory (ROM) or flash memory (flash RAM).Memory is computer-readable Jie
The example of matter.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
It should also be noted that, the terms "include", "comprise" or its any other variant are intended to nonexcludability
It include so that the process, method, commodity or the equipment that include a series of elements not only include those elements, but also to wrap
Include other elements that are not explicitly listed, or further include for this process, method, commodity or equipment intrinsic want
Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including element
There is also other identical elements in process, method, commodity or equipment.
It will be understood by those skilled in the art that embodiments herein can provide as method, system or computer program product.
Therefore, complete hardware embodiment, complete software embodiment or embodiment combining software and hardware aspects can be used in the application
Form.It is deposited moreover, the application can be used to can be used in the computer that one or more wherein includes computer usable program code
The shape for the computer program product implemented on storage media (including but not limited to magnetic disk storage, CD-ROM, optical memory etc.)
Formula.
The above is only embodiments herein, are not intended to limit this application.To those skilled in the art,
Various changes and changes are possible in this application.It is all within the spirit and principles of the present application made by any modification, equivalent replacement,
Improve etc., it should be included within the scope of the claims of this application.
Claims (2)
1. a kind of current-limiting method based on API gateway characterized by comprising
S101 sets the maximum value V of request number of timesmax;
S102 encrypts the identical URL request in address using one-way hash function, generates encrypted result, wherein described
Encrypted result includes the label key and current request number V of the URL request1;
S103 judges V in the validity period T of the label key1Whether V is not more thanmax, if so, passing through current request and V1
Value add 1, wherein the unit of T is second or minute or hour;
S104 repeats step S103, works as V1Greater than VmaxWhen, refuse current request.
2. a kind of current limiting system based on API gateway characterized by comprising
Setting module, for setting the maximum value V of request number of timesmax;
Encrypting module, for being encrypted to the identical URL request in address using one-way hash function, generation encrypted result,
In, the encrypted result includes the label key and current request number V1 of the request;
Judgment module, for judging whether V1 is not more than Vmax, if so, adding 1 by the value of current request and V1, wherein T's
Unit is second or minute or hour;
Refuse module, for working as V1Greater than VmaxWhen, refuse current request.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811511051.5A CN109587069B (en) | 2018-12-11 | 2018-12-11 | API gateway-based current limiting method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811511051.5A CN109587069B (en) | 2018-12-11 | 2018-12-11 | API gateway-based current limiting method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109587069A true CN109587069A (en) | 2019-04-05 |
CN109587069B CN109587069B (en) | 2022-10-04 |
Family
ID=65928274
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811511051.5A Active CN109587069B (en) | 2018-12-11 | 2018-12-11 | API gateway-based current limiting method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109587069B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111600807A (en) * | 2020-04-14 | 2020-08-28 | 网宿科技股份有限公司 | Flow control method and system based on API gateway equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106302445A (en) * | 2016-08-15 | 2017-01-04 | 北京百度网讯科技有限公司 | For the method and apparatus processing request |
CN107222426A (en) * | 2016-03-21 | 2017-09-29 | 阿里巴巴集团控股有限公司 | The method of flow control, apparatus and system |
CN108471432A (en) * | 2018-07-11 | 2018-08-31 | 北京智芯微电子科技有限公司 | Prevent web application interface by the method for malicious attack |
CN108848037A (en) * | 2018-05-31 | 2018-11-20 | 平安医疗科技有限公司 | Service request processing method, device, computer equipment and storage medium |
-
2018
- 2018-12-11 CN CN201811511051.5A patent/CN109587069B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107222426A (en) * | 2016-03-21 | 2017-09-29 | 阿里巴巴集团控股有限公司 | The method of flow control, apparatus and system |
CN106302445A (en) * | 2016-08-15 | 2017-01-04 | 北京百度网讯科技有限公司 | For the method and apparatus processing request |
CN108848037A (en) * | 2018-05-31 | 2018-11-20 | 平安医疗科技有限公司 | Service request processing method, device, computer equipment and storage medium |
CN108471432A (en) * | 2018-07-11 | 2018-08-31 | 北京智芯微电子科技有限公司 | Prevent web application interface by the method for malicious attack |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111600807A (en) * | 2020-04-14 | 2020-08-28 | 网宿科技股份有限公司 | Flow control method and system based on API gateway equipment |
Also Published As
Publication number | Publication date |
---|---|
CN109587069B (en) | 2022-10-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109831298B (en) | Method for safely updating key in block chain, node and storage medium | |
JP6709574B2 (en) | Terminal rule engine device and terminal rule operating method | |
JP6804668B2 (en) | Block data validation method and equipment | |
CN107196989B (en) | A kind of processing method and processing device of service request | |
CN110768912B (en) | API gateway current limiting method and device | |
US9742556B2 (en) | Comparison and search operations of encrypted data | |
TW201913515A (en) | Processing method, device and server for selecting consensus node | |
CN109032803B (en) | Data processing method and device and client | |
US10423449B2 (en) | Allocating tasks in a computing environment | |
CN110008715B (en) | Method for realizing privacy protection in block chain, node and storage medium | |
TWI705686B (en) | Method, device and equipment for data statistics | |
US11294727B2 (en) | Resolving cryptographic bottlenecks for distributed multi-signature contracts shared with cryptographic accelerators by switching between local and accelerator cryptographic libraries | |
CN113961145B (en) | Data migration method and device | |
US20170124450A1 (en) | Adaptive prediction system | |
TWI686758B (en) | Data request processing, inquiry message processing method, device and equipment | |
CN109462475A (en) | Data ciphering method, decryption method and relevant apparatus | |
CN108334340A (en) | A kind of Cross-environment data communications method, device and system | |
CN109194483A (en) | Data verification method based on block chain | |
CN109587069A (en) | A kind of current-limiting method and system based on API gateway | |
CN109508791A (en) | Vehicle damage management method | |
US11740825B2 (en) | Object lifecycle management in a dispersed storage system | |
US20190116108A1 (en) | Unobtrusive support for third-party traffic monitoring | |
CN109639672A (en) | The method and system for preventing Replay Attack based on JWT data | |
CN110532248A (en) | A kind of server application acquisition of information and method of adjustment based on CMDB | |
CN109710382A (en) | A kind of virtual platform construction method |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |