CN111010339B - Enterprise-level high-performance API service gateway design method - Google Patents

Enterprise-level high-performance API service gateway design method Download PDF

Info

Publication number
CN111010339B
CN111010339B CN201911351580.8A CN201911351580A CN111010339B CN 111010339 B CN111010339 B CN 111010339B CN 201911351580 A CN201911351580 A CN 201911351580A CN 111010339 B CN111010339 B CN 111010339B
Authority
CN
China
Prior art keywords
current
rate
service gateway
api service
request
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.)
Active
Application number
CN201911351580.8A
Other languages
Chinese (zh)
Other versions
CN111010339A (en
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.)
Xiangji Technology Co.,Ltd.
Original Assignee
Xiangji Zhiyuan Wuhan 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 Xiangji Zhiyuan Wuhan Technology Co ltd filed Critical Xiangji Zhiyuan Wuhan Technology Co ltd
Priority to CN201911351580.8A priority Critical patent/CN111010339B/en
Publication of CN111010339A publication Critical patent/CN111010339A/en
Application granted granted Critical
Publication of CN111010339B publication Critical patent/CN111010339B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method for designing an enterprise-level high-performance API service gateway, which comprises the following steps: starting, inbound requesting, calculating the current rate, calculating the current limit count KEY, whether the current rate exceeds the rate limit, releasing the request, increasing the counter, increasing the synchronous counter, refusing the request, returning the HTTP429 status code, and ending. In the design method, the increment of a synchronous counter is set, and the synchronous interval time of the counter is configured to be smaller than the time of a current limiting window, so that the current limiting rate of the whole API gateway cluster circulates in a state of convergence-divergence-convergence within the time of the current limiting window, and is close to the required current limiting rate as much as possible; the method reduces the influence on the overall performance of the API service gateway while ensuring the accuracy of current limiting, and meets the requirements of enterprise-level application; the efficient, expandable and finally consistent distributed current limiting is realized; distributed current limiting irrelevant to the states of the API service gateway nodes can dynamically increase and decrease the number of cluster nodes and modify current limiting configuration, and current limiting requirements with different precisions can be flexibly met.

Description

Enterprise-level high-performance API service gateway design method
Technical Field
The invention relates to the technical field of design of enterprise-level high-performance API service gateways, in particular to a design method of an enterprise-level high-performance API service gateway.
Background
The micro-service architecture has the advantages of expandability, loose coupling and the like, is applied to various industries and enterprises, and becomes a current mainstream architecture mode of a service solution. In the framework, a set of API service gateway is needed, which mainly handles the matters of authentication, routing, fusing and current limiting of API requests, and provides monitoring and measurement of services. As an entrance of the external service of the whole set of system, the performance of the API service gateway is particularly important, and the API service gateway has to have higher performance to support horizontal extension while meeting the functional requirements.
However, when the current API service gateway implements the current limiting function in a distributed deployment environment, a central storage is required. When the current limiting judgment is carried out, each time the external request reaches the API service gateway node, the read-write operation is carried out on the central storage, so that the central storage becomes the bottleneck of the API service gateway cluster.
Disclosure of Invention
The invention aims to provide a design method of an enterprise-level high-performance API service gateway, which aims to solve the technical defects and technical requirements which cannot be met in the prior art.
In order to achieve the purpose, the invention provides the following technical scheme: the design method of the enterprise-level high-performance API service gateway comprises the following steps: starting, inbound requesting, calculating a current limit count KEY, judging whether the current rate exceeds the rate limit or not, releasing the request, increasing the counter, increasing the synchronous counter, rejecting the request, returning an HTTP429 status code, and ending; when the API service gateway node completes the preposed authentication, the flow limiting process after entering the flow limiting link is as follows:
s1, calculating the current limit count KEY of the request according to the configuration of the current limit;
s2, calculating the current request rate according to the type of the current limiting window, including a fixed time window or a sliding time window;
s3, comparing the calculated current request rate with the rate upper limit, if the former is smaller than the latter, releasing the request, and adding 1 to the increment of the corresponding flow limit count KEY; otherwise, rejecting the request and directly returning the HTTP429 status code;
s4, configuring the synchronous interval time of the counter to be smaller than the time of the current limiting window;
s5, the API service gateway node performs read-write operation on the central storage according to the interval time, writes the request times increment in the memory of the API service gateway node into the central storage, and reads the value in the central storage into the memory of the API service gateway node;
s6, the API service gateway node calculates the current request rate according to the type of the current limiting window:
a.) a fixed time window, the current request rate being the current time window count;
b.) sliding the time window, the current request rate being current time window count + (time window length-length the time window has elapsed)/time window length x last time window count;
s7, the API service gateway node compares the current request rate and the current limiting rate, if the current request rate and the current limiting rate are released, the current time window count of the API service gateway node is updated;
s8, the next synchronization time is reached, and the operation of step S1 is repeated.
Preferably, when the API service gateway performs the current limiting judgment, the "maximum rate" in each time window is a pre-configured constant, and the "current rate" is calculated according to the request count; in the case of distributed deployment of API service gateways, counting each node individually, would cause the actual throttling rate of the API service gateway cluster to diverge,
preferably, extreme conditions occur: the actual current limiting rate is equal to the preset current limiting rate multiplied by the number of gateway nodes; and (4) introducing central storage, reading and writing the counter by each node in the API service gateway cluster through a network, and sharing request counting.
Preferably, the centrally stored read-write pressure in S6 is only related to the number of API service gateway nodes and the synchronization interval time, and is not related to the inbound request rate.
Preferably, the synchronization interval time will be set to 0 in the extreme case, i.e. each request synchronizes the read-write center storage.
Compared with the prior art, the invention has the following beneficial effects:
1. the invention provides a method for realizing the high-efficiency, expandable and finally consistent current limiting function of the API service gateway, which reduces the influence on the overall performance of the API service gateway while ensuring the accuracy of current limiting and meets the requirement of enterprise-level application.
2. The synchronous interval time of the counter is configured to be smaller than the time of a current limiting window, so that the current limiting rate of the whole API gateway cluster is circulated in a convergence-divergence-convergence state in the time of the current limiting window, and is close to the required current limiting rate as much as possible; the method realizes high-efficiency, expandable and finally consistent distributed current limiting; distributed current limiting irrelevant to the state of the API service gateway node is realized, the number of cluster nodes can be increased and decreased dynamically, current limiting configuration can be modified, and current limiting requirements with different precisions can be met flexibly.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, the present invention provides a technical solution: the design method of the enterprise-level high-performance API service gateway comprises the following steps: starting, inbound requesting, calculating a current limit count KEY, judging whether the current rate exceeds the rate limit or not, releasing the request, increasing the counter, increasing the synchronous counter, rejecting the request, returning an HTTP429 status code, and ending; when the API service gateway node completes the preposed authentication, the flow limiting process after entering the flow limiting link is as follows:
s1, calculating the current limit count KEY of the request according to the configuration of the current limit;
s2, calculating the current request rate according to the type of the current limiting window, including a fixed time window or a sliding time window;
s3, comparing the calculated current request rate with the rate upper limit, if the former is smaller than the latter, releasing the request, and adding 1 to the increment of the corresponding flow limit count KEY; otherwise, rejecting the request and directly returning the HTTP429 status code;
s4, configuring the synchronous interval time of the counter to be smaller than the time of the current limiting window;
s5, the API service gateway node performs read-write operation on the central storage according to the interval time, writes the request times increment in the memory of the API service gateway node into the central storage, and reads the value in the central storage into the memory of the API service gateway node;
s6, the API service gateway node calculates the current request rate according to the type of the current limiting window:
a.) a fixed time window, the current request rate being the current time window count;
b.) sliding the time window, the current request rate being current time window count + (time window length-length the time window has elapsed)/time window length x last time window count;
s7, the API service gateway node compares the current request rate and the current limiting rate, if the current request rate and the current limiting rate are released, the current time window count of the API service gateway node is updated;
s8, the next synchronization time is reached, and the operation of step S1 is repeated.
When the API service gateway judges the current limit, the maximum rate in each time window is a preset constant, and the current rate is calculated according to the request count; in the case of distributed deployment of API service gateways, counting each node individually may cause the actual throttling rate of the API service gateway cluster to diverge.
Extreme conditions occur: the actual current limiting rate is equal to the preset current limiting rate multiplied by the number of gateway nodes; and introducing central storage, reading and writing the counter by each node in the API service gateway cluster through a network, sharing request counting, and setting the synchronization interval time to be 0 under an extreme condition, namely synchronously reading and writing the central storage for each request.
The centrally stored read and write pressure in S6 is only related to the number of API service gateway nodes and the synchronization interval time, and is not related to the inbound request rate.
The counter 'synchronization interval time' is configured to be smaller than the time of a current limiting window; in the time of the current limiting window, the current limiting speed of the whole API gateway cluster is circulated in a state of convergence-divergence-convergence, and is close to the required current limiting speed as much as possible; meanwhile, the read-write pressure stored in the center is only related to the number of the API service gateway nodes and the synchronization interval time, and is not related to the inbound request rate; the overall performance and the current limiting effect of the API service gateway are more stable and controllable; the synchronization interval time is reduced, part of performance of the API service gateway is sacrificed, the convergence effect of the current limiting rate can be improved, and the current limiting is more accurate; under extreme conditions, the synchronous interval time can be set to be 0, namely, each request is synchronously stored in the read-write center, the existing method is degraded, the performance is sacrificed, and the complete accurate current limiting is realized; increasing the synchronization interval allows more current limit deviations, which may improve the performance of the API service gateway.
The working principle is as follows: s1: firstly, deploying load balancing service at the upstream of an API service gateway cluster, and shunting an inbound request to each API service gateway node;
s2: then, each API service gateway node communicates with a central storage in a fixed period, reads the total current limit quota of the cluster and writes the increment of each current limit count;
s3: finally, all API service gateway nodes of the cluster share related data in a fixed period, update the data into respective memories, use the data as a numerical source of a current limiting counter, and cooperate with different current limiting strategies to carry out current limiting;
and adjusting parameters such as a proper current limiting strategy, a synchronization period and the like according to actual needs to finally achieve the current limiting aim.
It will be evident to those skilled in the art that the invention is not limited to the details of the foregoing illustrative embodiments, and that the present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof. The present embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the invention being indicated by the appended claims rather than by the foregoing description, and all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein.
Furthermore, it should be understood that although the present description refers to embodiments, not every embodiment may contain only a single embodiment, and such description is for clarity only, and those skilled in the art should integrate the description, and the embodiments may be combined as appropriate to form other embodiments understood by those skilled in the art.

Claims (5)

1. The design method of the enterprise-level high-performance API service gateway is characterized by comprising the following steps: the content of the design method comprises the following steps: starting, inbound requesting, calculating a current limit count KEY, judging whether the current rate exceeds the rate limit or not, releasing the request, increasing the counter, increasing the synchronous counter, rejecting the request, returning an HTTP429 status code, and ending; when the API service gateway node completes the preposed authentication, the flow limiting process after entering the flow limiting link is as follows:
s1, calculating the current limit count KEY of the request according to the configuration of the current limit;
s2, calculating the current request rate according to the type of the current limiting window, including a fixed time window or a sliding time window;
s3, comparing the calculated current request rate with the rate upper limit, if the former is smaller than the latter, releasing the request, and adding 1 to the increment of the corresponding flow limit count KEY; otherwise, rejecting the request and directly returning the HTTP429 status code;
s4, configuring the synchronous interval time of the counter to be smaller than the time of the current limiting window;
s5, the API service gateway node performs read-write operation on the central storage according to the interval time, writes the request times increment in the memory of the API service gateway node into the central storage, and reads the value in the central storage into the memory of the API service gateway node;
s6, the API service gateway node calculates the current request rate according to the type of the current limiting window:
a.) a fixed time window, the current request rate being the current time window count;
b.) sliding the time window, the current request rate being current time window count + (time window length-length the time window has elapsed)/time window length x last time window count;
s7, the API service gateway node compares the current request rate and the current limiting rate, if the current request rate and the current limiting rate are released, the current time window count of the API service gateway node is updated;
s8, the next synchronization time is reached, and the operation of step S1 is repeated.
2. The enterprise-level high-performance API service gateway design method of claim 1, wherein: when the API service gateway judges the current limit, the maximum rate in each time window is a preset constant, and the current rate is calculated according to the request count; in the case of distributed deployment of API service gateways, counting each node individually may cause the actual throttling rate of the API service gateway cluster to diverge.
3. The enterprise-level high-performance API service gateway design method of claim 2, wherein: when extreme conditions occur: the actual current limiting rate is equal to the preset current limiting rate multiplied by the number of gateway nodes; and (4) introducing central storage, reading and writing the counter by each node in the API service gateway cluster through a network, and sharing request counting.
4. The enterprise-level high-performance API service gateway design method of claim 1, wherein: the read-write pressure stored in the center of the S6 is only related to the number of API service gateway nodes and the synchronization interval time, and is not related to the inbound request rate.
5. The enterprise-level high-performance API service gateway design method of claim 3, wherein: in an extreme case, the synchronization interval time is set to 0, namely, the storage of the read-write center is synchronized every request.
CN201911351580.8A 2019-12-24 2019-12-24 Enterprise-level high-performance API service gateway design method Active CN111010339B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911351580.8A CN111010339B (en) 2019-12-24 2019-12-24 Enterprise-level high-performance API service gateway design method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911351580.8A CN111010339B (en) 2019-12-24 2019-12-24 Enterprise-level high-performance API service gateway design method

Publications (2)

Publication Number Publication Date
CN111010339A CN111010339A (en) 2020-04-14
CN111010339B true CN111010339B (en) 2021-11-30

Family

ID=70117882

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911351580.8A Active CN111010339B (en) 2019-12-24 2019-12-24 Enterprise-level high-performance API service gateway design method

Country Status (1)

Country Link
CN (1) CN111010339B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113765813A (en) * 2020-09-24 2021-12-07 北京沃东天骏信息技术有限公司 Method and device for dynamically adjusting message receiving rate
CN114157719A (en) * 2021-11-05 2022-03-08 广州九尾信息科技有限公司 Gateway current limiting method based on API

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515898A (en) * 2009-03-25 2009-08-26 华为技术有限公司 Method and device for managing statistical data of chip
CN108028753A (en) * 2015-09-03 2018-05-11 飞利浦照明控股有限公司 Network node
CN109672612A (en) * 2018-12-13 2019-04-23 中国电子科技集团公司电子科学研究院 API gateway system
CN110166376A (en) * 2019-06-06 2019-08-23 北京百度网讯科技有限公司 Flow control methods and device, system, server, computer-readable medium
CN110191063A (en) * 2019-06-13 2019-08-30 北京百度网讯科技有限公司 Processing method, device, equipment and the storage medium of service request

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10715448B2 (en) * 2018-05-25 2020-07-14 Software Ag System and/or method for predictive resource management in file transfer servers

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101515898A (en) * 2009-03-25 2009-08-26 华为技术有限公司 Method and device for managing statistical data of chip
CN108028753A (en) * 2015-09-03 2018-05-11 飞利浦照明控股有限公司 Network node
CN109672612A (en) * 2018-12-13 2019-04-23 中国电子科技集团公司电子科学研究院 API gateway system
CN110166376A (en) * 2019-06-06 2019-08-23 北京百度网讯科技有限公司 Flow control methods and device, system, server, computer-readable medium
CN110191063A (en) * 2019-06-13 2019-08-30 北京百度网讯科技有限公司 Processing method, device, equipment and the storage medium of service request

Also Published As

Publication number Publication date
CN111010339A (en) 2020-04-14

Similar Documents

Publication Publication Date Title
CN111010339B (en) Enterprise-level high-performance API service gateway design method
CN104919439B (en) For supporting isomery accumulator system of isomery memory access requests in the system based on processor and associated method and computer-readable media
US7280476B2 (en) Traffic control at a network node
CN104053227B (en) A kind of method and apparatus for anchor main equipment selection
US9459682B2 (en) Power management of devices in a network
CN105608366B (en) User authority control method and device
CN109617986A (en) A kind of load-balancing method and the network equipment
US20120271943A1 (en) Method, apparatus, and system for scheduling distributed buffer resources
CN101425890A (en) Transmitted clock implementing apparatus and method
CN110113406B (en) Distributed computing service cluster system
CN107703878A (en) A kind of PLC distributed remotes I/O expansion module
CN104506462A (en) MAC (Media Access Control) address management method and equipment in distributed switch
WO2022052901A1 (en) Data storage and reconciliation method and system
CN108319617A (en) Determine the method, apparatus and method for handover control, device of database principal and subordinate's difference
CN105246103A (en) Load balancing access method for wireless local area network
CN109194721A (en) A kind of asynchronous RDMA communication dynamic memory management method and system
CN105246137B (en) A kind of micropower wireless network data transmission method and system
CN105657009A (en) Object gateway load balancing system and method, and cross-region object gateway storage system
CN109510681A (en) A kind of communication system time synchronization the smallest datum node selection method of series
CN101702680B (en) Aging method, device and communication equipment of media accessing control address
CN109088937B (en) Cluster authorization method and device based on unified management
CN105682199A (en) Wireless synchronization method and system
KR101771612B1 (en) Synchronization error compensating system and method for EtherCAT
Zhou et al. Demand shaping in cellular networks
CN114124962A (en) Multi-machine room message load balancing processing method and device

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
CP01 Change in the name or title of a patent holder

Address after: No.218-430079, Wuhan New Wuhu science and Technology Park, Wuhan

Patentee after: Xiangji Technology Co.,Ltd.

Address before: No.218-430079, Wuhan New Wuhu science and Technology Park, Wuhan

Patentee before: XIANGJI ZHIYUAN (WUHAN) TECHNOLOGY CO.,LTD.

CP01 Change in the name or title of a patent holder