CN112953840A - Current limiting control method, gateway equipment and current limiting control system - Google Patents

Current limiting control method, gateway equipment and current limiting control system Download PDF

Info

Publication number
CN112953840A
CN112953840A CN202110112831.8A CN202110112831A CN112953840A CN 112953840 A CN112953840 A CN 112953840A CN 202110112831 A CN202110112831 A CN 202110112831A CN 112953840 A CN112953840 A CN 112953840A
Authority
CN
China
Prior art keywords
current limiting
api
gateway device
data
current
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
CN202110112831.8A
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.)
Shanghai Jinshida Chengkuo Information Technology Co ltd
Original Assignee
Shanghai Jinshida Chengkuo Information 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 Shanghai Jinshida Chengkuo Information Technology Co ltd filed Critical Shanghai Jinshida Chengkuo Information Technology Co ltd
Priority to CN202110112831.8A priority Critical patent/CN112953840A/en
Publication of CN112953840A publication Critical patent/CN112953840A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/29Flow control; Congestion control using a combination of thresholds
    • 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

Landscapes

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

Abstract

The application provides a current-limiting control method, a gateway device and a current-limiting control system, relates to the technical field of current-limiting control, and can set different current-limiting thresholds aiming at different APIs (application program interfaces) so that the flexibility of current limiting is higher. The method comprises the following steps: the method comprises the steps that gateway equipment receives an Application Program Interface (API) access request sent by a client, wherein the access request carries a first API identification of a first API of the micro-service; the gateway equipment determines a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identification; the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds; and the gateway equipment carries out current limiting control on the first API through the first current limiting threshold.

Description

Current limiting control method, gateway equipment and current limiting control system
Technical Field
The present application relates to the field of current limiting control technologies, and in particular, to a current limiting control method, a gateway device, and a current limiting control system.
Background
The micro-service can realize function decoupling, so the application range is wider. The current limiting of the micro-service is one of the problems that the micro-service needs to consider, and the current limiting uses the unified default current limiting parameter when the micro-service is limited, which results in poor flexibility of the current limiting.
Disclosure of Invention
The embodiment of the application provides a current limiting control method, a gateway device and a current limiting control system, which can set different current limiting thresholds aiming at different APIs (application program interfaces), so that the flexibility of current limiting is higher.
In view of the above, in a first aspect, the present application provides a current limiting control method, including:
the method comprises the steps that gateway equipment receives an API access request sent by a client, wherein the access request carries a first API identification of a first API of the micro service;
the gateway equipment determines a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identification; the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds;
and the gateway equipment carries out current limiting control on the first API through the first current limiting threshold.
Optionally, the method further comprises:
the gateway equipment acquires current limiting data stored in the zookeeper cluster; and the current limiting threshold in the current limiting data is obtained by respectively setting the different API identifications in the API control equipment.
Optionally, the method further comprises:
the gateway equipment monitors the current limiting data stored in the zookeeper cluster;
when monitoring that the current limiting data is updated, the gateway equipment acquires the updated current limiting data;
and the gateway equipment updates the current limiting data according to the updated current limiting data.
Optionally, the different API identifier is obtained by the API control device from a service registry; the service registration center is configured to register service information for the micro service, where the service information includes the different API identifiers, or includes default current limiting thresholds corresponding to the different API identifiers, and the default current limiting thresholds corresponding to the different API identifiers are the same value.
Optionally, the performing, by the gateway device, current limit control on the first API through the first current limit threshold includes:
the gateway equipment performs current limiting control on the first API through the first current limiting threshold by adopting a preset current limiting algorithm;
wherein, in the case that the preset throttling algorithm comprises a token bucket algorithm, the first throttling threshold comprises a first token bucket capacity and a token inflow rate;
alternatively, the first and second electrodes may be,
in a case where the preset throttling algorithm comprises a leaky bucket algorithm, the first throttling threshold comprises a second token bucket capacity and a token outflow rate.
Optionally, the performing, by the gateway device, current limit control on the first API through the first current limit threshold includes:
the gateway device refuses the API access request under the condition that the first API meets the current limiting condition through the first current limiting threshold value;
alternatively, the first and second electrodes may be,
the gateway device sends the API access request to a first API of the micro-service under the condition that the first API does not meet the current limiting condition determined by the first current limiting threshold value;
the current limiting conditions include: the number of tokens of the API access request is larger than the number of available tokens;
wherein, in case that the preset throttling algorithm comprises the token bucket algorithm, the number of the available tokens is obtained according to the first token bucket capacity and the token inflow rate; or, in a case that the preset throttling algorithm includes the leaky bucket algorithm, the number of the providable tokens is obtained according to the second token bucket capacity and the token outflow rate.
By adopting the current limiting control method, the gateway equipment acquires the corresponding current limiting threshold aiming at the API which requests to access currently in the process of current limiting control and accurately performs current limiting control according to the current limiting threshold in consideration of the fact that the current limiting data comprises the mapping relation between different API identifications and different current limiting thresholds, and the flexibility of current limiting is improved.
In a second aspect, the present application provides a gateway device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, the processor implementing the method according to the first aspect or any alternative of the first aspect when executing the computer program.
In a third aspect, the present application provides a current limit control system comprising: a gateway device and zookeeper cluster;
the gateway device is used for acquiring current limiting data stored in the zookeeper cluster, wherein the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds;
the gateway device is further configured to receive an API access request sent by a client, where the access request carries a first API identifier of a first API of a microservice;
the gateway device is further configured to obtain a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identifier;
the gateway device is further configured to perform current limiting control on the first API through the first current limiting threshold.
Optionally, the gateway device is further configured to listen to the current limiting data stored in the zookeeper cluster;
the gateway equipment is also used for acquiring updated current limiting data when monitoring that the current limiting data is updated;
the gateway device is further configured to update the current limiting data according to the updated current limiting data.
In a fourth aspect, the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, implements a method according to the first aspect or any of the alternatives of the first aspect.
In a fifth aspect, the present application provides a computer program product for causing a current limiting control apparatus to perform the steps of the method of the first aspect or any alternative of the first aspect when the computer program product is run on the current limiting control apparatus.
It is understood that the beneficial effects of the second aspect to the fifth aspect can be referred to the related description of the first aspect, and are not described herein again.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a schematic structural diagram of a current limiting control system according to an embodiment of the present disclosure;
fig. 2 is a schematic structural diagram of a current limiting control system according to an embodiment of the present disclosure;
fig. 3 is a schematic flow chart of a current limiting control method according to an embodiment of the present disclosure;
fig. 4 is a schematic flowchart of a current limiting control method according to an embodiment of the present disclosure;
fig. 5 is a schematic flowchart of a current limiting control method according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a gateway device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items. Furthermore, in the description of the present application and the appended claims, the terms "first," "second," "third," and the like are used for distinguishing between descriptions and not necessarily for describing or implying relative importance.
It should also be appreciated that reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
For ease of understanding, the current limiting control system to which the present application relates will first be described by way of example. As shown in fig. 1, a current limiting control system may include a gateway device cluster (i.e., gateway device 1, gateway device 2, …, gateway device m in fig. 1, m being a positive integer) and a zookeeper cluster (i.e., zookeeper1, zookeeper2, …, zookeeper, n being a positive integer in fig. 1).
In the embodiment of the application, the zookeeper cluster stores limited stream data, and the gateway device can acquire the current limiting data stored in the zookeeper cluster. The current limiting data includes mapping relationships between different API (application programming interface) identifiers and different current limiting thresholds, and the gateway device is a device in the gateway device cluster.
Optionally, all gateway devices or a part of gateway devices in the gateway device cluster may dynamically listen to the zookeeper cluster to obtain the current limiting data.
Optionally, the gateway device is configured to receive an API access request sent by the client, where the access request carries a first API identifier of a first API of the microservice; acquiring a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identification; and performing current limiting control on the first API through the first current limiting threshold.
Optionally, the gateway device is further configured to monitor the flow limiting data stored in the zookeeper cluster; when monitoring that the current limiting data is updated, acquiring the updated current limiting data; and updating the current limiting data according to the updated current limiting data.
It should be noted that specific contents of the gateway device cluster and the zookeeper cluster may refer to the contents in the embodiment shown in fig. 2, and are not described herein again.
Referring to fig. 1, as shown in fig. 2, the current limiting control system may further include: API control device, service registry, micro-service architecture, and server (the application takes the redis server in fig. 2 as an example for explanation). The service registration center may be a terminal device.
It can be understood that a zookeeper cluster may include a plurality of zookeepers, each zookeeper stores current limiting data corresponding to an API of a microservice in a microservice architecture, and the current limiting data may be synchronized between different zookeepers. According to the method and the device, by adopting the zookeeper cluster, if the currently working zookeeper has a fault, one zookeeper is selected from the rest zookeepers to continue working, so that the reliability of the zookeeper can be ensured. And the residual zookeeper is the devices in the zookeeper cluster except the zookeeper which is currently working.
Alternatively, the zookeeper cluster in the present application may be replaced with a single zookeeper, so that the flow limit data may be stored by the single zookeeper.
It will also be appreciated that there may be multiple nodes in each zookeeper and that one node may be selected from the multiple nodes of zookeeper for storage of the current limit data.
As shown in fig. 2, a plurality of gateway devices may be included in the gateway device cluster, and each gateway device may acquire and store throttling data from the zookeeper cluster to perform throttling control on each API of the micro service in the micro service architecture. By adopting the gateway equipment cluster, if the currently working gateway equipment has a fault, one gateway equipment can be selected from the rest gateway equipment to continue working, so that the reliability of the gateway equipment can be ensured. And the rest gateway equipment is equipment in the gateway equipment cluster except the currently working gateway equipment.
In one embodiment, a currently operating gateway device in a gateway device cluster may first obtain current limiting data from a zookeeper cluster (or a currently operating zookeeper), and then the currently operating gateway device may synchronize the current limiting data to the remaining gateway devices; in another embodiment, each gateway device in the gateway device cluster may obtain the current limit data directly from the zookeeper cluster (or the zookeeper currently operating). The above examples are merely illustrative, and the present application is not limited thereto.
Optionally, the gateway device cluster in the present application may be replaced with a single gateway device, so that current limiting control may be performed by the single gateway device.
In the embodiment of the present application, it is considered that the client may be composed of at least one micro service, and each micro service is used for completing an independent service. Therefore, the distributed deployment of the micro-services of different clients can be realized through the micro-service architecture. As shown in fig. 2, the micro service architecture includes a plurality of micro services (i.e., micro service1, micro service2, …, and micro service p in fig. 2, where p is a positive integer).
It can be understood that the APIs of the microservices in the present application are all only open to the gateway device cluster, so that the call security of the APIs is improved to a certain extent.
It should also be understood that there is a variety of interfaces for the API of the microservice, but by using the gateway device cluster, the gateway device cluster can provide a canonical interface to the outside.
The service registration center is used for registering service information of each micro-service in the micro-service architecture, each gateway device in the gateway device cluster and the API control device respectively; the API control equipment is used for setting current limiting thresholds for different APIs; and the gateway device in the gateway device cluster can call a redis server to obtain the current limiting result of the API.
For ease of understanding, fig. 3 shows a schematic diagram of one method of current limit control in conjunction with the current limit control system shown in fig. 2. As shown in fig. 3, the method may include two stages, where the first stage is a process of acquiring current limit data, and the second stage is a process of performing current limit control according to the acquired current limit data.
In particular, the first phase may comprise the steps of:
s301, the micro service architecture registers the service information of the micro service to the service registration center.
It will be appreciated that each microservice in the microservice architecture may each register service information for the microservice with a service registry. The service information of the micro service may include API identifiers of different APIs, or include default current limiting thresholds corresponding to different API identifiers, where the default current limiting thresholds corresponding to different API identifiers are the same value.
Optionally, the API control device may also register service information of the control device with the service registry. The service information of the control device may include identification information of an API in the API control device and identification information of an IP (internet protocol ) in the API control device.
Similarly, each gateway device in the gateway device cluster may also register the service information of the gateway device with the service registry. The service information of the gateway device may include identification information of an API in the gateway device and identification information of an IP in the gateway device.
Therefore, the service registration center registers different devices, so that the service caller can directly acquire the service information of the device to be used from the service registration center, and the service caller can conveniently call the device to be used.
S302, the service registration center sends the service information of the micro service to the API control equipment.
Alternatively, the API control device may acquire service information of all the micro services or service information of a part of the micro services from the service registry. Therefore, the API identification needing personalized current limiting can be selected manually.
S303, the API control equipment sets the current limiting data corresponding to different APIs in the micro service according to the service information of the micro service.
And the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds.
In an embodiment, in a case that the service information of the micro service includes API identifiers of different APIs, the application may set corresponding current limiting thresholds for the different API identifiers, respectively.
In another embodiment, when the service information of the micro service includes default current limiting thresholds corresponding to different API identifiers, and the default current limiting thresholds corresponding to different API identifiers are the same value, the application may delete the default current limiting thresholds corresponding to different API identifiers first, and then set corresponding current limiting thresholds for different API identifiers respectively.
In still other embodiments, when the service information of the micro service includes default current limiting thresholds corresponding to different API identifiers, and the default current limiting thresholds corresponding to different API identifiers are the same value, the application may further classify the different API identifiers to obtain a first type API identifier and a second type API identifier. And then, keeping the current limiting threshold value corresponding to the first class of API identification as a default current limiting threshold value, and respectively setting the corresponding current limiting threshold value for the second class of API identification. In this way, by classifying the API identifications, the user can perform personalized throttling for a portion of the APIs and perform conventional throttling for another portion of the APIs.
When a user logs in the API control device and there is no current limiting data in the API control device, the API control device obtains the current limiting data from the zookeeper cluster. At this time, if no current limiting data exists in the zookeeper cluster, it can be determined that the current limiting control system is started for the first time, and then configuration of the current limiting data is performed in the API control device; if the zookeeper cluster has the current limiting data, it can be determined that the API control device may have a fault to cause data loss, and the API control device may reset according to the current limiting data in the zookeeper cluster.
And S304, the API control equipment sends the current limiting data to the zookeeper cluster.
The API control device may send the current limiting data to each zookeeper in the zookeeper cluster, or the API control device may send the current limiting data to a zookeeper currently operating in the zookeeper cluster, and synchronize the current limiting data to the remaining zookees through the zookeeper currently operating, which is not particularly limited in this application.
In an alternative embodiment, the zookeeper cluster may periodically retrieve the current limit data from the API control device.
S305, the zookeeper cluster stores the current limiting data.
S306, the gateway device obtains the current limiting data stored in the zookeeper cluster.
The gateway device may periodically send a data acquisition request to the zookeeper cluster, and receive the current limiting data sent by the zookeeper cluster according to the data acquisition request. Still alternatively, the zookeeper cluster may periodically send the current limit data to the gateway device.
It is understood that fig. 3 illustrates an example of one gateway device in a gateway device cluster.
Through the steps in the first stage, the gateway device can acquire the current limiting data, so that current limiting control can be performed according to the current limiting data in the following process. In particular, the second stage may comprise the steps of:
s307, the client sends an API access request to the gateway device, wherein the access request carries a first API identifier of a first API of the micro-service.
S308, the gateway device sends a first current limiting threshold corresponding to the first API identification to the redis server under the condition of receiving the API access request.
S309, the redis server obtains the current limiting result of the first API according to the first current limiting threshold corresponding to the first API identifier.
It should be noted that, in consideration of the limited processing resources of the gateway device, the current limiting result of the first API is obtained by calling the redis server, so that the occupation of the processing resources of the gateway device is reduced.
S310, the redis server sends the current limiting result of the first API to the gateway device.
Wherein, when the current limiting result includes that the first API does not satisfy the current limiting condition, S311 and S312 are executed;
in case that the current limiting result includes that the first API satisfies the current limiting condition, S313 is performed.
S311, the gateway device sends an API access request to the micro service architecture.
S312, the micro service architecture calls the first API under the condition that the API access request is received.
S313, the gateway device refuses the API access request.
In summary, the present application may flexibly set the current limiting threshold for different APIs in the API control device, so that the gateway device obtains the corresponding current limiting threshold for the API currently requested to be accessed during the current limiting control process, and accurately performs the current limiting control according to the current limiting threshold, thereby improving the flexibility of current limiting.
Fig. 4 is a schematic flow chart of a current limiting control method provided in the present application. As shown in fig. 4, the current limiting control method may include:
s401, the gateway device receives an API access request sent by a client, wherein the access request carries a first API identification of a first API of the micro service.
The gateway device may be one gateway device in the gateway device cluster in fig. 1 or fig. 2.
It can be understood that when the user uses the client, different business operations can be performed in the client. In this way, the client determines the first API that the business operation needs to call and generates an API access request including the first API identification. Therefore, the client can generate corresponding API access requests according to different business operations.
For example, assuming that the user performs the killing-by-second shopping operation in the client, the client may generate an API access request including the API1 since the killing-by-second shopping operation requires the API1 to be called; assuming that the user performs an after-sales evaluation operation in the client, the client may generate an API access request including the API2, and so on, since the after-sales evaluation operation requires the API2 to be called.
S402, the gateway equipment determines a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identification; the current limit data includes a mapping between different API identifications and different current limit thresholds.
In some embodiments, a gateway device obtains current limit data stored in a zookeeper cluster; the current limiting threshold in the current limiting data is obtained by setting different API identifications in the API control equipment respectively. In this way, the gateway device may pre-store the limited stream data. In this case, the step may be: the gateway device may determine a first current limit threshold corresponding to the first API from the current limit data in the local.
In other embodiments, the gateway device may send the first API identification to the zookeeper cluster upon receiving the API access request. Since the zookeeper cluster may pre-fetch and store the throttling data from the API control device, the gateway device may receive a first throttling threshold determined by the zookeeper cluster from the first API identification and the throttling data. Therefore, the gateway equipment can not store the current limiting data in advance, and the memory capacity of the gateway equipment is prevented from being occupied.
Wherein, different API marks are obtained by the API control equipment from the service registration center; the service registration center is used for registering service information aiming at the micro service, the service information comprises different API identifications, or comprises default current limiting thresholds corresponding to the different API identifications, and the default current limiting thresholds corresponding to the different API identifications are the same numerical value.
Optionally, the API control device is provided with a visual interface, so that an operator can set the current limiting threshold value for different API identifications in the visual interface respectively.
Optionally, considering that the request amount of the same API in different time periods is different, for example, in a twenty-one period, the request amount of a certain API is larger; the request amount of the certain API is small in the period of 9: 00-11: 00 of the working day. Based on the above, the current limiting threshold values in different time periods can be set for the same API identifier in the API control device according to the request quantity of the same API in different time periods.
Alternatively, the interface response rates of different APIs are different, taking into account that different APIs perform different types of services. For example, API1 performs XX1 traffic, API2 performs XX2 traffic, and API1 performs XX1 traffic at an interface response rate v1, and API2 performs XX2 traffic at an interface response rate v 2. Based on this, the application can also set the current limiting threshold value for different API identifications respectively in the API control device according to the interface response rate of different API execution services.
And S403, the gateway device performs current limiting control on the first API through the first current limiting threshold.
In this embodiment, the gateway device may perform current limiting control on the first API through the first current limiting threshold by using a preset current limiting algorithm. The preset current limiting algorithm includes a token bucket algorithm or a leaky bucket algorithm, etc.
Optionally, in a case where the preset throttling algorithm comprises a token bucket algorithm, the first throttling threshold comprises a first token bucket capacity and a token inflow rate.
Optionally, in a case where the preset throttling algorithm comprises a leaky bucket algorithm, the first throttling threshold comprises a second token bucket capacity and a token outflow rate.
For example, in the case where the preset throttling algorithm includes a token bucket algorithm, the throttling data may be as shown in table 1:
TABLE 1 Current Limit data
API identification First token bucket capacity (volume) Token inflow rate (one/unit time)
API 1 5 3
API 2 6 4
Further, the gateway device rejects the API access request under the condition that the first API meets the current limiting condition according to the first current limiting threshold value, so that the micro-service running caused by API overload is effectively avoided; or the gateway device sends the API access request to the first API of the micro-service under the condition that the first API does not meet the current limiting condition through the first current limiting threshold value.
Wherein, the current limiting condition may include: the number of tokens for the API access request is greater than the number of tokens that can be provided.
It will be appreciated that the number of tokens for an API access request may be a predetermined number, for example 1.
Alternatively, in case the pre-set throttling algorithm comprises a token bucket algorithm, the number of tokens may be provided as derived from the first token bucket capacity and said token inflow rate.
It is understood that a token bucket of different APIs is provided in the redis server. For a first token bucket of a first API, a redis server may store history information of the first token bucket, where the history information includes a remaining number of tokens in the first token bucket and a history time when the last API access request obtains the token through the first token bucket.
The redis server may then obtain a current time that the current API access request passed the first token bucket; calculating the time difference between the current time and the historical time; obtaining the current token quantity in the first token bucket, namely calculating the product of the time difference and the token inflow rate to obtain the token inflow, and calculating the sum value between the token inflow and the residual token quantity to obtain the current token quantity; a smaller value is selected from the current number of tokens and the first token bucket capacity as the number of providable tokens.
Alternatively, in the case where the predetermined throttling algorithm includes a leaky bucket algorithm, the number of tokens may be provided as a function of the second token bucket capacity and the token outflow rate.
It is understood that the history information and the current time may be obtained by the method described in the token bucket algorithm; calculating the time difference between the current time and the historical time; obtaining the current token quantity in the first token bucket, namely calculating the product of the time difference and the token outflow rate to obtain the token outflow, calculating the difference between the residual token quantity and the token outflow, if the difference is greater than 0, determining that the difference is the current token quantity, and if the difference is less than or equal to 0, determining that the current token quantity is 0; the difference between the second token bucket capacity and the current number of tokens is calculated as the number of providable tokens. The above process of determining the number of available tokens is only an example, and the present application is not limited thereto.
By adopting the current limiting control method, the gateway equipment acquires the corresponding current limiting threshold aiming at the API which requests to access currently in the process of current limiting control and accurately performs current limiting control according to the current limiting threshold in consideration of the fact that the current limiting data comprises the mapping relation between different API identifications and different current limiting thresholds, and the flexibility of current limiting is improved.
In conjunction with the embodiment shown in fig. 4, as shown in fig. 5, in an alternative embodiment of the present application, after S403, the following steps are further included:
s404, the gateway device monitors the current limiting data stored in the zookeeper cluster.
It can be understood that, in the prior art, the current limiting data of the micro-service is stored in a local configuration file, and it is impossible to monitor whether the current limiting data changes online, which requires restarting the gateway. Therefore, the operation and maintenance burden is increased, the micro-service is unavailable in a short time, and the user experience is reduced. In the method, the zookeeper cluster is adopted to store the current limiting data, so that the updating of the current limiting data can be monitored online in real time without restarting a gateway.
S405, when monitoring that the current limiting data is updated, the gateway device acquires the updated current limiting data.
Wherein the current limit data presence update may include: addition, deletion, or modification of current limit data, etc. At this time, in an embodiment, the updated current limit data may correspond to: added current limit data, deleted current limit data, modified current limit data. Therefore, the data transmission quantity can be reduced by adopting an incremental updating mode.
For example, if the micro service1 is newly added to the micro service architecture, the micro service1 may register the service information of the micro service1 with the service registry. And by setting the current limit data for each API of the microservice 1 in the API control device and sending the current limit data for microservice 1 to the zookeeper cluster, the zookeeper cluster adds the current limit data for microservice 1 to the current limit database. In this way, when the gateway device monitors that the zookeeper cluster performs the adding operation in the current limiting database, the gateway device acquires the current limiting data of the microservice service1 from the zookeeper cluster.
For another example, if the micro service2 in the micro service architecture is no longer used and deleted, the service registration center deregisters the service information of the micro service2 and sends the deregistration information of the micro service2 to the API control device, at this time, the API control device may delete the current limiting data of the micro service2 and forward the deregistration information of the micro service2 to the zookeeper cluster, so that the zookeeper cluster may delete the current limiting data of the micro service2 from the current limiting database. In this way, when the gateway device monitors that the zookeeper cluster performs deletion operation in the current limiting database, the deleted current limiting data is acquired from the zookeeper cluster.
For another example, if the current limiting data of the microservice 3 in the microservice architecture needs to be changed, the current limiting data of the microservice 3 may be changed in the API control device, and the current limiting data after the microservice 3 is changed is sent to the zookeeper cluster, so that the zookeeper cluster may replace the current limiting data before the microservice 3 with the current limiting data after the microservice 3 is changed. In this way, when the gateway device monitors that the zookeeper cluster performs a change operation in the current limiting database, the gateway device obtains the changed current limiting data from the zookeeper cluster.
In another embodiment, the updated current limiter data may be the current limiter data in the zookeeper cluster. Therefore, the data can be updated in a full-scale updating mode.
And S406, the gateway equipment updates the current limiting data according to the updated current limiting data.
Therefore, the gateway device can achieve synchronous updating of the current limiting data by dynamically monitoring the current limiting data in the zookeeper cluster, and therefore the accuracy of current limiting is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.
Based on the current limiting control method provided by the above embodiment, the embodiment of the present invention further provides an embodiment of an apparatus for implementing the above method embodiment.
Fig. 6 is a schematic diagram of a gateway device provided in an embodiment of the present application. As shown in fig. 6, the gateway apparatus 6 of this embodiment includes: a processor 60, a memory 61 and a computer program 62, such as a current limit control program, stored in said memory 61 and executable on said processor 60. The processor 60, when executing the computer program 62, implements the steps in the various embodiments of the current limiting control method described above, such as S301-S303 shown in fig. 3. Alternatively, the processor 60, when executing the computer program 62, implements the functions of the modules/units in the device embodiments.
Illustratively, the computer program 62 may be partitioned into one or more modules/units that are stored in the memory 61 and executed by the processor 60 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 62 in the gateway device 6.
The gateway device may include, but is not limited to, a processor 60, a memory 61. Those skilled in the art will appreciate that fig. 6 is merely an example of a gateway device 6, and does not constitute a limitation of the gateway device 6, and may include more or less components than those shown, or some components in combination, or different components, e.g., the gateway device may also include input-output devices, network access devices, buses, etc.
The Processor 60 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 61 may be an internal storage unit of the gateway device 6, such as a hard disk or a memory of the gateway device 6. The memory 61 may also be an external storage device of the gateway device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, provided on the gateway device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the gateway device 6. The memory 61 is used for storing the computer program and other programs and data required by the gateway device. The memory 61 may also be used to temporarily store data that has been output or is to be output.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the method for controlling current limiting may be implemented.
The embodiment of the present application provides a computer program product, which when running on a gateway device, enables the gateway device to implement the above current limiting control method when executed.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (10)

1. A method of current limit control, comprising:
the method comprises the steps that gateway equipment receives an Application Program Interface (API) access request sent by a client, wherein the access request carries a first API identification of a first API of the micro-service;
the gateway equipment determines a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identification; the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds;
and the gateway equipment carries out current limiting control on the first API through the first current limiting threshold.
2. The method of claim 1, further comprising:
the gateway equipment acquires current limiting data stored in the zookeeper cluster; and the current limiting threshold in the current limiting data is obtained by respectively setting the different API identifications in the API control equipment.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
the gateway equipment monitors the current limiting data stored in the zookeeper cluster;
when monitoring that the current limiting data is updated, the gateway equipment acquires the updated current limiting data;
and the gateway equipment updates the current limiting data according to the updated current limiting data.
4. The method of claim 2, wherein the different API identification is obtained by the API control device from a service registry; the service registration center is configured to register service information for the micro service, where the service information includes the different API identifiers, or includes default current limiting thresholds corresponding to the different API identifiers, and the default current limiting thresholds corresponding to the different API identifiers are the same value.
5. The method of claim 1 or 2, wherein the gateway device performs throttling control on the first API through the first throttling threshold, and wherein the throttling control comprises:
the gateway equipment performs current limiting control on the first API through the first current limiting threshold by adopting a preset current limiting algorithm;
wherein, in the case that the preset throttling algorithm comprises a token bucket algorithm, the first throttling threshold comprises a first token bucket capacity and a token inflow rate;
alternatively, the first and second electrodes may be,
in a case where the preset throttling algorithm comprises a leaky bucket algorithm, the first throttling threshold comprises a second token bucket capacity and a token outflow rate.
6. The method of claim 5, wherein the gateway device performs throttling control on the first API through the first throttling threshold, and wherein the throttling control comprises:
the gateway device refuses the API access request under the condition that the first API meets the current limiting condition through the first current limiting threshold value;
alternatively, the first and second electrodes may be,
the gateway device sends the API access request to a first API of the micro-service under the condition that the first API does not meet the current limiting condition determined by the first current limiting threshold value;
the current limiting conditions include: the number of tokens of the API access request is larger than the number of available tokens;
wherein, in case that the preset throttling algorithm comprises the token bucket algorithm, the number of the available tokens is obtained according to the first token bucket capacity and the token inflow rate; or, in a case that the preset throttling algorithm includes the leaky bucket algorithm, the number of the providable tokens is obtained according to the second token bucket capacity and the token outflow rate.
7. A gateway device comprising a processor, a memory and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 6 when executing the computer program.
8. A current limiting control system, comprising: a gateway device and zookeeper cluster;
the gateway device is used for acquiring current limiting data stored in the zookeeper cluster, wherein the current limiting data comprises mapping relations between different API identifications and different current limiting thresholds;
the gateway device is further configured to receive an API access request sent by a client, where the access request carries a first API identifier of a first API of a microservice;
the gateway device is further configured to obtain a first current limiting threshold corresponding to the first API according to the current limiting data and the first API identifier;
the gateway device is further configured to perform current limiting control on the first API through the first current limiting threshold.
9. The current limiting control system of claim 8,
the gateway device is also used for monitoring the current limiting data stored in the zookeeper cluster;
the gateway equipment is also used for acquiring updated current limiting data when monitoring that the current limiting data is updated;
the gateway device is further configured to update the current limiting data according to the updated current limiting data.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 6.
CN202110112831.8A 2021-01-27 2021-01-27 Current limiting control method, gateway equipment and current limiting control system Pending CN112953840A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110112831.8A CN112953840A (en) 2021-01-27 2021-01-27 Current limiting control method, gateway equipment and current limiting control system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110112831.8A CN112953840A (en) 2021-01-27 2021-01-27 Current limiting control method, gateway equipment and current limiting control system

Publications (1)

Publication Number Publication Date
CN112953840A true CN112953840A (en) 2021-06-11

Family

ID=76238043

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110112831.8A Pending CN112953840A (en) 2021-01-27 2021-01-27 Current limiting control method, gateway equipment and current limiting control system

Country Status (1)

Country Link
CN (1) CN112953840A (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342498A (en) * 2021-06-28 2021-09-03 平安信托有限责任公司 Concurrent request processing method, device, server and storage medium
CN113518041A (en) * 2021-06-15 2021-10-19 新华三大数据技术有限公司 Message processing method and device
CN114039893A (en) * 2021-11-08 2022-02-11 航天信息股份有限公司 API gateway speed limiting method and device
CN114465959A (en) * 2021-12-24 2022-05-10 南京苏宁电子信息技术有限公司 Interface dynamic flow control method and device, computer equipment and storage medium
CN114979012A (en) * 2022-05-31 2022-08-30 济南浪潮数据技术有限公司 Network flow current limiting method, system, device and computer storage medium
CN115242722A (en) * 2022-06-14 2022-10-25 中盈优创资讯科技有限公司 Advanced flow control implementation method based on API gateway
CN116743833A (en) * 2023-08-16 2023-09-12 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106713168A (en) * 2016-12-21 2017-05-24 上海艾融软件股份有限公司 Flow control method and system
CN109218212A (en) * 2018-09-03 2019-01-15 四川长虹电器股份有限公司 Method for limiting flow through API gateway
CN109842565A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Interface current-limiting method, device, electronic equipment and storage medium
CN110535777A (en) * 2019-08-12 2019-12-03 新华三大数据技术有限公司 Access request control method, device, electronic equipment and readable storage medium storing program for executing
CN110545246A (en) * 2018-05-29 2019-12-06 北京京东尚科信息技术有限公司 Token bucket-based current limiting method and device
CN111447150A (en) * 2020-02-29 2020-07-24 中国平安财产保险股份有限公司 Access request current limiting method, server and storage medium
CN111813576A (en) * 2020-07-08 2020-10-23 北京思特奇信息技术股份有限公司 Business service management method and system based on micro-service

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106713168A (en) * 2016-12-21 2017-05-24 上海艾融软件股份有限公司 Flow control method and system
CN110545246A (en) * 2018-05-29 2019-12-06 北京京东尚科信息技术有限公司 Token bucket-based current limiting method and device
CN109218212A (en) * 2018-09-03 2019-01-15 四川长虹电器股份有限公司 Method for limiting flow through API gateway
CN109842565A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Interface current-limiting method, device, electronic equipment and storage medium
CN110535777A (en) * 2019-08-12 2019-12-03 新华三大数据技术有限公司 Access request control method, device, electronic equipment and readable storage medium storing program for executing
CN111447150A (en) * 2020-02-29 2020-07-24 中国平安财产保险股份有限公司 Access request current limiting method, server and storage medium
CN111813576A (en) * 2020-07-08 2020-10-23 北京思特奇信息技术股份有限公司 Business service management method and system based on micro-service

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张德安、李油建、王新玲: "《集群化录井特色技术》" *

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113518041A (en) * 2021-06-15 2021-10-19 新华三大数据技术有限公司 Message processing method and device
CN113518041B (en) * 2021-06-15 2023-05-16 新华三大数据技术有限公司 Message processing method and device
CN113342498A (en) * 2021-06-28 2021-09-03 平安信托有限责任公司 Concurrent request processing method, device, server and storage medium
CN114039893A (en) * 2021-11-08 2022-02-11 航天信息股份有限公司 API gateway speed limiting method and device
CN114465959A (en) * 2021-12-24 2022-05-10 南京苏宁电子信息技术有限公司 Interface dynamic flow control method and device, computer equipment and storage medium
CN114979012A (en) * 2022-05-31 2022-08-30 济南浪潮数据技术有限公司 Network flow current limiting method, system, device and computer storage medium
CN115242722A (en) * 2022-06-14 2022-10-25 中盈优创资讯科技有限公司 Advanced flow control implementation method based on API gateway
CN115242722B (en) * 2022-06-14 2024-04-16 中盈优创资讯科技有限公司 Advanced flow control implementation method based on API gateway
CN116743833A (en) * 2023-08-16 2023-09-12 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service
CN116743833B (en) * 2023-08-16 2023-11-03 雄安国创中心科技有限公司 Method and device for enhancing communication capability and network control capability of terminal and service

Similar Documents

Publication Publication Date Title
CN112953840A (en) Current limiting control method, gateway equipment and current limiting control system
CN110535777B (en) Access request control method and device, electronic equipment and readable storage medium
US8001555B2 (en) Method and apparatus for operating an open API network having a proxy
US7283539B2 (en) Method and system for managing message-based applications and applications providers in a communications network
US10389801B2 (en) Service request processing method, related apparatus, and system
WO2021254331A1 (en) Resource management method and system, proxy server, and storage medium
CN108183849B (en) Device management method, device and system based on L2TP
CN110661717A (en) Current limiting method and device and electronic equipment
CN112261133A (en) CDN node control method, device, server and storage medium
US8396057B2 (en) Method and apparatus for traffic regulation in a communication network
CN109413117B (en) Distributed data calculation method, device, server and computer storage medium
CN112671914A (en) IOT (Internet of things) equipment communication method and system based on actor model
CN112073329A (en) Distributed current limiting method and device, electronic equipment and storage medium
CN117014189A (en) Multi-gateway scheduling processing method, equipment, system, server and storage medium
CN114189893B (en) O-RAN capability opening method, communication system, device and storage medium
CN114745277B (en) Elastic expansion method and device for public cloud cross-domain private line, electronic equipment and medium
CN113835905B (en) Message queue load balancing method and device, electronic equipment and medium
CN114143403A (en) Intelligent outbound method, device, outbound system and storage medium
EP3675461B1 (en) Electronic communication node load balancing system and method
KR101048875B1 (en) Load balancing system and method of IMS server in internet telephony service
TWI723314B (en) Communication device, communication control method, and control device
CN110417566B (en) Multi-head configuration method, device and system
WO2017199099A1 (en) Communication method for use between sdn device and ocs, sdn device, and ocs
CN116455985A (en) Distributed service system, method, computer equipment and storage medium
CN116684355A (en) Distributed current limiting method and device, electronic equipment 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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20210611