CN110417672B - Current limiting method and device - Google Patents

Current limiting method and device Download PDF

Info

Publication number
CN110417672B
CN110417672B CN201910709145.1A CN201910709145A CN110417672B CN 110417672 B CN110417672 B CN 110417672B CN 201910709145 A CN201910709145 A CN 201910709145A CN 110417672 B CN110417672 B CN 110417672B
Authority
CN
China
Prior art keywords
abnormal
node
client
normal
current limiting
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910709145.1A
Other languages
Chinese (zh)
Other versions
CN110417672A (en
Inventor
居振飞
戴觊婧
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sankuai Online Technology Co Ltd
Original Assignee
Beijing Sankuai Online Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Sankuai Online Technology Co Ltd filed Critical Beijing Sankuai Online Technology Co Ltd
Priority to CN201910709145.1A priority Critical patent/CN110417672B/en
Publication of CN110417672A publication Critical patent/CN110417672A/en
Application granted granted Critical
Publication of CN110417672B publication Critical patent/CN110417672B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/29Flow control; Congestion control using a combination of thresholds
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/10Network architectures or network communication protocols for network security for controlling access to devices or network resources

Abstract

The embodiment of the disclosure provides a current limiting method and a device, wherein the method comprises the following steps: monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold value; if the access amount of one target abnormal node in the nodes is larger than the current limiting threshold of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node; distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and performing access control according to the updated current limiting binary tree. According to the method and the device, the current limiting threshold value of the corresponding node of the abnormal client can be respectively distributed to the abnormal client and the other normal clients when the clients are abnormal, so that the phenomenon that one client abnormally affects the access of the other normal clients is avoided, the labor cost is reduced, and the accuracy of the current limiting threshold value is improved.

Description

Current limiting method and device
Technical Field
The disclosed embodiments relate to the field of network technologies, and in particular, to a current limiting method and device.
Background
In the network service, a server provides service, and a client accesses the server to obtain corresponding service. When the number of clients is large, the pressure of the server is large, and the access of the clients to the server is controlled by limiting the current so as to relieve the pressure of the server.
In the prior art, two schemes for limiting the current of the client mainly include. The first scheme is mainly to set a total current limiting threshold value for the server, and when the access amount of the server reaches the current limiting threshold value of the current limiting threshold value, the client is denied to access the server. The second scheme is mainly that a current limiting threshold value is set for each client, and when the access amount of the client reaches the current limiting threshold value corresponding to the client, the client is denied access to the server.
The inventor researches the above scheme to find that, for the first scheme, if one of the clients causes the access amount to exceed the threshold, access of all the clients is denied, and access of other normal clients is affected; with the second scheme, the current limiting threshold of each client is difficult to determine, and the labor cost of the current limiting threshold is high when the number of clients is large, and in addition, the access amount that the server can bear cannot be accurately distributed to each client.
Disclosure of Invention
The embodiment of the disclosure provides a current limiting method and device, which can respectively allocate a current limiting threshold of a corresponding node of an abnormal client to the abnormal client and other normal clients when the clients are abnormal, thereby avoiding that one client is abnormal to influence the access of other normal clients, reducing the labor cost and improving the accuracy of the current limiting threshold.
According to a first aspect of embodiments of the present disclosure, there is provided a method of limiting current, the method comprising:
monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold value;
if the access amount of a target abnormal node in the nodes is larger than the current limiting threshold of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node;
distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and
and performing access control according to the updated current limiting binary tree.
According to a second aspect of embodiments of the present disclosure, there is provided a current limiting device, the device including:
the access amount monitoring module is used for monitoring the access amount of each node in a preset current limiting binary tree, and the node has a current limiting threshold value;
the client dividing module is used for determining an abnormal client and a normal client from the clients corresponding to the target abnormal nodes if the access amount of one target abnormal node in the nodes is greater than the current limiting threshold of the target abnormal node;
the current limiting threshold value distribution module is used for distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and
and the access control module is used for carrying out access control according to the updated current limiting binary tree.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor, a memory and a computer program stored on the memory and executable on the processor, the processor implementing the aforementioned current limiting method when executing the program.
According to a fourth aspect of embodiments of the present disclosure, there is provided a readable storage medium, characterized in that instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the aforementioned current limiting method.
The embodiment of the disclosure provides a current limiting method and a device, wherein the method comprises the following steps: monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold value; if the access amount of a target abnormal node in the nodes is larger than the current limiting threshold of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node; distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and performing access control according to the updated current limiting binary tree. The embodiment of the disclosure can distribute the current limiting threshold of the corresponding node of the abnormal client to the abnormal client and the other normal clients respectively when the clients are abnormal, thereby avoiding that one client is abnormal to influence the access of the other normal clients, reducing the labor cost and improving the accuracy of the current limiting threshold.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the description of the embodiments of the present disclosure will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present disclosure, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 illustrates a flow chart of method steps for limiting current in one embodiment of the present disclosure;
FIG. 2 shows a flow chart of method steps for limiting current in another embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a current-limiting binary tree in an initial state according to the present disclosure;
FIG. 4 is a schematic structural diagram of a current-limiting binary tree after one split according to the present disclosure;
FIG. 5 is a schematic structural diagram of a current-limiting binary tree after two splits according to the present disclosure;
FIG. 6 is a schematic structural diagram of a current-limiting binary tree after multiple splits according to the present disclosure;
FIG. 7 is a schematic structural diagram of a current-limiting binary tree after an abnormal child node of the present disclosure recovers to normal;
FIG. 8 illustrates a block diagram of a current limiting device in one embodiment of the present disclosure;
FIG. 9 shows a block diagram of a current limiting device in another embodiment of the present disclosure;
FIG. 10 shows a block diagram of an electronic device in an embodiment of the disclosure.
Detailed Description
Technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is apparent that the described embodiments are some, but not all, of the embodiments of the present disclosure. All other embodiments, which can be obtained by a person skilled in the art without making creative efforts based on the embodiments of the present disclosure, belong to the protection scope of the embodiments of the present disclosure.
Example one
Referring to fig. 1, a flow chart illustrating steps of a current limiting method in an embodiment of the present disclosure is shown, specifically as follows.
Step 101, monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold.
The embodiment of the disclosure is used for performing access control on the server, and ensuring that the server can normally operate without crash of the server due to overlarge access amount.
The current-limiting binary tree is constructed based on a full binary tree, and in an initial state, the current-limiting binary tree only includes one root node, as shown in fig. 3, child nodes may be set as empty nodes, and access requests of all clients are processed; when the access amount to the root node is larger than the current limiting threshold value corresponding to the root node, the root node is divided into a normal child node and an abnormal child node, the access amount of each node is monitored all the time, and the nodes are dynamically divided.
The access amount is the number of access requests that can be expressed in unit time.
The current limit threshold is used to control access requests to the node, for example, if the current limit threshold is 100, the number of access requests to access the node per unit time is at most 100. It is understood that the current limit threshold may be set according to an actual application scenario and a processing capability of each node, which is not limited by the embodiments of the present disclosure.
And step 102, if the visit quantity of a target abnormal node in the nodes is larger than the current limiting threshold value of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node.
It can be understood that each node in the current-limiting binary tree corresponds to one or more clients to access the node, wherein an access amount to the node is suddenly increased when each client is abnormal, and if the access amount of one target abnormal node is greater than or equal to the current-limiting threshold of the target abnormal node, an abnormal client and a normal client are determined; and if the access amount of one target abnormal node is increased and still smaller than the current limiting threshold of the target abnormal node, the target abnormal node is not split.
And 103, distributing the current limiting threshold of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client.
According to the embodiment of the disclosure, when the access amount of the target abnormal node is greater than the current limiting threshold of the target abnormal node, the target abnormal node is divided into two sub-nodes, wherein one sub-node is used for limiting the access request of the abnormal client, and the other sub-node is used for limiting the access request of the normal client. Therefore, when the target abnormal node is abnormal, the normal processing of the access request of the normal client is ensured as far as possible, and the abnormal client and the normal client cannot normally access.
It can be understood that step 103 splits the target abnormal node in the current-limiting binary tree into an abnormal child node and a normal child node, i.e., updates the current-limiting binary tree.
As can be seen from step 103, the depth of the current-limited binary tree is related to the number of the abnormal clients, and as the number of the abnormal clients is larger, the depth of the current-limited binary tree increases. For example, if there are five clients CT1, CT2, CT3, CT4, and CT5 accessing the server, in the initial state, as shown in fig. 3, the clients CT1, CT2, CT3, CT4, and CT5 all perform current limiting through the root node ND1, and if the access amount of the root node ND1 is greater than the current limiting threshold of the root node ND1 due to an abnormality of the client CT1, the node ND1 is split into an abnormal child node ND2 and a normal child node ND3 as shown in fig. 4, and at this time, the depth of the current limiting tree is 2. The abnormal child node ND2 limits the access requests of the normal clients CT2, CT3, CT4 and CT5, and the normal child node ND3 limits the access requests of the abnormal client CT 1.
If the client CT2 of the client CT1, CT2, CT3, CT4, and CT5 is abnormal again, as shown in fig. 5, the normal child node ND3 is further split into the abnormal child node ND4 and the normal child node ND5, and at this time, the depth of the current-limiting binary tree is 3. The abnormal child node ND4 limits the access requests of the abnormal clients CT1 and CT2, and the normal child node ND5 limits the current of the normal clients CT3, CT4 and CT 5.
By analogy, in an extreme case, when the clients CT1, CT2, CT3, CT4, and CT5 are all abnormal, the current-limiting binary tree is split into two parts as shown in fig. 6, the abnormal child node ND2 is used to limit the access request of the abnormal client CT1, the abnormal child node ND4 is used to limit the access request of the abnormal client CT2, the abnormal child node ND6 is used to limit the access request of the abnormal client CT3, the abnormal child node ND8 is used to limit the access request of the abnormal client CT4, the abnormal child node ND10 is used to limit the access request of the abnormal client CT5, and the normal child node ND11 is not used to limit any client. At this time, it is equivalent to the binary current-limited tree in the initial state shown in fig. 3 when all the client CTs 1, CT2, CT3, CT4, and CT5 are normal.
And step 104, performing access control according to the updated current limiting binary tree.
Specifically, the access request of the normal client can be limited through the normal child node, when the access amount of the normal child node is greater than the current limiting threshold of the normal child node, the normal child node is taken as a new target abnormal node, and is further split according to the step 103, and thus, the process is performed recursively; and when the access amount of the normal child node is smaller than the current limiting threshold value of the normal child node, processing the new access request.
In addition, the access request of the abnormal client is limited through the abnormal child node, and when the access amount of the abnormal child node is larger than or equal to the current limiting threshold of the abnormal child node, a new access request is rejected; and when the access quantity of the abnormal child node is smaller than the current limiting threshold value of the abnormal child node, processing a new access request.
In summary, an embodiment of the present disclosure provides a current limiting method, where the method includes: monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold value; if the access amount of a target abnormal node in the nodes is larger than the current limiting threshold of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node; distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and performing access control according to the updated current limiting binary tree. The embodiment of the disclosure can distribute the current limiting threshold of the corresponding node of the abnormal client to the abnormal client and the other normal clients respectively when the clients are abnormal, thereby avoiding that one client is abnormal to influence the access of the other normal clients, reducing the labor cost and improving the accuracy of the current limiting threshold.
Example two
Referring to fig. 2, a flow chart illustrating specific steps of a current limiting method in another embodiment of the present disclosure is shown, specifically as follows.
Step 201, monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold.
This step can refer to the detailed description of step 101, and is not described herein again.
Step 202, if the access amount of a target abnormal node in the nodes is greater than the current limiting threshold of the target abnormal node, counting the access amount of the client corresponding to the target abnormal node in a preset time period.
The preset time period may be a time period before the current time, for example, if the unit time is minutes, a ratio of the total number of access requests in the last two hours to 120 minutes is counted as the access amount.
It can be understood that the client corresponding to the target abnormal node performs current limitation on the client through the current limitation threshold of the target abnormal node, so that a plurality of clients corresponding to the target abnormal node may exist, and at this time, the access amount of the target abnormal node is the sum of the access amounts of all the clients corresponding to the target abnormal node.
And 203, taking the client side which is ranked in the front in the client side sequence as the abnormal client side, and taking the other client sides as the normal client sides, wherein the client side sequence is obtained by arranging the client sides corresponding to the target abnormal node in a descending order according to the access amount.
In the embodiment of the present disclosure, the client ranked at the top position may be obtained from the client sequence as an abnormal client, a plurality of clients ranked at the top may also be obtained from the client sequence as abnormal clients, and a client whose access amount exceeds the access amount threshold in the client sequence may also be used as an abnormal client.
The embodiment of the present disclosure does not impose any limitation on the selection policy of the abnormal client.
Step 204, calculating the ratio of the access quantity of the abnormal client to the access quantity of the target abnormal node.
Specifically, the ratio R can be calculated with reference to the following formula:
Figure BDA0002153121930000071
the method comprises the steps that I is the total number of clients of a target abnormal node, the first J clients in a client sequence are abnormal clients, the J +1 th client to the I th client are normal clients, and I > is J > 1.
Step 205, according to the ratio, dividing the current limiting threshold of the target abnormal node into a first current limiting threshold corresponding to the abnormal client and a second current limiting threshold corresponding to the normal client.
In particular, a first current limiting threshold CLT1Can be calculated by referring to the following formula:
Figure BDA0002153121930000072
second current limit threshold CLT2Can be calculated by referring to the following formula:
Figure BDA0002153121930000081
wherein, CLTtotalIs the current limit threshold of the target abnormal node.
Step 206, creating the abnormal child node corresponding to the abnormal client and the normal child node corresponding to the normal client, and initializing.
Specifically, the child node may be initialized to a null node and then various attributes of the child node may be set.
Step 207, respectively setting the first current limiting threshold as the current limiting threshold of the abnormal child node, and setting the second current limiting threshold as the current limiting threshold of the normal child node.
In the embodiment of the disclosure, each node is used for limiting the current of the access request of the corresponding client, so that the abnormal child node and the normal child node obtained by splitting need to set the current limiting threshold value at first.
Specifically, the first current limiting threshold may be used as a current limiting threshold attribute of the abnormal child node, and the second current limiting threshold may be used as a current limiting threshold of the normal child node.
And 208, setting the target abnormal node as the abnormal child node and the father node of the normal child node.
In an embodiment of the present disclosure, the attribute of each node further includes: parent nodes, thereby facilitating rapid location of the node's parent.
Because the binary tree has a parent-child relationship, after the target abnormal node is split, the target abnormal node is used as a parent node of the abnormal child node and the normal child node after the splitting.
Specifically, the identification of the target abnormal node may be used as the parent node attribute of the abnormal child node and the normal child node.
Step 209, setting the depths of the abnormal child node and the normal child node according to the depth of the target abnormal node.
In an embodiment of the present disclosure, the attribute of each node further includes a depth. Therefore, the method can help to quickly determine the depth of the client in the preset current limiting binary tree.
Specifically, the depth of the parent node may be increased by 1 to serve as the depth attribute of the abnormal child node and the normal child node.
Step 210, setting the client identifier of the client with the highest access amount as the client identifier of the abnormal child node, and setting the client identifier of the normal child node as null.
In the embodiment of the present disclosure, the attribute of each node further includes a client identifier, so that the access request of the client corresponding to the node is conveniently throttled according to the throttling threshold of the node.
Specifically, the client identifier may be used as the client attribute of the child node, for example, the client identifier of a normal client may be used as the client attribute of a normal child node, when the number of normal clients is large, the client identifier of the normal child node may be set to be null, and the client identifier of an abnormal client may be used as the client attribute of an abnormal client.
Step 211, setting the abnormal child node and the normal child node as child nodes of the target abnormal node.
In embodiments of the present disclosure, each node also includes child node attributes, which may facilitate rapid location of child nodes.
It is to be understood that the target exception node may be a root node or a normal child node.
Step 212, receiving an access request, where the access request carries a target client identifier.
In practical application, the access request can be initiated for the client installed on various terminals, and when the client is installed on the terminal, a client identifier is generated to uniquely distinguish the clients used by different users, so that the server can return data according to the client identifier.
Step 213, in response to the access request, obtaining a node corresponding to the target client identifier from the updated node of the current-limiting binary tree, to obtain a target control node.
Specifically, each node in the current-limiting binary tree may be traversed to determine whether the client attribute of each node includes the client identifier, and if the client attribute of one of the nodes includes the client identifier, the node is determined to be a node corresponding to the client identifier.
Optionally, in an embodiment of the present disclosure, step 213 comprises sub-steps a1 to a 2:
sub-step a1, if the client identifier corresponding to one of the abnormal sub-nodes in the updated current-limiting binary tree is the target client identifier, determining that the abnormal sub-node is the target control node.
In the embodiment of the disclosure, the client initiating the request may be an abnormal client or a normal client, so that the access request of the abnormal client is limited by the abnormal child node, and the access request of the normal client is limited by the normal child node.
Sub-step a2, if the updated current-limiting binary tree does not have the abnormal child node whose client identifier is the target client identifier, taking the normal child node in the current-limiting binary tree as the target control node.
In an embodiment of the present disclosure, the most common scenarios are: the data volume of the clients is large, wherein the data volume only comprises that a small number of clients are abnormal, a large number of normal clients remain, at this time, the client attribute of the abnormal child node can be set as the client identifier of the abnormal client, and for the normal child node, because the number of the normal clients is large, the client attribute of the normal child node can be set as a null or other specified identifiers, so that the storage space occupied by the normal child node is reduced, and further the storage space occupied by the current-limiting binary tree is reduced.
Of course, if the total amount of the clients is not large, the client attribute of the normal child node may be set as the client identifier of the normal client.
Step 214, if the target control node is successfully acquired, performing access control on the access request through the current limiting threshold of the target control node.
Specifically, if the current access amount of the node corresponding to the client identifier is greater than or equal to the current limit threshold of the node, the access request is rejected, or the response to the access request is delayed, and the access request is processed when the current access amount is less than the current limit threshold of the node; and if the current access quantity of the node corresponding to the client identification is smaller than the current limit threshold of the node, immediately processing the access request.
The embodiment of the disclosure can perform access control on the access request according to the abnormal child node and the normal child node after the splitting, and can ensure accurate control effect.
Step 215, monitoring whether the abnormal child node is normal or not in real time.
In the embodiment of the disclosure, the abnormal child node can be monitored in real time to determine whether the abnormal child node is normal or not.
Optionally, in another embodiment of the present disclosure, step 215 includes sub-steps B1-B2:
and a sub-step B1 of monitoring the visit quantity of the abnormal child node in real time.
It can be understood that the access volume of the abnormal child node is the access volume of the corresponding client.
Sub-step B2, if the access amount of the abnormal child node is continuously less than a preset access amount threshold value within a preset time period, determining that the abnormal child node is recovered to be normal.
The preset time period may be a time period with a preset duration before the current time, and may be set according to an actual application scenario, which is not limited in the embodiments of the present disclosure.
The embodiment of the disclosure can continuously detect whether the abnormal child node is recovered to be normal, if the condition that the access quantity of the abnormal child node is less than the access quantity threshold value lasts for only a very small period of time, it is not determined that the abnormal child node is recovered to be abnormal, and only if the condition that the access quantity of the abnormal child node is less than the access quantity threshold value lasts for only a very long period of time, for example, the time length of more than a preset time period, it is determined that the abnormal child node is recovered to be abnormal.
For example, the preset time period may be approximately ten minutes before the current time, and at this time, if the access amount of the abnormal child node is smaller than the preset access amount threshold value within approximately 2 minutes before the current time, it is not determined that the abnormal child node returns to normal; and if the access quantity of the abnormal child node is smaller than the preset access quantity threshold value within nearly 15 minutes before the current moment, determining that the abnormal child node is recovered to be normal.
The embodiment of the disclosure can accurately determine whether the abnormal child node is recovered to be normal according to the access amount of the abnormal child node.
Step 216, if it is monitored that the abnormal child node is recovered to be normal, setting the child node of the normal child node as the child node of the target abnormal node, and deleting the abnormal child node and the normal child node.
For example, for one split from the current limited binary tree shown in fig. 3 to the current limited binary tree shown in fig. 4, the target abnormal node is node ND1, and if the abnormal child node ND2 returns to normal, the abnormal child node ND2 and the normal child node ND3 in fig. 4 are merged into the node ND 1. Specifically, the normal child node has been split into ND4 and ND5 as shown in fig. 5 if ND2 returns to normal. First, the child nodes (the abnormal child node ND4 and the normal child node ND5) of the normal child node ND3 are taken as child nodes of the node ND1, and the abnormal child node ND2 and the normal child node ND3 are deleted, resulting in a current-limited binary tree after fusion as shown in fig. 7.
Step 217, modifying the current limiting threshold of the child node of the target abnormal node according to the current limiting threshold of the target abnormal node.
If the current-limited binary tree has been split into the current-limited binary tree shown in fig. 5 when the abnormal child node ND2 recovers to normal, i.e., the normal child node ND3 has been split into the abnormal child node ND4 and the normal child node ND5, the current-limited binary tree after merging as shown in fig. 7 is obtained.
Since the parent nodes of the abnormal child node ND4 and the normal child node ND5 become the node ND1 after the step 216, and the current limit threshold of the node ND1 is different from that of the original normal child node ND3, the current limit thresholds of the abnormal child node ND4 and the normal child node ND5 need to be reallocated. The specific allocation method may refer to steps 103, 204 to 205, which are not described herein again.
In addition, the depth of the abnormal child node ND4 and the normal child node in the current-limiting binary tree shown in fig. 7 needs to be reduced by 1.
The embodiment of the disclosure can monitor whether the abnormal child node is recovered to be normal or not, and merge the abnormal client corresponding to the abnormal child node into the normal child node after the abnormal child node is recovered to be normal, so that the accuracy of the current-limiting binary tree can be ensured.
In summary, the embodiments of the present disclosure provide another current limiting method based on the first embodiment, and besides the beneficial effects of the first embodiment, the current limiting threshold may be accurately allocated according to the access amount; the parent node attribute, the depth attribute, the child node attribute, the client attribute and the like of the target abnormal node can be updated, so that the target client can be quickly found from the current-limiting binary tree; whether the abnormal child node recovers the abnormity can be monitored according to the access amount, and the abnormal child node and the normal child node are combined after the abnormal child node and the normal child node recover to be beneficial to improving the accuracy of the current-limiting binary tree; and accurately determining that the current-limiting binary tree is an abnormal client or a normal client according to the client identifier, and accurately limiting the current respectively.
EXAMPLE III
Referring to fig. 8, there is shown a block diagram of a current limiting device in another embodiment of the present disclosure, as follows.
And an access amount monitoring module 301, configured to monitor an access amount of each node in a preset current limiting binary tree, where the node has a current limiting threshold.
A client partitioning module 302, configured to determine an abnormal client and a normal client from clients corresponding to a target abnormal node if an access amount of the target abnormal node in the nodes is greater than a current limiting threshold of the target abnormal node;
a current limiting threshold value allocating module 303, configured to allocate the current limiting threshold value of the target abnormal node to the abnormal client and the normal client, so as to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client.
And an access control module 304, configured to perform access control according to the updated current-limiting binary tree.
In summary, embodiments of the present disclosure provide a current limiting device, the device includes: the access amount monitoring module is used for monitoring the access amount of each node in a preset current limiting binary tree, and the node has a current limiting threshold value; the client dividing module is used for determining an abnormal client and a normal client from the clients corresponding to the target abnormal nodes if the access amount of one target abnormal node in the nodes is greater than the current limiting threshold of the target abnormal node; the current limiting threshold value distribution module is used for distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and the access control module is used for carrying out access control according to the updated current limiting binary tree. The embodiment of the disclosure can distribute the current limiting threshold of the corresponding node of the abnormal client to the abnormal client and the other normal clients respectively when the clients are abnormal, thereby avoiding that one client is abnormal to influence the access of the other normal clients, reducing the labor cost and improving the accuracy of the current limiting threshold.
The third embodiment is an embodiment of the apparatus corresponding to the first embodiment, and the detailed description may refer to the first embodiment, which is not repeated herein.
Example four
Referring to fig. 9, a block diagram of a current limiting device in one embodiment of the present disclosure is shown, as follows.
And an access amount monitoring module 401, configured to monitor an access amount of each node in a preset current limiting binary tree, where the node has a current limiting threshold.
A client partitioning module 402, configured to determine an abnormal client and a normal client from clients corresponding to a target abnormal node if an access amount of the target abnormal node in the nodes is greater than a current limiting threshold of the target abnormal node; optionally, in an embodiment of the present disclosure, the client partitioning module 402 includes:
the access amount statistic sub-module 4021 is configured to count an access amount of the client corresponding to the target abnormal node within a preset time period.
The client partitioning sub-module 4022 is configured to use the client ranked at the top in a client sequence as the abnormal client, and use the other clients as the normal clients, where the client sequence is obtained by arranging the clients corresponding to the target abnormal node in a descending order according to the access amount.
A current limiting threshold value allocation module 403, configured to allocate the current limiting threshold value of the target abnormal node to the abnormal client and the normal client, so as to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; optionally, in an embodiment of the present disclosure, the node further has a parent node and a depth, and the current limiting threshold allocation module 403 includes:
and the visit quantity ratio calculation submodule 4031 is used for calculating the ratio of the visit quantity of the abnormal client to the visit quantity of the target abnormal node.
A current limiting threshold value distribution submodule 4032, configured to divide the current limiting threshold value of the target abnormal node into a first current limiting threshold value corresponding to the abnormal client and a second current limiting threshold value corresponding to the normal client according to the ratio.
A child node creating sub-module 4033, configured to create the abnormal child node corresponding to the abnormal client and the normal child node corresponding to the normal client, and initialize the child nodes.
And the current limiting threshold setting submodule 4034 is configured to set the first current limiting threshold as the current limiting threshold of the abnormal child node, and set the second current limiting threshold as the current limiting threshold of the normal child node, respectively.
A father node setting submodule 4035, configured to set the target abnormal node as the abnormal child node or the father node of the normal child node.
And a depth setting sub-module 4036, configured to set depths of the abnormal sub-node and the normal sub-node according to the depth of the target abnormal node.
A client identifier setting sub-module 4037, configured to set the client identifier of the client with the highest access amount as the client identifier of the abnormal child node, and set the client identifier of the normal child node as null.
A child node update module 4038, configured to set the abnormal child node and the normal child node as child nodes of the target abnormal node.
An access control module 404, configured to perform access control according to the updated current-limiting binary tree; optionally, in an embodiment of the present disclosure, the access control module 404 includes:
and the access request receiving submodule 4041 is configured to receive an access request, where the access request carries a target client identifier.
The node obtaining sub-module 4042 is configured to, in response to the access request, obtain a node corresponding to the target client identifier from the updated node of the current-limiting binary tree, to obtain a target control node.
And the access control sub-module 4043 is configured to, if the target control node is successfully acquired, perform access control on the access request through the current limiting threshold of the target control node.
And a return to normal detection module 405, configured to monitor whether the abnormal child node returns to normal in real time.
A normal recovery processing module 406, configured to set the child node of the normal child node as the child node of the target abnormal node and delete the abnormal child node and the normal child node if it is monitored that the abnormal child node recovers to normal.
A current limiting threshold modifying module 407, configured to modify the current limiting threshold of the child node of the target abnormal node according to the current limiting threshold of the target abnormal node.
Optionally, in an embodiment of the present disclosure, the node obtaining sub-module 4042 includes:
a first node determining unit, configured to determine that the abnormal child node is the target control node if a client identifier corresponding to one of the abnormal child nodes in the updated current-limiting binary tree is the target client identifier.
A second node determining unit, configured to, if the updated current-limiting binary tree does not have the abnormal child node whose client identifier is the target client identifier, take the normal child node in the current-limiting binary tree as the target control node.
Optionally, in another embodiment of the present disclosure, the return to normal detection module 405 includes:
and the abnormal node visit amount monitoring submodule is used for monitoring the visit amount of the abnormal child node in real time.
And the normality recovery confirming submodule is used for confirming that the abnormal child node recovers to be normal if the visit quantity of the abnormal child node is continuously smaller than a preset visit quantity threshold value in a preset time period.
In summary, the embodiment of the present disclosure provides another current limiting device based on the third embodiment, and besides the beneficial effects of the third embodiment, the current limiting threshold may be accurately allocated according to the access amount; the parent node attribute, the depth attribute, the child node attribute, the client attribute and the like of the target abnormal node can be updated, so that the target client can be quickly found from the current-limiting binary tree; whether the abnormal child node recovers the abnormity can be monitored according to the access amount, and the abnormal child node and the normal child node are combined after the abnormal child node and the normal child node recover to be beneficial to improving the accuracy of the current-limiting binary tree; and accurately determining that the current-limiting binary tree is an abnormal client or a normal client according to the client identifier, and accurately limiting the current respectively.
The fourth embodiment is an embodiment of the apparatus corresponding to the second embodiment, and details can be found in the second embodiment and are not described herein again.
An embodiment of the present disclosure also provides an electronic device, referring to fig. 10, including: a processor 501, a memory 502 and a computer program 5021 stored on the memory 502 and executable on the processor, the processor 501 implementing the current limiting method of the foregoing embodiments when executing the program.
Embodiments of the present disclosure also provide a readable storage medium, in which instructions, when executed by a processor of an electronic device, enable the electronic device to perform the current limiting method of the foregoing embodiments.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. In addition, embodiments of the present disclosure are not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the embodiments of the present disclosure as described herein, and any descriptions of specific languages are provided above to disclose the best modes of the embodiments of the present disclosure.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present disclosure may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the disclosure, various features of the embodiments of the disclosure are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that is, claimed embodiments of the disclosure require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of an embodiment of this disclosure.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
The various component embodiments of the disclosure may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a current limiting device according to embodiments of the present disclosure. Embodiments of the present disclosure may also be implemented as an apparatus or device program for performing a portion or all of the methods described herein. Such programs implementing embodiments of the present disclosure may be stored on a computer readable medium or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit embodiments of the disclosure, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. Embodiments of the disclosure may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
The above description is only for the purpose of illustrating the preferred embodiments of the present disclosure and is not to be construed as limiting the embodiments of the present disclosure, and any modifications, equivalents, improvements and the like that are made within the spirit and principle of the embodiments of the present disclosure are intended to be included within the scope of the embodiments of the present disclosure.
The above description is only a specific implementation of the embodiments of the present disclosure, but the scope of the embodiments of the present disclosure is not limited thereto, and any person skilled in the art can easily conceive of changes or substitutions within the technical scope of the embodiments of the present disclosure, and all the changes or substitutions should be covered by the scope of the embodiments of the present disclosure. Therefore, the protection scope of the embodiments of the present disclosure shall be subject to the protection scope of the claims.

Claims (10)

1. A method of limiting current, the method comprising:
monitoring the access amount of each node in a preset current limiting binary tree, wherein the node has a current limiting threshold value; each node in the current limiting binary tree corresponds to one or more clients;
if the access amount of a target abnormal node in the nodes is larger than the current limiting threshold of the target abnormal node, determining an abnormal client and a normal client from the clients corresponding to the target abnormal node;
distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and
performing access control according to the updated current-limiting binary tree;
wherein, the allocating the current limit threshold of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client includes:
dividing the current limiting threshold value of the target abnormal node into a first current limiting threshold value corresponding to the abnormal client and a second current limiting threshold value corresponding to the normal client;
creating the abnormal child node corresponding to the abnormal client and the normal child node corresponding to the normal client, and initializing;
and respectively setting the first current limiting threshold as the current limiting threshold of the abnormal sub-node, and setting the second current limiting threshold as the current limiting threshold of the normal sub-node.
2. The method according to claim 1, wherein the step of determining an abnormal client and a normal client from the clients corresponding to the target abnormal node comprises:
counting the access amount of the client corresponding to the target abnormal node in a preset time period;
and taking the client which is sequenced at the top in the client sequence as the abnormal client, and taking the other clients as the normal clients, wherein the client sequence is obtained by sequencing the clients corresponding to the target abnormal node in a descending order according to the access amount.
3. The method of claim 2, wherein the step of dividing the throttling threshold of the target abnormal node into a first throttling threshold corresponding to the abnormal client and a second throttling threshold corresponding to the normal client comprises:
calculating the ratio of the access quantity of the abnormal client to the access quantity of the target abnormal node;
and dividing the current limiting threshold value of the target abnormal node into a first current limiting threshold value corresponding to the abnormal client and a second current limiting threshold value corresponding to the normal client according to the ratio.
4. The method of claim 3, wherein the node further has a parent node, a depth, and wherein after the steps of setting the first current limit threshold to the current limit threshold of the abnormal child node and the second current limit threshold to the current limit threshold of the normal child node, respectively, the method further comprises:
setting the target abnormal node as a father node of the abnormal child node and the normal child node;
setting the depths of the abnormal child nodes and the normal child nodes according to the depth of the target abnormal node;
and setting the client identifier of the client with the highest access amount as the client identifier of the abnormal child node, and setting the client identifier of the normal child node as null.
5. The method according to any one of claims 1 to 4, wherein after the step of assigning the current limit threshold of the target abnormal node to the abnormal client and the normal client, resulting in an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client, the method further comprises:
and setting the abnormal child node and the normal child node as child nodes of the target abnormal node.
6. The method according to claim 3, wherein after the step of performing access control according to the updated current-limited binary tree, the method further comprises:
monitoring whether the abnormal child node is recovered to be normal or not in real time;
if the abnormal child node is monitored to be recovered to be normal, setting the child node of the normal child node as the child node of the target abnormal node, and deleting the abnormal child node and the normal child node;
and modifying the current limiting threshold of the child node of the target abnormal node according to the current limiting threshold of the target abnormal node.
7. The method of claim 6, wherein the step of monitoring whether the abnormal child node is normal in real time comprises:
monitoring the access amount of the abnormal child node in real time;
and if the visit quantity of the abnormal child node is continuously smaller than a preset visit quantity threshold value in a preset time period, determining that the abnormal child node is recovered to be normal.
8. The method according to claim 6, wherein the step of performing access control according to the updated current-limited binary tree includes:
receiving an access request, wherein the access request carries a target client identifier;
responding to the access request, and acquiring a node corresponding to the target client identifier from the updated node of the current-limiting binary tree to obtain a target control node;
and if the target control node is successfully acquired, performing access control on the access request through the current limiting threshold of the target control node.
9. The method according to claim 8, wherein the step of obtaining a node corresponding to the target client id from the updated nodes of the current-limited binary tree to obtain a target control node includes:
if the client identifier corresponding to one abnormal child node in the updated current-limiting binary tree is the target client identifier, determining that the abnormal child node is the target control node;
and if the updated current-limiting binary tree does not have the abnormal child node of which the client identifier is the target client identifier, taking the normal child node in the current-limiting binary tree as the target control node.
10. A current limiting device, the device comprising:
the access amount monitoring module is used for monitoring the access amount of each node in a preset current limiting binary tree, and the node has a current limiting threshold value; each node in the current limiting binary tree corresponds to one or more clients;
the client dividing module is used for determining an abnormal client and a normal client from the clients corresponding to the target abnormal nodes if the access amount of one target abnormal node in the nodes is greater than the current limiting threshold of the target abnormal node;
the current limiting threshold value distribution module is used for distributing the current limiting threshold value of the target abnormal node to the abnormal client and the normal client to obtain an abnormal child node corresponding to the abnormal client and a normal child node corresponding to the normal client; and
the access control module is used for carrying out access control according to the updated current-limiting binary tree;
wherein, the current limit threshold value distribution module is specifically configured to:
dividing the current limiting threshold value of the target abnormal node into a first current limiting threshold value corresponding to the abnormal client and a second current limiting threshold value corresponding to the normal client;
creating the abnormal child node corresponding to the abnormal client and the normal child node corresponding to the normal client, and initializing;
and respectively setting the first current limiting threshold as the current limiting threshold of the abnormal sub-node, and setting the second current limiting threshold as the current limiting threshold of the normal sub-node.
CN201910709145.1A 2019-08-01 2019-08-01 Current limiting method and device Active CN110417672B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910709145.1A CN110417672B (en) 2019-08-01 2019-08-01 Current limiting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910709145.1A CN110417672B (en) 2019-08-01 2019-08-01 Current limiting method and device

Publications (2)

Publication Number Publication Date
CN110417672A CN110417672A (en) 2019-11-05
CN110417672B true CN110417672B (en) 2021-08-13

Family

ID=68365251

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910709145.1A Active CN110417672B (en) 2019-08-01 2019-08-01 Current limiting method and device

Country Status (1)

Country Link
CN (1) CN110417672B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6967921B1 (en) * 2000-11-27 2005-11-22 At&T Corp. Method and device for efficient bandwidth management
CN102571547A (en) * 2010-12-29 2012-07-11 北京启明星辰信息技术股份有限公司 Method and device for controlling hyper text transport protocol (HTTP) traffic
CN105530138A (en) * 2014-09-28 2016-04-27 腾讯科技(深圳)有限公司 Data monitoring method and data monitoring device
CN107528885A (en) * 2017-07-17 2017-12-29 阿里巴巴集团控股有限公司 A kind of service request processing method and device
CN109067841A (en) * 2018-07-05 2018-12-21 武汉斗鱼网络科技有限公司 Service current-limiting method, system, server and storage medium based on ZooKeeper
CN109787908A (en) * 2018-12-13 2019-05-21 平安普惠企业管理有限公司 Server current-limiting method, system, computer equipment and storage medium
CN109842565A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Interface current-limiting method, device, electronic equipment and storage medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6967921B1 (en) * 2000-11-27 2005-11-22 At&T Corp. Method and device for efficient bandwidth management
CN102571547A (en) * 2010-12-29 2012-07-11 北京启明星辰信息技术股份有限公司 Method and device for controlling hyper text transport protocol (HTTP) traffic
CN105530138A (en) * 2014-09-28 2016-04-27 腾讯科技(深圳)有限公司 Data monitoring method and data monitoring device
CN107528885A (en) * 2017-07-17 2017-12-29 阿里巴巴集团控股有限公司 A kind of service request processing method and device
CN109067841A (en) * 2018-07-05 2018-12-21 武汉斗鱼网络科技有限公司 Service current-limiting method, system, server and storage medium based on ZooKeeper
CN109787908A (en) * 2018-12-13 2019-05-21 平安普惠企业管理有限公司 Server current-limiting method, system, computer equipment and storage medium
CN109842565A (en) * 2018-12-15 2019-06-04 平安科技(深圳)有限公司 Interface current-limiting method, device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN110417672A (en) 2019-11-05

Similar Documents

Publication Publication Date Title
CN104601601B (en) The detection method and device of web crawlers
KR102498093B1 (en) Method and system for user device identification
US9940020B2 (en) Memory management method, apparatus, and system
CN110224943B (en) Flow service current limiting method based on URL, electronic equipment and computer storage medium
CN109359263B (en) User behavior feature extraction method and system
CN114095567B (en) Data access request processing method and device, computer equipment and medium
US20170185454A1 (en) Method and Electronic Device for Determining Resource Consumption of Task
CN109450806B (en) Flow control method and device and distributed cluster
KR102327572B1 (en) Methods and devices for data storage and service processing
CN113726783A (en) Abnormal IP address identification method and device, electronic equipment and readable storage medium
KR20190015327A (en) Methods and Devices to Prevent Servers from Attacking
CN108154024A (en) A kind of data retrieval method, device and electronic equipment
CN111562884A (en) Data storage method and device and electronic equipment
CN112199175A (en) Task queue generating method, device and equipment
CN110417672B (en) Current limiting method and device
US10187264B1 (en) Gateway path variable detection for metric collection
CN110365682B (en) Anti-cheating method and device
CN109871260B (en) Multi-dimensional service current limiting method and system based on shared memory between containers
JP2017156888A (en) Performance degradation factor estimation program, and performance degradation factor estimation device
CN111491040B (en) IP distribution method and IP distribution device
CN112434237A (en) Page loading method and device, electronic equipment and storage medium
CN110891097B (en) Cross-device user identification method and device
CN113300966A (en) Flow control method, device and system and electronic equipment
CN108572871B (en) Resource allocation method and device, electronic equipment and storage medium
CN113961302A (en) Resource allocation method, device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant