Request flow limiting method and related equipment thereof

By judging the order of magnitude relationship between the preset current limit value and the number of gateway modules, it is decided to divide the current limit value into the gateway module or configure it to centralized components, which solves the problem of request overflow when requesting current limit by clustered gateway devices, and improves the problem of request overflow when requesting current limit. The user experience and the reliability of the current limiting system.

CN119420702APending Publication Date: 2025-02-11HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310921715.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-25
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

Gateway devices deployed in clusters are prone to request overflow when requesting flow restrictions, resulting in request rejection or delay processing, affecting user experience.

Method used

By obtaining the current limiting information corresponding to the request, the order of magnitude relationship between the preset current limiting value and the number of gateway modules is judged, and the current limiting value is divided into the gateway module or configured to the centralized component according to the judgment results to perform current limiting.

Benefits of technology

Reduces the chance of request abnormal overflow, improves user experience, and improves the reliability of the current limiting system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420702A_ABST
    Figure CN119420702A_ABST
Patent Text Reader

Abstract

The invention relates to a request flow limiting method and related equipment thereof. The method comprises the following steps: acquiring current limiting information corresponding to a request, the current limiting information comprising a preset current limiting value corresponding to a preset current limiting calculation period; under the condition that the number of the gateway modules corresponding to the request in the gateway cluster is multiple, the magnitude order relation between the preset current limiting value and the number of the gateway modules is judged; when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of the gateway modules, dividing the preset current limiting value to the gateway modules according to the number of the gateway modules, and carrying out current limiting on the requests based on counting of the requests by the gateway modules; and when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules, configuring a preset current limiting value to the gateway modules, and carrying out current limiting on the requests based on counting of the requests by the centralized component. Through application of the method and the device, the probability of abnormal overflow of the request existing in request flow limiting by the gateway equipment deployed in a clustered manner is reduced, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a request current limiting method and related equipment. Background Art

[0002] This section is intended to provide a background or context to the embodiments of the invention recited in the claims. No admission is made that the description herein is prior art by its inclusion in this section.

[0003] In order to protect upstream and downstream applications, it is necessary to limit the flow of requests sent by upstream nodes. Currently, request flow limiting is usually done by periodically counting the number of requests in the local memory of a single machine through a gateway device to limit the number of requests released within a cycle. In clustered gateway devices, flow limiting is performed at the traffic entrance through multiple gateway modules (physical machines or virtual machines) in the cluster. However, since requests do not flow evenly into multiple gateway modules, when the request has not reached the overall flow limit value, there is still a high possibility of request overflow on a certain gateway module, resulting in request rejection or delayed processing, affecting the user experience. Summary of the invention

[0004] The request current limiting method and related devices provided by the embodiments of the present invention at least solve the problem of abnormal overflow of requests for request current limiting of clustered gateway devices.

[0005] A request current limiting method, comprising: Acquire current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; When there are multiple gateway modules corresponding to the request in the gateway cluster, determining the order of magnitude relationship between the preset current limiting value and the number of the gateway modules; In a case where the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of the gateway modules, the preset current limiting value is divided among the gateway modules according to the number of the gateway modules, and the request is current limited based on the count of the request by the gateway module; When the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules, the preset current limiting value is configured for the gateway module, and the request is current limited based on the count of the request by the centralized component.

[0006] In some embodiments, determining the order of magnitude relationship between the preset current limiting value and the number of the gateway modules includes: Determine whether the preset current limit value P is greater than k×Q, where Q is the number of gateway modules corresponding to the request in the gateway cluster, and k is a preset constant greater than or equal to 1; In the case where P is greater than k×Q, determining that the order of magnitude of the preset current limit value is greater than the order of magnitude of the number of the gateway modules; When P is not greater than k×Q, it is determined that the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules.

[0007] In some of the embodiments, the current limiting information includes: a preset current limiting value of the requesting party of the request within a preset current limiting calculation period, and / or a preset current limiting value of the receiving party of the request within a preset current limiting calculation period.

[0008] In some embodiments, the method further comprises: Obtain a current limiting strategy, and determine whether to limit the request according to the current limiting strategy, wherein the current limiting strategy includes one of the following: limiting the request of all requesters, limiting the request of a preset requester, and limiting the request of other requesters except the preset requester.

[0009] In some embodiments, allocating the preset current limiting value to the gateway modules according to the number of the gateway modules includes: The preset current limiting value is evenly or unevenly distributed to the gateway modules.

[0010] In some embodiments, limiting the request based on the count of the request by the centralized component includes: The information of the request received by the gateway module is sent to the centralized component, the count of the request by the centralized component is obtained, the count of the request by the centralized component is compared with the size of the preset current limiting value, and the gateway module limits the current of the request based on the comparison result.

[0011] In some embodiments, after allocating the preset current limiting value to the gateway modules according to the number of the gateway modules and limiting the current of the request based on the count of the request by the gateway module, the method further includes: Determine whether the count of the request by the gateway module within the preset current limiting calculation period reaches a first preset threshold, wherein the first preset threshold is determined based on a preset percentage of the current limiting value obtained by the division of the gateway module; When the count of the requests by the gateway module within the preset current limiting calculation period reaches the first preset threshold, the current limiting value of the gateway module is reconfigured, and the request is current limited based on the count of the requests by the centralized component.

[0012] In some embodiments, when the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limit value of the gateway module includes: The current limiting value of the gateway module is configured as the preset current limiting value.

[0013] In some embodiments, when the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limit value of the gateway module includes: When there are multiple gateway modules in the gateway cluster whose counts of the requests within the preset current limiting calculation period reach the first preset threshold, the current limiting value of the gateway module is configured as the sum of the current limiting values ​​divided by the multiple gateway modules.

[0014] In some embodiments, when the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limit value of the gateway module includes: When there are multiple gateway modules in the gateway cluster whose counts of the requests reach the first preset threshold, the current limiting value of the gateway module is configured to be a value between the sum of the current limiting values ​​divided by the multiple gateway modules and the preset current limiting value.

[0015] In some embodiments, the preset percentage corresponding to the first preset threshold value ranges from 80% to 90%.

[0016] In some embodiments, after reconfiguring the current limiting value of the gateway module and current limiting the request based on the count of the request by the centralized component, the method further includes: Determine whether the count of the request by the centralized component within the preset current limiting calculation period is lower than a second preset threshold, wherein the second preset threshold is determined based on a preset percentage of the current limiting value reconfigured by the gateway module, and the second preset threshold is less than the first preset threshold; When the count of the request by the centralized component within the preset current limiting calculation period is lower than the second preset threshold, the current limiting value obtained by dividing the gateway module when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules is restored, and the request is current limited based on the count of the request by the gateway module.

[0017] In some embodiments, the preset percentage corresponding to the second preset threshold value ranges from 40% to 70%.

[0018] A gateway system includes a gateway cluster and a centralized component, wherein the gateway cluster includes a plurality of gateway modules; The gateway cluster is used to: obtain current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; when there are multiple gateway modules corresponding to the request in the gateway cluster, determine the order of magnitude relationship between the preset current limiting value and the number of the gateway modules; when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of the gateway modules, divide the preset current limiting value to the gateway modules according to the number of the gateway modules, and limit the request based on the count of the request by the gateway module; The centralized component is used to: count the requests when the order of magnitude of the current limit value is not greater than the order of magnitude of the number of the gateway modules; The gateway cluster is also used to: when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules, configure the preset current limiting value to the gateway module, and limit the request based on the count of the request by the centralized component.

[0019] An electronic device comprises: a processor and a memory storing a program, wherein the program comprises instructions, and when the instructions are executed by the processor, the processor executes the above method.

[0020] A non-transitory machine-readable medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the above method.

[0021] The request current limiting method and related devices provided by the embodiments of the present invention obtain current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; when there are multiple gateway modules corresponding to the request in the gateway cluster, determine the order of magnitude relationship between the preset current limiting value and the number of gateway modules; when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules, divide the preset current limiting value to the gateway modules according to the number of gateway modules, and limit the request based on the count of requests by the gateway modules; when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of gateway modules, configure the preset current limiting value to the gateway module, and limit the request based on the count of requests by the centralized component, thereby reducing the probability of abnormal overflow of requests for request current limiting in clustered gateway devices and improving user experience.

[0022] The details of one or more embodiments of the invention are set forth in the following drawings and description so that other features, objects, and advantages of the invention are more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other embodiments can be obtained based on these drawings without creative work.

[0024] Figure 1 Flow chart of the request current limiting method of this embodiment.

[0025] Figure 2 Schematic diagram of the request current limiting system of this embodiment.

[0026] Figure 3 Schematic diagram of the gateway system of this embodiment.

[0027] Figure 4 Schematic diagram of the structure of the electronic device of this embodiment. DETAILED DESCRIPTION

[0028] Embodiments of the present embodiment will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present embodiment are shown in the accompanying drawings, it should be understood that the present embodiment can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, which are instead provided for a more thorough and complete understanding of the present embodiment. It should be understood that the drawings and embodiments of the present embodiment are only for exemplary purposes and are not intended to limit the scope of protection of the present embodiment.

[0029] In order to ensure service stability, it is necessary to limit the number of requests sent by the client to the server, which is called request flow limiting. Flow limiting is usually performed at the traffic entrance. For example, at the gateway device, flow limiting is performed on requests passing through the gateway device according to the policy. The main methods of flow limiting include discarding requests that exceed the flow limit value within the flow limit calculation cycle, or delaying requests that exceed the flow limit value within the current flow limit calculation cycle to the next flow limit calculation cycle (discarding, releasing, or delaying again).

[0030] This embodiment provides a request current limiting method. Figure 1 is a flow chart of the request current limiting method of this embodiment. Figure 1 As shown, the process includes the following steps: Step S101, obtaining current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period.

[0031] Step S102 : when there are multiple gateway modules corresponding to the request in the gateway cluster, determine the order of magnitude relationship between the preset current limiting value and the number of gateway modules.

[0032] Step S103, when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules, the preset current limiting value is divided into the gateway modules according to the number of gateway modules, and the requests are current limited based on the count of the requests by the gateway modules.

[0033] Step S104, when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of gateway modules, the preset current limiting value is configured for the gateway module, and the request is current limited based on the count of the request by the centralized component.

[0034] By adopting the above steps, it is determined whether the gateway module performs single-machine current limiting on the request count, or the centralized component performs cluster current limiting on the request count according to the order of magnitude relationship between the preset current limiting value and the number of gateway modules. In the related art, all gateway modules are used for single-machine current limiting. When the preset current limiting value is relatively too small and the number of gateway modules in the gateway cluster is relatively too large, it is easy for the total number of requests to not reach the total current limiting value while the individual single machine has reached the current limiting value, resulting in request overflow, thereby causing the request to be abnormally current limited and affecting the user experience. In comparison, the above steps count requests based on the centralized component when the preset current limiting value is relatively too small and the number of gateway modules in the gateway cluster is relatively excessive. The centralized counting of requests by the gateway module based on the centralized component can reduce the probability of abnormal overflow of requests and improve the user experience.

[0035] In addition, although the method of using centralized components for global current limiting for all requests in the related technology can also avoid the abnormal overflow of requests caused by the current limiting of a single machine in the gateway cluster, on the one hand, the centralized component (such as redis) has a concurrency limit. If too many requests arrive at redis at the same time, exceeding its maximum connection limit, the new request will be blocked or rejected, which will cause some requests to be mistakenly considered to exceed the current limit, thereby causing the inaccuracy of the current limiting scheme; on the other hand, the centralized component is connected to the application through the network and is limited by the network delay. Compared with the single machine current limiting of the gateway device, the network delay causes the reliability of the centralized component to limit the request current to be reduced, especially when the number of requests is large. The reliability reduction is particularly obvious. In comparison, the above steps of this embodiment do not count the current limiting of all requests by the centralized component, but determine who counts the requests based on the order of magnitude relationship between the preset current limiting value and the number of gateway modules, so that part of the requests are counted by the gateway module, and the other part of the requests are counted by the centralized component, thereby improving the reliability of the entire current limiting system.

[0036] Among them, the centralized components include but are not limited to components based on redis or zookeeper. Among them, the redis-based components use lua scripts to count requests. On the one hand, the count value of the centralized component is a centralized and statistical count of requests from multiple gateway modules. On the other hand, the count value is synchronized to multiple gateway modules so that these gateway modules can limit the flow of requests according to the count value of the centralized component and the flow limit value configured by the gateway module. In this embodiment, the algorithms used to limit the flow of requests include but are not limited to fixed window algorithms, sliding window algorithms, leaky bucket algorithms, and token bucket algorithms. Accordingly, when counting requests, the gateway module and the centralized component respectively use counting methods corresponding to the above-mentioned flow limit algorithms for counting.

[0037] In the above steps, the current limiting information corresponding to the request refers to the current limiting information of the requesting party and / or the receiving party of the request. For example, the current limiting information includes: the preset current limiting value of the requesting party of the request within the preset current limiting calculation period, and / or, the preset current limiting value of the receiving party of the request within the preset current limiting calculation period. In this embodiment, the corresponding current limiting information can be set for the requesting party of the request, and the corresponding current limiting information can also be set for the receiving party of the request, or the corresponding current limiting information can be set for both the requesting party and the receiving party of the request, so as to realize current limiting according to the requesting party of the request, current limiting according to the receiving party of the request, or combined current limiting according to the requesting party and the receiving party of the request. Among them, combined current limiting means that the request must meet the current limiting requirements of the requesting party on the one hand, and also meet the current limiting requirements of the receiving party, and the request will be released, otherwise it will be congested or rejected.

[0038] The requester of the request may be, for example, a client or an application (APP), and the recipient of the request may be, for example, a server or an application program interface (API) provided by the server. The client may be a physical machine or a virtual machine, and the server may be a centralized server or a distributed server cluster.

[0039] In the above steps, the gateway cluster includes multiple gateway modules, which can be virtual machines or physical machines, and each gateway module is used to process the request flowing through the gateway module. When the request is transmitted to the gateway cluster, it can be assigned to one or more gateway modules in the gateway cluster for processing according to the set load balancing method. The gateway module to which the request can be assigned is the gateway module corresponding to the request in this embodiment. The request can correspond to all gateway modules in the cluster, that is, the request can be assigned to any gateway module in the gateway cluster through load balancing; the request can also correspond to some gateway modules in the cluster, that is, the request is assigned to a part of the specific gateway modules in the gateway cluster through load balancing. For example, for a specific request, one or more specific gateway modules are assigned to process the request to ensure that the specific request can be reliably processed.

[0040] There are many ways to load balance requests. One is to evenly distribute requests to multiple corresponding gateway modules according to different requesters and different receivers; the other is to randomly but evenly distribute requests to multiple corresponding gateway modules regardless of the requester and the receiver. The first load balancing method can theoretically ensure that request overflow is avoided under the condition of single-machine current limiting. However, it is highly complex to evenly distribute requests according to different requesters and different receivers at the same time. There is a possibility that the distribution cannot be uniform no matter how it is distributed. Therefore, the second load balancing method is a more common load balancing method. This load balancing method can only ensure that the total amount of requests can be evenly distributed, but cannot ensure that the requests corresponding to the same requester and the same receiver can be evenly distributed to multiple gateway modules. This is the main reason why the gateway cluster is prone to request overflow when using the single-machine current limiting method.

[0041] For example, when the preset current limit value is 10, if the number of gateway modules in the gateway cluster is 20, then if these 20 gateway modules are to be used to limit the requests, if the current limit value of each gateway module is configured to 0.5 (equivalent to releasing one request in two cycles), since the requests are always unevenly distributed to any gateway module, the number of requests sent by the requester is also 10 and does not exceed the total current limit value. However, if two requests are distributed to a gateway module in two cycles, one of the requests will overflow and be limited. Therefore, when the preset current limit value is too small and the gateway module is too large, the probability of abnormal overflow of requests in single-machine current limiting is high due to uneven request distribution.

[0042] For example, when the preset current limit value is 1000, if the number of gateway modules in the gateway cluster is 10, then if these 10 gateway modules are to be used to limit the requests, if the current limit value of each gateway module is configured as 100, the requests are also unevenly distributed to any gateway module. At this time, the number of requests sent by the requester is 1000, which does not exceed the total current limit value. The number of requests allocated to each gateway module is a random value between 80 and 120. At this time, only a maximum of 20% of the requests on some gateway modules will overflow abnormally. Therefore, when the preset current limit value is large and the gateway module is small, the probability of abnormal overflow of requests in single-machine current limit caused by uneven request distribution is small.

[0043] Therefore, in some of the embodiments, determining the order of magnitude relationship between the preset current limiting value and the number of gateway modules includes: determining whether the preset current limiting value P is greater than k×Q, where Q is the number of gateway modules corresponding to the request in the gateway cluster, and k is a preset constant greater than or equal to 1; when P is greater than k×Q, determining that the order of magnitude of the preset current limiting value is greater than the order of magnitude of the gateway module; when P is not greater than k×Q, determining that the order of magnitude of the current limiting value is not greater than the order of magnitude of the gateway module. For example, the above k value can be a constant such as 1, 5, 8, 10, 100, 200, or a decimal value such as 1.5, 9.5, etc.

[0044] In some of the embodiments, a flexible current limiting strategy can be implemented. For example, when the current limiting value of the requester and the current limiting value of the receiver are respectively pre-set, the combined current limiting of the requester and the receiver can be implemented, such as the combined current limiting of the APP and the API. In addition, in order to further improve the flexibility of the current limiting strategy, in this embodiment, the current limiting strategy can also be obtained, and it is determined whether to limit the request according to the current limiting strategy, wherein the current limiting strategy includes one of the following: current limiting the requests of all requesters, current limiting the requests of the preset requester, and current limiting the requests of other requesters except the preset requester. The above three strategies are respectively referred to as global current limiting, blacklist current limiting and whitelist current limiting.

[0045] In some of the embodiments, when a single machine current limiting method is adopted, that is, a method of current limiting requests based on the count of the gateway module, the current limiting value of the gateway module is divided evenly or unevenly based on the preset current limiting value and the number of gateway modules. Among them, the uneven division can be based on the processing performance of the gateway module, for example, a current limiting value higher than the average value can be configured for the gateway module with higher processing performance, and when load balancing, the proportion of requests allocated to the gateway module with higher processing performance is also increased accordingly.

[0046] Figure 2 is a schematic diagram of the request current limiting system of this embodiment. Figure 2As shown, when limiting the flow of requests based on the counting of requests by the centralized component, after the gateway cluster receives a specific request, the information of the specific request (including the receiving time of the request, the requester of the request, the recipient of the request, etc.) is sent to the centralized component, and the centralized component counts the requests according to the receiving time of the request, the requester of the request, and the recipient of the request, and its counting period is also the preset flow limiting calculation period. The centralized component will uniformly count the specific requests of multiple gateway modules, and the gateway module will then synchronously obtain the count value of the specific request from the centralized component, compare the count of the request by the centralized component with the preset flow limiting value currently configured by the gateway module, and the gateway module will limit the flow of the request based on the comparison result.

[0047] In some of the embodiments, after the preset current limiting value is divided among the gateway modules according to the number of gateway modules, and the current limiting is performed on the requests based on the count of the requests by the gateway modules, it is also possible to detect whether the count of the gateway modules reaches the threshold, so that the centralized component is used to count the requests in advance before the gateway module single machine has not reached the current limiting value obtained by the division, so as to avoid the overflow of the requests on the gateway module single machine. For example, it is determined whether the count of the requests by the gateway module reaches the first preset threshold within the preset current limiting calculation cycle, wherein the first preset threshold is determined based on the preset percentage of the current limiting value obtained by the division of the gateway module; when the count of the requests by the gateway module reaches the first preset threshold within the preset current limiting calculation cycle, the current limiting value of the gateway module is reconfigured, and the requests are current limited based on the count of the requests by the centralized component.

[0048] The preset percentage corresponding to the above-mentioned first preset threshold value ranges from 80% to 90%.

[0049] When limiting the flow of requests based on the count of requests by the centralized component, if the preset flow limiting calculation period has not expired, the gateway module will also send the current count value of the request to the centralized component, so that the centralized component can count based on the current count value of the request. It can also be selected that at the time when the preset flow limiting calculation period expires, the counting by the gateway module is switched to the counting by the centralized component, so as to avoid transmitting the current count value of the gateway module between the gateway module and the centralized component.

[0050] When the current limiting value of the gateway module is reconfigured as described above, the current limiting value of the gateway module can be configured as the preset current limiting value. At this time, among the gateway modules of the gateway cluster, a part of the current limiting values ​​are configured as the preset current limiting values, but the unified count of the centralized components is used as the current limiting basis, and the current limiting values ​​of the other part are pre-divided into current limiting values ​​evenly or unevenly according to the number of gateway modules. Therefore, at this time, the overall current limiting value of the gateway cluster for the request is slightly higher than the preset current limiting value.

[0051] For example, the preset flow limit value is 300, and the flow limit values ​​of gateway modules A, B, and C are 100 respectively; when the stand-alone counts of gateway modules A and B reach the first preset threshold of 80, the centralized component count is used, and the flow limit values ​​of gateway modules A and B are reconfigured to 300. If the count value of gateway module C is 70 (which does not reach the first preset threshold), only requests exceeding 300 on gateway modules A and B will be limited. At this time, the total flow allowed to be released by the gateway cluster is 300 + the flow of gateway module C (less than 80), which is greater than the preset flow limit value of 300.

[0052] To this end, in other embodiments, when the current limiting value of the gateway module is reconfigured as described above, if there are multiple gateway modules in the gateway cluster whose request counts reach the first preset threshold value within the preset current limiting calculation period, the current limiting value of the gateway module is configured as the sum of the current limiting values ​​obtained by dividing the multiple gateway modules. At this time, in the gateway modules of the gateway cluster, a part of the current limiting values ​​is configured as the sum of the current limiting values ​​obtained by dividing the multiple gateway modules (gateway modules that use centralized component counting for current limiting), but the statistical count of the centralized component is used as the current limiting basis, and the current limiting values ​​of the other part are pre-divided according to the number of gateway modules. The current limiting value is evenly or unevenly divided in advance. Therefore, at this time, the overall current limiting value of the gateway cluster for the request is just equal to the preset current limiting value, but due to the advance occupation of the current limiting value by the pre-divided current limiting value, the maximum flow that can be passed by the request on the gateway cluster cannot reach the preset current limiting value, and there is always a part that is wasted, and the wasted flow value is equal to the sum of the remaining number of the current limiting values ​​of the gateway modules that have not yet used the centralized component counting for current limiting.

[0053] For example, the preset flow limit value is 300, and the flow limit values ​​of gateway modules A, B, and C are 100 respectively; when the stand-alone count of gateway modules A and B reaches the first preset threshold of 80, the centralized component count is used, and the flow limit values ​​of gateway modules A and B are reconfigured to 200. If the count value of gateway module C is 70 (which does not reach the first preset threshold), only requests exceeding 200 on gateway modules A and B will be limited. At this time, the total flow allowed to be released by the gateway cluster is 200 + the flow of gateway module C (less than 80), which is less than the preset flow limit value of 300.

[0054] In order to make the overall current limiting value of the gateway cluster for requests closer to the preset current limiting value, in some embodiments, when the current limiting value of the gateway module is reconfigured as mentioned above, when the count of requests from multiple gateway modules in the gateway cluster reaches a first preset threshold, the current limiting value of the gateway module is configured to be a value between the sum of the current limiting values ​​divided by multiple gateway modules and the preset current limiting value.

[0055] For example, the preset flow limit value is 300, and the flow limit values ​​of gateway modules A, B, and C are 100 respectively; when the stand-alone counts of gateway modules A and B reach the first preset threshold of 80, the centralized component count is used, and the flow limit values ​​of gateway modules A and B are reconfigured to values ​​between 200 and 300, for example, set to 220. If the count value of gateway module C is 70 (not reaching the first preset threshold), only requests exceeding 220 on gateway modules A and B will be limited. At this time, the total flow allowed to be released by the gateway cluster is 220 + the flow of gateway module C (less than 80), which is close to the preset flow limit value of 300.

[0056] In the above embodiment, the probability of request overflow is reduced by switching the stand-alone count of the gateway module to the centralized count of the centralized component (also called cluster count). In other embodiments, the centralized count of the centralized component can also be switched to the stand-alone count of the gateway module to avoid being affected by defects such as the connection number limit of the centralized component. In some of the embodiments, after reconfiguring the current limit value of the gateway module and limiting the current of the request based on the count of the request by the centralized component, the method also includes: determining whether the count of the request by the centralized component within the preset current limit calculation cycle is lower than the second preset threshold, wherein the second preset threshold is determined based on the preset percentage of the current limit value reconfigured by the gateway module, and the second preset threshold is less than the first preset threshold; when the count of the request by the centralized component within the preset current limit calculation cycle is lower than the second preset threshold, the current limit value obtained by the division of the gateway module when the order of magnitude of the preset current limit value is greater than the order of magnitude of the number of gateway modules is restored, and the request is limited based on the count of the request by the gateway module.

[0057] In some of the embodiments, the preset percentage corresponding to the second preset threshold value ranges from 40% to 70%.

[0058] Figure 3 is a schematic diagram of the gateway system of this embodiment, such as Figure 3 As shown, the gateway system includes a gateway cluster 30 and a centralized component 40 , wherein the gateway cluster 30 includes a plurality of gateway modules 301 .

[0059] The gateway cluster 30 is used to: obtain current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; when there are multiple gateway modules corresponding to the request in the gateway cluster, determine the order of magnitude relationship between the preset current limiting value and the number of gateway modules; when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules, divide the preset current limiting value to the gateway modules according to the number of gateway modules, and limit the request based on the count of the request by the gateway module.

[0060] The centralized component 40 is used to count requests when the magnitude of the current limiting value is not greater than the magnitude of the number of gateway modules.

[0061] The gateway cluster 30 is also used to: when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of gateway modules, configure the preset current limiting value to the gateway module, and limit the request based on the count of the request by the centralized component.

[0062] In some of the embodiments, the gateway cluster 30 determines the order of magnitude relationship between the preset current limiting value and the number of gateway modules, including: determining whether the preset current limiting value P is greater than k×Q, where Q is the number of gateway modules corresponding to the request in the gateway cluster, and k is a preset constant greater than or equal to 1; when P is greater than k×Q, determining that the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules; when P is not greater than k×Q, determining that the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of gateway modules.

[0063] In some of the embodiments, the current limiting information includes: a preset current limiting value of a requesting party within a preset current limiting calculation period, and / or a preset current limiting value of a receiving party of the request within a preset current limiting calculation period.

[0064] In some of the embodiments, the gateway cluster 30 is also used to obtain a current limiting strategy and determine whether to limit the request based on the current limiting strategy, wherein the current limiting strategy includes one of the following: limiting the request of all requesters, limiting the request of a preset requester, and limiting the request of other requesters except the preset requester.

[0065] In some of the embodiments, the gateway cluster 30 divides the preset current limiting value to the gateway modules according to the number of the gateway modules, including: dividing the preset current limiting value to the gateway modules evenly or unevenly.

[0066] In some of the embodiments, the gateway cluster 30 limits the flow of requests based on the count of requests by the centralized component, including: sending the request information received by the gateway module to the centralized component, obtaining the count of requests by the centralized component, comparing the count of requests by the centralized component with the size of the preset flow limiting value, and the gateway module limits the flow of requests based on the comparison result.

[0067] In some of the embodiments, after the gateway cluster 30 divides the preset current limiting value to the gateway modules according to the number of gateway modules and limits the requests based on the count of the requests by the gateway modules, it is also used to: determine whether the count of requests by the gateway modules within a preset current limiting calculation period reaches a first preset threshold, wherein the first preset threshold is determined based on a preset percentage of the current limiting value obtained by the division of the gateway modules; when the count of requests by the gateway modules within the preset current limiting calculation period reaches the first preset threshold, reconfigure the current limiting value of the gateway modules, and limit the requests based on the count of requests by the centralized component.

[0068] In some of the embodiments, when the count of requests by the gateway module reaches a first preset threshold, the gateway cluster 30 reconfigures the current limit value of the gateway module, including: configuring the current limit value of the gateway module to a preset current limit value.

[0069] In some of the embodiments, when the gateway module's request count reaches a first preset threshold, the gateway cluster 30 reconfigures the current limiting value of the gateway module, including: when there are multiple gateway modules in the gateway cluster and their request counts reach a first preset threshold within a preset current limiting calculation period, the current limiting value of the gateway module is configured as the sum of the current limiting values ​​divided by the multiple gateway modules.

[0070] In some of the embodiments, when the count of requests by the gateway module reaches a first preset threshold, the gateway cluster 30 reconfigures the current limiting value of the gateway module, including: when the count of requests by multiple gateway modules in the gateway cluster reaches the first preset threshold, configuring the current limiting value of the gateway module to be a value between the sum of the current limiting values ​​divided by the multiple gateway modules and the preset current limiting value.

[0071] In some of the embodiments, the preset percentage corresponding to the first preset threshold value ranges from 80% to 90%.

[0072] In some of the embodiments, after reconfiguring the current limiting value of the gateway module and limiting the requests based on the count of requests by the centralized component, the gateway cluster 30 is also used to: determine whether the count of requests by the centralized component within a preset current limiting calculation period is lower than a second preset threshold, wherein the second preset threshold is determined based on a preset percentage of the current limiting value reconfigured by the gateway module, and the second preset threshold is less than the first preset threshold; when the count of requests by the centralized component within the preset current limiting calculation period is lower than the second preset threshold, restore the current limiting value divided by the gateway module when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules, and limit the requests based on the count of requests by the gateway module.

[0073] In some of the embodiments, the preset percentage corresponding to the second preset threshold value ranges from 40% to 70%.

[0074] An embodiment of the present invention further provides an electronic device, comprising: at least one processor; and a memory in communication with the at least one processor. The memory stores a computer program executable by the at least one processor, and when the computer program is executed by the at least one processor, the electronic device executes the method of the embodiment of the present invention.

[0075] An embodiment of the present invention further provides a non-transitory machine-readable medium storing a computer program, wherein the computer program, when executed by a processor of a computer, is used to cause the computer to execute the method of the embodiment of the present invention.

[0076] An embodiment of the present invention further provides a computer program product, including a computer program, wherein the computer program, when executed by a processor of a computer, is used to enable the computer to execute the method of the embodiment of the present invention.

[0077] refer to Figure 4 , a block diagram of an electronic device that can be used as a server or client of an embodiment of the present invention will now be described, which is an example of a hardware device that can be applied to various aspects of the present invention. Electronic devices are intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0078] like Figure 4 As shown, the electronic device includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 to a random access memory (RAM) 403. In RAM 403, various programs and data required for the operation of the electronic device can also be stored. The computing unit 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0079] Multiple components in the electronic device are connected to the I / O interface 405, including: an input unit 406, an output unit 407, a storage unit 408, and a communication unit 409. The input unit 406 can be any type of device that can input information to the electronic device, and the input unit 406 can receive input digital or character information, and generate key signal input related to user settings and / or function control of the electronic device. The output unit 407 can be any type of device that can present information, and can include but is not limited to a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 408 can include but is not limited to a disk, an optical disk. The communication unit 409 allows the electronic device to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and can include but is not limited to a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0080] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a CPU, a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above. For example, in some embodiments, the method embodiments of the present invention may be implemented as a computer program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on an electronic device via ROM 402 and / or communication unit 409. In some embodiments, the computing unit 401 may be configured to perform the above-described method in any other appropriate manner (e.g., by means of firmware).

[0081] The computer programs for implementing the methods of the embodiments of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer programs are executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer programs may be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.

[0082] In the context of an embodiment of the present invention, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable signal medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0083] It should be noted that the term "including" and its variations used in the embodiments of the present invention are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". The modifications of "one" and "multiple" mentioned in the embodiments of the present invention are illustrative rather than restrictive. Those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".

[0084] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0085] The various steps described in the method implementation methods provided in the embodiments of the present invention may be performed in different orders and / or in parallel. In addition, the method implementation methods may include additional steps and / or omit the steps shown. The scope of protection of the present invention is not limited in this respect.

[0086] The term "embodiment" in this specification refers to specific features, structures or characteristics described in conjunction with the embodiment that can be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily mean the same embodiment, nor does it mean that it is mutually exclusive with other embodiments and is independent or optional. The various embodiments in this specification are described in a related manner, and the same or similar parts between the various embodiments refer to each other. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment.

[0087] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be subject to the attached claims.

Claims

1. A request current limiting method, comprising: Acquire current limiting information corresponding to the request, wherein the current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; When there are multiple gateway modules corresponding to the request in the gateway cluster, determining the order of magnitude relationship between the preset current limiting value and the number of the gateway modules; In a case where the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of the gateway modules, the preset current limiting value is divided among the gateway modules according to the number of the gateway modules, and the request is current limited based on the count of the request by the gateway module; When the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules, the preset current limiting value is configured for the gateway module, and the request is current limited based on the count of the request by the centralized component.

2. The method according to claim 1, wherein: Determining the order of magnitude relationship between the preset current limiting value and the number of the gateway modules includes: Determine whether the preset current limit value P is greater than k×Q, where Q is the number of gateway modules corresponding to the request in the gateway cluster, and k is a preset constant greater than or equal to 1; In the case where P is greater than k×Q, determining that the order of magnitude of the preset current limit value is greater than the order of magnitude of the number of the gateway modules; When P is not greater than k×Q, it is determined that the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules.

3. The method according to claim 1, wherein: The current limiting information includes: a preset current limiting value of the requesting party of the request within a preset current limiting calculation period, and / or a preset current limiting value of the receiving party of the request within a preset current limiting calculation period.

4. The method according to claim 1, wherein: The method further comprises: Obtain a current limiting strategy, and determine whether to limit the request according to the current limiting strategy, wherein the current limiting strategy includes one of the following: limiting the request of all requesters, limiting the request of a preset requester, and limiting the request of other requesters except the preset requester.

5. The method according to claim 1, wherein: Allocating the preset current limiting value to the gateway modules according to the number of the gateway modules comprises: The preset current limiting value is evenly or unevenly distributed to the gateway modules.

6. The method according to claim 1, wherein: Based on the count of the requests by the centralized component, limiting the flow of the requests includes: The information of the request received by the gateway module is sent to the centralized component, the count of the request by the centralized component is obtained, the count of the request by the centralized component is compared with the size of the preset current limiting value, and the gateway module limits the current of the request based on the comparison result.

7. The method according to claim 1, wherein: After allocating the preset current limiting value to the gateway modules according to the number of the gateway modules, and limiting the current of the request based on the count of the request by the gateway module, the method further includes: Determine whether the count of the request by the gateway module within the preset current limiting calculation period reaches a first preset threshold, wherein the first preset threshold is determined based on a preset percentage of the current limiting value obtained by the division of the gateway module; When the count of the requests by the gateway module within the preset current limiting calculation period reaches the first preset threshold, the current limiting value of the gateway module is reconfigured, and the request is current limited based on the count of the requests by the centralized component.

8. The method according to claim 7, wherein: When the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limiting value of the gateway module includes: The current limiting value of the gateway module is configured as the preset current limiting value.

9. The method according to claim 7, wherein: When the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limiting value of the gateway module includes: When there are multiple gateway modules in the gateway cluster whose counts of the requests within the preset current limiting calculation period reach the first preset threshold, the current limiting value of the gateway module is configured as the sum of the current limiting values ​​divided by the multiple gateway modules.

10. The method according to claim 7, wherein: When the count of the requests by the gateway module reaches the first preset threshold, reconfiguring the current limiting value of the gateway module includes: When there are multiple gateway modules in the gateway cluster whose counts of the requests reach the first preset threshold, the current limiting value of the gateway module is configured to be a value between the sum of the current limiting values ​​divided by the multiple gateway modules and the preset current limiting value.

11. The method according to claim 7, wherein: The preset percentage corresponding to the first preset threshold value ranges from 80% to 90%.

12. The method according to claim 7, wherein: After reconfiguring the current limiting value of the gateway module and limiting the current of the request based on the count of the request by the centralized component, the method further includes: Determine whether the count of the request by the centralized component within the preset current limiting calculation period is lower than a second preset threshold, wherein the second preset threshold is determined based on a preset percentage of the current limiting value reconfigured by the gateway module, and the second preset threshold is less than the first preset threshold; When the count of the request by the centralized component within the preset current limiting calculation period is lower than the second preset threshold, the current limiting value obtained by dividing the gateway module when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of gateway modules is restored, and the request is current limited based on the count of the request by the gateway module.

13. The method according to claim 12, wherein: The preset percentage corresponding to the second preset threshold value ranges from 40% to 70%.

14. A gateway system, comprising a gateway cluster and a centralized component, wherein the gateway cluster comprises a plurality of gateway modules; The gateway cluster is used to obtain current limiting information corresponding to the request, wherein: The current limiting information includes a preset current limiting value corresponding to a preset current limiting calculation period; when there are multiple gateway modules corresponding to the request in the gateway cluster, determining the order of magnitude relationship between the preset current limiting value and the number of the gateway modules; when the order of magnitude of the preset current limiting value is greater than the order of magnitude of the number of the gateway modules, dividing the preset current limiting value to the gateway modules according to the number of the gateway modules, and limiting the request based on the count of the request by the gateway module; The centralized component is used to: count the requests when the order of magnitude of the current limit value is not greater than the order of magnitude of the number of the gateway modules; The gateway cluster is also used to: when the order of magnitude of the current limiting value is not greater than the order of magnitude of the number of the gateway modules, configure the preset current limiting value to the gateway module, and limit the request based on the count of the request by the centralized component.

15. An electronic device, comprising: A processor, and a memory storing a program, wherein the program comprises instructions which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 13.

16. A non-transitory machine-readable medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 13.