Distributed cluster current limiting method and device, electronic equipment and medium

By dynamically adjusting the configuration of the token bucket current limiter in a distributed cluster and adjusting it according to the deviation value of the token number and the generation rate, the problem of load imbalance in the distributed cluster is solved, and the total flow control and load balancing distribution of access workloads are realized.

CN119629127AActive Publication Date: 2025-03-14NEW H3C BIG DATA TECH CO LTD
View PDF 14 Cites 0 Cited by

Patent Information

Application Number
CN202411746647.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-03-14
Estimated Expiration
2044-11-29

AI Technical Summary

Technical Problem

In a distributed cluster, how to dynamically adjust the configuration of the token bucket current limiter to effectively control the total traffic of access workloads and ensure load balancing distribution.

Method used

By obtaining the set of token counts and the generated rate set, the quantity deviation value and the rate deviation value are calculated, and the token generation rate of the token bucket limiter is adjusted according to these deviation values ​​to achieve load balancing.

Benefits of technology

It realizes effective control of the total traffic of accessing workloads in a distributed cluster, ensuring the load balancing distribution of the entire cluster, and avoiding single point of overload.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629127A_ABST
    Figure CN119629127A_ABST
Patent Text Reader

Abstract

The invention provides a distributed cluster current limiting method and device, electronic equipment and a medium. The method comprises the following steps: acquiring a token number set and a generation rate set; if each token number in the token number set is greater than or equal to 0, calculating a number deviation value according to the token number set; under the condition that the number deviation value is smaller than a first threshold value, the token generation rate corresponding to the token bucket current limiter with the token number larger than the first threshold value is reduced, and the token generation rate corresponding to the token bucket current limiter with the token number smaller than the first threshold value is increased; if each token number in the token number set is less than 0, calculating a rate deviation value according to the generation rate set; and under the condition that the rate deviation value is smaller than a second threshold value, reducing the token generation rate corresponding to the token bucket current limiter of which the token number is larger than the second threshold value, and increasing the token generation rate corresponding to the token bucket current limiter of which the token number is smaller than the second threshold value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present specification relates to the field of cloud computing technology, and in particular to a current limiting method, device, electronic device, and medium for a distributed cluster. Background Art

[0002] In distributed application scenarios, the diversity and complexity of services carried by hosts have increased significantly, and it is particularly important to ensure the quality of key business services and the ability of the system to provide stable services. In order to solve the resource usage problem of mixed services on the host, avoid the competition for resources by specific services, and ensure the performance of a single or certain services, it is necessary to dynamically control the flow of specific services to meet the specific performance goals of certain applications. How to limit the flow of distributed clusters is an urgent problem to be solved. Summary of the invention

[0003] In order to overcome the problems existing in the related art, this specification provides a current limiting method, device, electronic device and medium for a distributed cluster.

[0004] According to a first aspect of an embodiment of the present specification, a current limiting method for a distributed cluster is provided, wherein the distributed cluster includes multiple token bucket limiters, and the method includes: obtaining a token number set and a generation rate set, wherein the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters; if each token number in the token number set is greater than or equal to 0, then calculating a number deviation value based on the token number set; when the number deviation value is less than a first threshold, reducing the token generation rate corresponding to the token bucket limiter whose token number is greater than the first threshold, and increasing the token generation rate corresponding to the token bucket limiter whose token number is less than the first threshold; if each token number in the token number set is less than 0, then calculating a rate deviation value based on the generation rate set; when the rate deviation value is less than a second threshold, reducing the token generation rate corresponding to the token bucket limiter whose token number is greater than the second threshold, and increasing the token generation rate corresponding to the token bucket limiter whose token number is less than the second threshold.

[0005] According to a second aspect of an embodiment of the present specification, a current limiting device for a distributed cluster is provided, comprising: an acquisition module, used to acquire a token number set and a generation rate set, wherein the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters; a quantity deviation value calculation module, used to calculate the quantity deviation value according to the token number set if each token number in the token number set is greater than or equal to 0; a first adjustment module, used to reduce the token generation rate corresponding to the token bucket limiter whose token number is greater than the first threshold value when the quantity deviation value is less than a first threshold value, and increase the token generation rate corresponding to the token bucket limiter whose token number is less than the first threshold value; a rate deviation value calculation module, used to calculate the rate deviation value according to the generation rate set if each token number in the token number set is less than 0; a second adjustment module, used to reduce the token generation rate corresponding to the token bucket limiter whose token number is greater than the second threshold value when the rate deviation value is less than a second threshold value, and increase the token generation rate corresponding to the token bucket limiter whose token number is less than the second threshold value.

[0006] According to a third aspect of the embodiments of this specification, there is provided an electronic device, including:

[0007] processor;

[0008] a memory for storing processor-executable instructions;

[0009] The processor is configured to execute the current limiting method of a distributed cluster according to the first aspect or any corresponding embodiment thereof.

[0010] According to a fourth aspect of an embodiment of this specification, a current limiting device for a distributed cluster is provided, including: a computer program product, including computer instructions, the computer instructions are used to enable a computer to execute the current limiting method for a distributed cluster of the first aspect or any corresponding implementation manner thereof.

[0011] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0012] In the embodiments of this specification, the current limiting configuration of each token bucket current limiter can be dynamically adjusted according to the load condition of the token bucket current limiter, so as to effectively control the total flow of access workload in the distributed cluster and achieve a balanced load distribution of the entire distributed cluster.

[0013] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0015] Figure 1A It is a schematic diagram of a system architecture shown in this specification according to an exemplary embodiment.

[0016] Figure 1B The diagram is a schematic diagram of current limiting for a distributed cluster according to an exemplary embodiment.

[0017] Figure 2 This is a flow chart of a distributed cluster current limiting method shown in this specification according to an exemplary embodiment.

[0018] Figure 3 The figure is a flow chart showing another current limiting method of a distributed cluster according to an exemplary embodiment.

[0019] Figure 4 It is a hardware structure diagram of the computer device where the current limiting device of the distributed cluster of the embodiment of this specification is located.

[0020] Figure 5 It is a block diagram of a current limiting device of a distributed cluster according to an exemplary embodiment of this specification. DETAILED DESCRIPTION

[0021] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0022] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0023] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0024] Next, the embodiments of this specification are described in detail.

[0025] The following combination Figure 1A The system architecture of the distributed cluster to which the current limiting method and device of the distributed cluster can be applied in the embodiments of this specification is described. It should be noted that FIG1 is only an example of the system architecture to which the embodiments of this specification can be applied, to help those skilled in the art understand the technical content of this specification, but it does not mean that the embodiments of this specification cannot be used in other devices, systems, environments or scenarios.

[0026] Figure 1A It is a schematic diagram of a system architecture shown in this specification according to an exemplary embodiment.

[0027] like Figure 1A As shown, the system architecture may include, for example, a server, an agent, and a load balancer. The server may be located at a control node. The server may be used to set the total current limit of the distributed cluster, dynamically adjust the agent token bucket configuration (such as QoS configuration) according to the current load of the agent, and achieve balanced load distribution. The agent may be located at a working node. The agent may be used to set the local token bucket current limiter of the working node according to the server configuration, and monitor and report the current load and token bucket related data.

[0028] The server can sense when a working node goes offline or a new working node comes online, and readjust the current limiting configuration of each workload to achieve balanced load distribution.

[0029] After receiving the token bucket configuration, the load balancer can be used to adjust the routing distribution weight of the load balancer to each Agent according to the token generation rate of each token bucket, distribute the request to each Agent according to the weight, and achieve load balancing that matches the backend processing capability.

[0030] Optionally, the Server may also include a Limit Dispatcher module responsible for calculating the configuration of each Agent token bucket based on an algorithm with the goal of optimal load distribution.

[0031] Optionally, the Agent can also include: Limit Controller and Limiter. Limit Controller is responsible for receiving the token bucket configuration distributed by the Server and updating the token bucket limiter's limiter settings. Limiter is also the local token bucket limiter, responsible for the limiter logic and synchronizing the current token bucket information to the cluster.

[0032] Optionally, the load balancer can be an independent third-party load balancer or a built-in load balancer in the Gateway. The Gateway can include a function for distributing service requests to the Agent. In this embodiment, when limiting the flow of the distributed cluster, the Gateway load balancer can be synchronously adjusted to optimize the request routing at the request end, which can improve system performance.

[0033] Optionally, Server, Agent, and Gateway can all contain a GossipSvc (popular protocol service) for information communication between cluster nodes using the Gossip protocol.

[0034] Figure 1B FIG. 1 is a schematic diagram showing current limiting for a distributed cluster according to an exemplary embodiment. Figure 1B As shown in the figure, the process of current limiting for a distributed cluster may include the following steps:

[0035] 1) The user or service sets the total current limit of the cluster;

[0036] 2) The server calculates the configuration of each agent's token bucket according to the algorithm, which may include, for example, the token generation rate;

[0037] 3)3.1: Gateway receives the configuration message and adjusts the load balancing weight of Load Balancer according to the token bucket current limiting configuration. The higher the token generation rate, the higher the weight, and correspondingly, the more requests are distributed;

[0038] 3.2: The Agent receives the configuration information and updates the current limit setting of the token bucket current limiter;

[0039] 4) The request initiator initiates a service request;

[0040] 5) Distribute business requests through the Gateway's Load Balancer;

[0041] 6) If the current limit is not triggered, the backend business load is accessed. If the current limit is triggered, an error response is given to inform that the request has been current limited;

[0042] 7) Update the token bucket information data, mainly including the current number of tokens, the current token generation rate, etc.;

[0043] 8) Synchronize the token bucket information data of the current Agent token bucket limiter to the cluster;

[0044] After receiving the token bucket information data synchronized by the Agent, the Server will execute step 2, that is, steps 2, 3, 6, and 7 will be executed in a loop, and the token bucket configuration will be automatically adjusted according to the algorithm to continuously optimize the load distribution.

[0045] The current limiting method of the distributed cluster provided in the embodiment of this specification is described in detail below. Figure 2 As shown, Figure 2 This is a flowchart of a distributed cluster current limiting method shown in this specification according to an exemplary embodiment. The method is applied to a distributed cluster. The distributed cluster current limiting method provided in the embodiment of this specification may include the following steps.

[0046] In step 210, a token number set and a generation rate set are obtained.

[0047] According to an embodiment of the present specification, the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters.

[0048] In step 220, if each token number in the token number set is greater than or equal to 0, then steps 230 to 240 are executed. If each token number in the token number set is less than 0, then steps 250 to 260 are executed.

[0049] In step 230, a quantity deviation value is calculated based on the token number set.

[0050] According to an embodiment of the present specification, for example, each positive value in the token number set may be summed to obtain a total positive deviation. Also, the absolute value of each negative value in the token number set may be summed to obtain a total negative deviation. Then, the sum of the positive deviation and the negative deviation may be calculated to obtain a quantity deviation value.

[0051] In step 240, when the quantity deviation value is less than the first threshold, the token generation rate corresponding to the token bucket limiter whose token number is greater than the first threshold is reduced, and the token generation rate corresponding to the token bucket limiter whose token number is less than the first threshold is increased.

[0052] According to the embodiments of this specification, the first threshold may be set according to actual needs.

[0053] According to an embodiment of the present specification, for example, a sum operation may be performed on the generation rates in the generation rate set to obtain an initial total rate.

[0054] Next, the ratio of the total amount of negative deviations to the total amount of positive deviations can be calculated to obtain a first ratio. The product of the first ratio, the initial total rate, and the first preset adjustment ratio is calculated to obtain a positive adjustment amount. In addition, the ratio of the total amount of positive deviations to the total amount of negative deviations can be calculated to obtain a second ratio. The product of the second ratio, the initial total rate, and the first preset adjustment ratio is calculated to obtain a negative adjustment amount. Among them, the first preset adjustment ratio is greater than 0 and less than or equal to 1, and the specific value can be set according to actual needs.

[0055] Then, for each token bucket current limiter, if the number of tokens of the token bucket current limiter is greater than the first threshold, the token generation rate of the token bucket current limiter can be adjusted according to the positive adjustment amount. If the number of tokens of the token bucket current limiter is less than the first threshold, the token generation rate of the token bucket current limiter can be adjusted according to the negative adjustment amount.

[0056] In step 250, a rate deviation value is calculated based on the generated rate set.

[0057] According to the embodiments of the present specification, for example, the average value of the token generation rate in the generation rate set can be calculated to obtain the average rate. Then, the absolute value of the difference between each token generation rate in the generation rate set and the average rate is calculated to obtain the individual deviation value of each token generation rate, and the maximum value among the individual deviation values ​​is determined as the rate deviation value.

[0058] In step 260, when the rate deviation value is less than the second threshold, the token generation rate corresponding to the token bucket limiter with a token number greater than the second threshold is reduced, and the token generation rate corresponding to the token bucket limiter with a token number less than the second threshold is increased.

[0059] According to the embodiments of this specification, the second threshold value may be set according to actual needs, and the second threshold value may be the same as or different from the first threshold value.

[0060] According to an embodiment of the present specification, for example, for each token bucket limiter, if the rate deviation value corresponding to the token bucket limiter is less than the second threshold, the product between the token generation rate of the token bucket limiter and the second preset adjustment ratio is calculated to obtain the maximum adjustment value. If the token generation rate of the token bucket limiter is greater than the average rate, the token generation rate of the token bucket limiter is subtracted from the maximum adjustment value to obtain a preliminary adjustment rate. Among them, the second preset adjustment ratio is greater than 0 and less than or equal to 1, and the specific value can be set according to actual needs. The second preset adjustment ratio can be the same as or different from the first preset adjustment ratio.

[0061] Next, the sum of all the preliminary adjustment rates can be calculated to obtain the preliminary adjustment total rate. The ratio between the sum of the token generation rates in the generation rate set and the preliminary adjustment total rate is calculated to obtain the adjustment factor.

[0062] Then, the token generation rates of the multiple token bucket limiters can be adjusted according to the adjustment factor.

[0063] According to the distributed cluster current limiting method of the embodiment of this specification, the current limiting configuration of each token bucket current limiter can be dynamically adjusted according to the load condition of the token bucket current limiter, so as to effectively control the total flow of access workload in the distributed cluster and achieve balanced load distribution of the entire distributed cluster.

[0064] Optionally, when the node information of the cluster is refreshed, such as expanding or shrinking the capacity, that is, removing the workload or adding a new workload, the distributed cluster flow limiting method shown in the embodiment of this specification can be automatically triggered to dynamically adjust the flow limit of the distributed cluster to achieve balanced load distribution of the entire distributed cluster.

[0065] Optionally, a counter may be set to record the number of consecutive adjustments to the token generation rate. Each time the token generation rate is adjusted (i.e., step 240 or step 260 is executed once), the counter is incremented by 1. When the counter reaches a threshold number of times, the adjustment of the distributed cluster token generation rate may be suspended. Each time the remaining tokens of all token bucket limiters are not 0, the counter is reset to zero, i.e., the number of consecutive adjustments is reset. If the adjustment of the distributed cluster token generation rate was previously suspended, the adjustment of the distributed cluster token generation rate is resumed after the counter is reset to zero.

[0066] Optionally, when synchronizing data to the load balancer, the weight of the load balancer can be adjusted according to the processing capacity of the workload. The higher the token generation rate, the higher the weight, thereby achieving load balancing that matches the backend processing capacity.

[0067] Optionally, when making current limiting adjustments, it can support adjustments based on a specified adjustment ratio to achieve gradual and smooth adjustment of current limiting, avoid sudden increases or decreases in load flow, and prevent backend workloads from becoming abnormal due to sudden increases in requests.

[0068] Optionally, the working node can be current limited by the local token bucket current limiter of the working node. Therefore, even if a front local token bucket current limiter is disconnected from the current limiting control plane (such as Server), normal service can continue and the current can be correctly limited according to the current configuration.

[0069] The current limiting method of a distributed cluster is described below in conjunction with another embodiment.

[0070] In this embodiment, when the tokens are not exhausted, the algorithm 1 can be applied to adjust the generation rate of the token bucket current limiter. When the tokens are exhausted, the algorithm 2 can be applied to adjust the generation rate of the token bucket current limiter.

[0071] Exemplarily, in this embodiment, the input of Algorithm 1 may include:

[0072] N, represents the number of token bucket limiters;

[0073] R represents the generation rate set: [r1, r2, ..., rN], where r1, r2, ..., rN are the current token generation rates of each token bucket limiter;

[0074] T represents the set of token numbers: [t1, t2, ..., tN], where t1, t2, ..., tN are the current remaining tokens of each token bucket limiter;

[0075] δ, represents the deviation ratio threshold, i.e., the first threshold;

[0076] α represents the adjustment ratio, that is, the first preset adjustment ratio.

[0077] The output of Algorithm 1 may include:

[0078] R' is the adjusted generation rate array: [r1', r2', ..., rN'].

[0079] Based on this, applying Algorithm 1 to adjust the generation rate of the token bucket current limiter may include the following steps:

[0080] 1. Calculate the initial total rate according to the following formula:

[0081] totalRate=sum(R)

[0082] Among them, totalRate is the initial total rate, R is the generated rate set, and sum() is the summation operation.

[0083] 2. Calculate the total positive deviation and total negative deviation according to the following formula:

[0084] totalPositive=sum of positive values ​​in T

[0085] totalNegative=sum of absolute values ​​of negative values ​​in T

[0086] Among them, totalPositive is the total positive deviation, totalNegative is the total negative deviation, T is the set of token numbers, sum of positive values ​​in T means calculating the sum of all positive values ​​in T, and sum of absolute valuesof negative values ​​in T means calculating the sum of the absolute values ​​of all negative values ​​in T.

[0087] 3. Calculate the total deviation value according to the following formula:

[0088] totalDeviation=totalPositive+totalNegative

[0089] Where totalDeviation is the total deviation value. If totalDeviation == 0, return R, that is, when totalDeviation is 0, no adjustment is required.

[0090] 4. Calculate the adjustment amount according to the following formula:

[0091] positiveRateAdjustment=(totalNegative / totalDeviation)*totalRate*α

[0092] negativeRateAdjustment=(totalPositive / totalDeviation)*totalRate*α

[0093] Among them, positiveRateAdjustment is a positive adjustment amount, negativeRateAdjustment is a negative adjustment amount, and α is a first preset adjustment ratio.

[0094] 5. Initialize the adjusted generation rate set R'

[0095] R'=[r1,r2,...,rN];

[0096] 6. For each ri in R' (i is a positive integer from 1 to N), execute:

[0097] If ti>0:

[0098] r'i=ri-(positiveRateAdjustment*(ti / totalPositive))

[0099] Otherwise if ti<0:

[0100] r'i=ri+(negativeRateAdjustment*(|ti| / totalNegative))

[0101] After execution, we get R'=[r'1,r'2,...,r'N];

[0102] 7. Calculate the sum of R'

[0103] sumNewRates=sum(R')

[0104] 8. Normalized R'

[0105] For each r'i in R', do:

[0106] r'i*=(totalRate / sumNewRates)

[0107] Among them, *= indicates the operation of calculating the product first and then assigning the value.

[0108] 9. Return to R'.

[0109] Subsequently, the corresponding token bucket current limiter can be set according to the generation rate of each token recorded by R'.

[0110] Exemplarily, in this embodiment, the input of Algorithm 2 may include:

[0111] N, represents the number of token bucket limiters;

[0112] R, represents the current generation rate set: [r1, r2, ..., rN];

[0113] D, represents the maximum rate deviation, i.e., the second threshold;

[0114] α represents the adjustment ratio, that is, the second preset adjustment ratio.

[0115] The output of Algorithm 2 may include:

[0116] R' represents the adjusted generation rate set: [r1', r2', ..., rN'].

[0117] Based on this, applying Algorithm 2 to adjust the generation rate of the token bucket current limiter may include the following steps:

[0118] 1. Calculate the initial total rate totalRate according to the following formula

[0119] totalRate=sum(R)

[0120] 2. Calculate the average rate averageRate according to the following formula:

[0121] averageRate = totalRate / N;

[0122] 3. Initialize a new generation rate array R':

[0123] R'=[r1,r2,...,rN];

[0124] 4. Make preliminary adjustments to each generation rate:

[0125] For i from 1 to N:

[0126] If |R'[i]-averageRate|>D:

[0127] maxAdjustment=α*R'[i]

[0128] If R'[i]>averageRate:

[0129] R'[i]=R'[i]-maxAdjustment

[0130] otherwise:

[0131] R'[i]=R'[i]+maxAdjustment;

[0132] 5. Calculate the adjusted total rate totalRate' according to the following formula:

[0133] totalRate' = sum(R');

[0134] 6. Calculate the adjustment factor based on the following:

[0135] f = totalRate / totalRate';

[0136] 7. Apply adjustment factors to adjust the token generation rate:

[0137] For i from 1 to N:

[0138] R'[i] = R'[i]*f;

[0139] 8. Return to R'.

[0140] Subsequently, the corresponding token bucket current limiter can be set according to the generation rate of each token recorded by R'.

[0141] like Figure 3 FIG. 1 is a flow chart of another method for limiting the flow of a distributed cluster according to an exemplary embodiment. Based on the above-mentioned embodiment, this embodiment describes a process for limiting the flow of a distributed cluster, including the following steps:

[0142] Whenever the Agent node information in the cluster is updated, the Server will be triggered to recalculate the configuration of each Agent token bucket.

[0143] First, determine whether there is at least one Agent in the cluster with remaining tokens.

[0144] If there is at least one agent in the cluster with remaining tokens, that is, the tokens are not exhausted, then the current number of tokens of all agents is counted and the corresponding number deviation value is calculated. The calculation method of the number deviation value is as mentioned above and will not be repeated here. If the current number of tokens of all agents is greater than or equal to 0 and the deviation value is less than "value 1", the token generation rate of the agent whose remaining token number exceeds "value 1" is reduced, and the token generation rate of the agent whose remaining token number is less than "value 1" is increased. "Value 1" can be set according to actual needs, for example, it can be 5%. If there are no remaining tokens in the agents in the cluster, that is, the tokens are exhausted, it is determined whether the current adjustment has been made N times in a row (N is a positive integer and can be set according to actual needs). If the current adjustment has been made N times in a row, the current token generation rate of all agents is counted and the rate deviation value is calculated. If the rate deviation value is less than "value 2", the token generation rate of the agent whose token generation rate exceeds "value 2" is reduced, and the token generation rate of the agent whose token generation rate is less than "value 2" is increased. "Value 2" can be set according to actual needs, for example, it can be 5%. Corresponding to the embodiments of the aforementioned methods, this specification also provides embodiments of a current limiting device for a distributed cluster and a terminal to which it is applied.

[0145] The embodiments of the current limiting device of the distributed cluster of this specification can be applied to computer devices, such as servers or terminal devices. The device embodiments can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them. From the hardware level, if Figure 4 As shown, it is a hardware structure diagram of the computer device where the current limiting device of the distributed cluster of the embodiment of this specification is located, except Figure 4 In addition to the processor 410, memory 430, network interface 420, and non-volatile memory 440 shown, the server or electronic device where the device 431 is located in the embodiment may also include other hardware according to the actual function of the computer device, which will not be described in detail.

[0146] like Figure 5 As shown, Figure 5 This is a block diagram of a distributed cluster current limiting device according to an exemplary embodiment of the present specification, the device comprising:

[0147] An acquisition module 510, configured to acquire a token number set and a generation rate set, wherein the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters;

[0148] A quantity deviation value calculation module 520, configured to calculate a quantity deviation value according to the token number set if each token number in the token number set is greater than or equal to 0;

[0149] A first adjustment module 530 is used to reduce the token generation rate corresponding to the token bucket limiter whose number of tokens is greater than the first threshold value, and increase the token generation rate corresponding to the token bucket limiter whose number of tokens is less than the first threshold value when the number deviation value is less than the first threshold value;

[0150] A rate deviation value calculation module 540, configured to calculate a rate deviation value according to a generation rate set if each token number in the token number set is less than 0;

[0151] The second adjustment module 550 is used to reduce the token generation rate corresponding to the token bucket limiter with a token number greater than the second threshold when the rate deviation value is less than the second threshold, and increase the token generation rate corresponding to the token bucket limiter with a token number less than the second threshold.

[0152] Optionally, the quantity deviation value calculation module may include:

[0153] The total positive deviation calculation submodule is used to sum each positive value in the token number set to obtain the total positive deviation;

[0154] The negative deviation total amount calculation submodule is used to sum the absolute value of each negative value in the token number set to obtain the negative deviation total amount;

[0155] The first deviation value calculation module is used to calculate the sum of the positive deviation and the negative deviation to obtain the quantity deviation value.

[0156] Optionally, the first adjustment module may include:

[0157] The initial total rate calculation submodule is used to sum the generation rates in the generation rate set to obtain the initial total rate;

[0158] A first ratio calculation submodule, used to calculate the ratio of the total negative deviation to the total positive deviation to obtain a first ratio;

[0159] A positive adjustment amount calculation submodule, used for calculating the product of the first ratio, the initial total rate and the first preset adjustment ratio to obtain the positive adjustment amount;

[0160] A second ratio calculation submodule is used to calculate the ratio of the total positive deviation to the total negative deviation to obtain a second ratio;

[0161] A negative value adjustment amount calculation submodule, used for calculating the product of the second ratio, the initial total rate and the first preset adjustment ratio to obtain a negative value adjustment amount;

[0162] The first adjustment submodule is used to, for each token bucket limiter, reduce the token generation rate of the token bucket limiter according to a positive adjustment amount if the number of tokens of the token bucket limiter is greater than a first threshold; and increase the token generation rate of the token bucket limiter according to a negative adjustment amount if the number of tokens of the token bucket limiter is less than the first threshold.

[0163] Optionally, the rate deviation value calculation module may include:

[0164] The average rate calculation submodule is used to calculate the average value of the token generation rate in the generation rate set to obtain the average rate;

[0165] The second deviation value calculation submodule is used to calculate the absolute value of the difference between each token generation rate in the generation rate set and the average rate, obtain the individual deviation value of each token generation rate, and determine the maximum value among the individual deviation values ​​as the rate deviation value.

[0166] Optionally, the second adjustment module may include:

[0167] a maximum adjustment value calculation submodule, for each token bucket current limiter, if the rate deviation value corresponding to the token bucket current limiter is less than the second threshold, then calculating the product between the token generation rate of the token bucket current limiter and the second preset adjustment ratio to obtain the maximum adjustment value;

[0168] A preliminary adjustment rate calculation submodule, for obtaining a preliminary adjustment rate by subtracting a maximum adjustment value from the token generation rate of the token bucket limiter if the token generation rate of the token bucket limiter is greater than an average rate;

[0169] A preliminary adjustment rate calculation submodule, configured to add a maximum adjustment value to the token generation rate of the token bucket limiter to obtain a preliminary adjustment rate if the token generation rate of the token bucket limiter is less than or equal to the average rate;

[0170] The preliminary adjustment total rate calculation submodule is used to calculate the sum of the preliminary adjustment rates to obtain the preliminary adjustment total rate;

[0171] The adjustment factor calculation submodule is used to calculate the ratio between the sum of the token generation rates in the generation rate set and the preliminary adjusted total rate to obtain the adjustment factor;

[0172] The second adjustment submodule is used to adjust the token generation rates of the multiple token bucket limiters according to the adjustment factor.

[0173] According to the distributed cluster current limiting device of the embodiment of this specification, the current limiting configuration of each token bucket current limiter can be dynamically adjusted according to the load condition of the token bucket current limiter, so as to effectively control the total flow of access workload in the distributed cluster and achieve balanced load distribution of the entire distributed cluster.

[0174] Accordingly, the present specification also provides an electronic device, which includes a processor; a memory for storing instructions executable by the processor; wherein the processor is configured as: an acquisition module, used to acquire a token number set and a generation rate set, the token number set including the number of tokens remaining in each token bucket limiter in a plurality of token bucket limiters, and the generation rate set including the token generation rate of each token bucket limiter in a plurality of token bucket limiters; a quantity deviation value calculation module, used to calculate the quantity deviation value according to the token number set if each token number in the token number set is greater than or equal to 0; a first adjustment module, used to adjust the quantity When the deviation value is less than the first threshold, the token generation rate corresponding to the token bucket limiter with a token number greater than the first threshold is reduced, and the token generation rate corresponding to the token bucket limiter with a token number less than the first threshold is increased; a rate deviation value calculation module is used to calculate the rate deviation value according to the generation rate set if each token number in the token number set is less than 0; a second adjustment module is used to reduce the token generation rate corresponding to the token bucket limiter with a token number greater than the second threshold, and increase the token generation rate corresponding to the token bucket limiter with a token number less than the second threshold, when the rate deviation value is less than the second threshold.

[0175] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.

[0176] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0177] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0178] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0179] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0180] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A distributed cluster current limiting method, characterized in that: The distributed cluster includes a plurality of token bucket current limiters, and the method includes: Acquire a token number set and a generation rate set, wherein the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters; If each token number in the token number set is greater than or equal to 0, then calculating a quantity deviation value based on the token number set; When the quantity deviation value is less than the first threshold, the token generation rate corresponding to the token bucket current limiter whose number of tokens is greater than the first threshold is reduced, and the token generation rate corresponding to the token bucket current limiter whose number of tokens is less than the first threshold is increased; If each token number in the token number set is less than 0, calculating a rate deviation value according to the generation rate set; When the rate deviation value is less than the second threshold, the token generation rate corresponding to the token bucket limiter whose token number is greater than the second threshold is reduced, and the token generation rate corresponding to the token bucket limiter whose token number is less than the second threshold is increased.

2. The method according to claim 1, characterized in that The calculating the quantity deviation value according to the token number set includes: Performing a sum operation on each positive value in the token number set to obtain a total amount of positive deviations; Sum the absolute value of each negative value in the token number set to obtain a total negative deviation; The sum of the positive deviation and the negative deviation is calculated to obtain the quantity deviation value.

3. The method according to claim 2, characterized in that The method of reducing the token generation rate corresponding to the token bucket current limiter having a token number greater than a first threshold value, and increasing the token generation rate corresponding to the token bucket current limiter having a token number less than the first threshold value, comprises: Performing a sum operation on the generation rates in the generation rate set to obtain an initial total rate; Calculating the ratio of the total negative deviation to the total positive deviation to obtain a first ratio; Calculating the product of the first ratio, the initial total rate and a first preset adjustment ratio to obtain a positive adjustment amount; Calculating the ratio of the total positive deviation to the total negative deviation to obtain a second ratio; Calculating the product of the second ratio, the initial total rate and the first preset adjustment ratio to obtain a negative adjustment amount; For each token bucket limiter, if the number of tokens of the token bucket limiter is greater than the first threshold, the token generation rate of the token bucket limiter is reduced according to the positive adjustment amount; if the number of tokens of the token bucket limiter is less than the first threshold, the token generation rate of the token bucket limiter is increased according to the negative adjustment amount.

4. The method according to claim 1, characterized in that: The calculating the rate deviation value according to the generation rate set includes: Calculating an average value of token generation rates in the generation rate set to obtain an average rate; The absolute value of the difference between each token generation rate in the generation rate set and the average rate is calculated to obtain an individual deviation value of each token generation rate, and the maximum value of the individual deviation values ​​is determined as the rate deviation value.

5. The method according to claim 4, characterized in that The step of reducing the token generation rate corresponding to the token bucket current limiter having a token number greater than the second threshold, and increasing the token generation rate corresponding to the token bucket current limiter having a token number less than the second threshold, comprises: For each token bucket current limiter, if the rate deviation value corresponding to the token bucket current limiter is less than the second threshold, then calculate the product between the token generation rate of the token bucket current limiter and the second preset adjustment ratio to obtain a maximum adjustment value; If the token generation rate of the token bucket limiter is greater than the average rate, subtracting the maximum adjustment value from the token generation rate of the token bucket limiter to obtain a preliminary adjustment rate; If the token generation rate of the token bucket limiter is less than or equal to the average rate, adding the maximum adjustment value to the token generation rate of the token bucket limiter to obtain a preliminary adjustment rate; Calculating the sum of the preliminary adjustment rates to obtain a preliminary adjustment total rate; Calculating the ratio between the sum of the token generation rates in the generation rate set and the preliminary adjusted total rate to obtain an adjustment factor; The token generation rates of the multiple token bucket limiters are adjusted according to the adjustment factor.

6. A current limiting device for a distributed cluster, characterized in that: The distributed cluster includes a plurality of token bucket current limiters, and the device includes: An acquisition module, configured to acquire a token number set and a generation rate set, wherein the token number set includes the number of tokens remaining in each of the multiple token bucket limiters, and the generation rate set includes the token generation rate of each of the multiple token bucket limiters; A quantity deviation value calculation module, configured to calculate a quantity deviation value according to the token number set if each token number in the token number set is greater than or equal to 0; A first adjustment module is used to reduce the token generation rate corresponding to the token bucket limiter whose number of tokens is greater than the first threshold value, and increase the token generation rate corresponding to the token bucket limiter whose number of tokens is less than the first threshold value when the number deviation value is less than the first threshold value; A rate deviation value calculation module, configured to calculate a rate deviation value according to the generation rate set if each token number in the token number set is less than 0; The second adjustment module is used to reduce the token generation rate corresponding to the token bucket limiter whose token number is greater than the second threshold when the rate deviation value is less than the second threshold, and increase the token generation rate corresponding to the token bucket limiter whose token number is less than the second threshold.

7. The device according to claim 6, characterized in that The quantity deviation value calculation module includes: A positive deviation total amount calculation submodule is used to perform a sum operation on each positive value in the token number set to obtain a positive deviation total amount; A negative deviation total amount calculation submodule is used to sum the absolute value of each negative value in the token number set to obtain the negative deviation total amount; The first deviation value calculation module is used to calculate the sum of the positive deviation and the negative deviation to obtain the quantity deviation value.

8. The device according to claim 7, characterized in that The first adjustment module includes: An initial total rate calculation submodule, used for performing a sum operation on the generation rates in the generation rate set to obtain an initial total rate; A first ratio calculation submodule, used for calculating the ratio of the total negative deviation to the total positive deviation to obtain a first ratio; A positive adjustment amount calculation submodule, used for calculating the product of the first ratio, the initial total rate and a first preset adjustment ratio to obtain a positive adjustment amount; A second ratio calculation submodule, used for calculating the ratio of the total positive deviation to the total negative deviation to obtain a second ratio; a negative value adjustment amount calculation submodule, configured to calculate the product of the second ratio, the initial total rate and a first preset adjustment ratio to obtain a negative value adjustment amount; The first adjustment submodule is used to, for each token bucket limiter, reduce the token generation rate of the token bucket limiter according to the positive adjustment amount if the number of tokens of the token bucket limiter is greater than the first threshold; and increase the token generation rate of the token bucket limiter according to the negative adjustment amount if the number of tokens of the token bucket limiter is less than the first threshold.

9. The device according to claim 6, characterized in that The rate deviation value calculation module includes: An average rate calculation submodule, used to calculate the average value of the token generation rate in the generation rate set to obtain an average rate; The second deviation value calculation submodule is used to calculate the absolute value of the difference between each token generation rate in the generation rate set and the average rate, obtain the individual deviation value of each token generation rate, and determine the maximum value of the individual deviation values ​​as the rate deviation value.

10. The device according to claim 9, characterized in that The second adjustment module includes: a maximum adjustment value calculation submodule, for each token bucket current limiter, if the rate deviation value corresponding to the token bucket current limiter is less than the second threshold, then calculating the product between the token generation rate of the token bucket current limiter and the second preset adjustment ratio to obtain the maximum adjustment value; A preliminary adjustment rate calculation submodule, configured to, if the token generation rate of the token bucket current limiter is greater than the average rate, subtract the maximum adjustment value from the token generation rate of the token bucket current limiter to obtain a preliminary adjustment rate; A preliminary adjustment rate calculation submodule, configured to add the token generation rate of the token bucket limiter to the maximum adjustment value to obtain a preliminary adjustment rate if the token generation rate of the token bucket limiter is less than or equal to the average rate; A preliminary adjusted total rate calculation submodule, used to calculate the sum of the preliminary adjusted rates to obtain a preliminary adjusted total rate; An adjustment factor calculation submodule, configured to calculate a ratio between the sum of the token generation rates in the generation rate set and the preliminary adjusted total rate to obtain an adjustment factor; The second adjustment submodule is used to adjust the token generation rates of the multiple token bucket limiters according to the adjustment factor.

11. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor is configured to execute the method according to any one of claims 1 to 5.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Data receiving flow control method and system

    CN104734985A

  • Flow limiting method and device based on weight mechanism, computer equipment and storage medium

    CN111083062A

  • Access request flow limiting method, server and storage medium

    CN111447150A

  • Network traffic limiting method and device, equipment and storage medium

    CN114143265A

  • Performance verification method and device of speed limiting module, electronic equipment and storage medium

    CN115328810A