Cluster-based Traffic Control Method, Device, Equipment and Storage Medium
By determining the corresponding target nodes and their traffic thresholds for the request in the cluster, the problem of managing nodes in the prior art affecting the flow control efficiency is solved, and efficient and precise flow control is achieved.
Patent Information
- Application Number
- CN202211426567.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-15
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2042-11-15
AI Technical Summary
In the prior art, cluster current limiting requires a preset management node to uniformly manage each server node, resulting in a large-scale distributed cluster, the interaction between the server node and the management node occupies a lot of performance overhead, and the availability of the management node directly affects the efficiency and accuracy of traffic control.
By obtaining the request to access the cluster, the request identification and concurrency threshold corresponding to the request are determined, the target node is determined from at least two server nodes in the cluster based on the request identification, and the traffic threshold of each target node is determined based on the concurrency threshold and the number of target nodes, so that the target node can control the requested traffic according to the traffic threshold.
The traffic control efficiency of requests in the cluster is improved, the availability of management nodes is avoided affecting the accuracy and efficiency of traffic control, and targeted traffic control for different requests is realized.
Smart Images

Figure CN115834483B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of cloud computing technology, and particularly to a cluster-based traffic control method, device, equipment and storage medium. Background Art
[0002] Flow limiting, also known as traffic control, can monitor metrics such as the throughput of application traffic or the number of concurrent threads during the process of flow limiting. When metrics such as throughput or the number of concurrent requests reach a specified threshold, traffic is controlled to prevent the system from being overwhelmed by an instantaneous traffic peak and to ensure the high availability of the application. In a distributed business scenario, it is often necessary to perform an overall flow limiting control on multiple nodes, and such an overall control can be referred to as cluster flow limiting.
[0003] In the prior art, since cluster flow limiting involves multiple distributed server nodes at the same time, it is necessary to preset a management node to collect and uniformly control the situation of each server node. That is, when each server node in the cluster performs a transaction, it needs to interact with the management node. In a large-scale distributed cluster, the interaction between the server node and the management node will occupy a large amount of performance overhead and will also increase the latency of requests to a certain extent. When the management node fails, it will affect the traffic control of the entire cluster, resulting in low traffic control efficiency of the cluster. Summary of the Invention
[0004] This application provides a cluster-based traffic control method, device, equipment and storage medium to improve the traffic control efficiency of requests in the cluster.
[0005] In a first aspect, this application provides a cluster-based traffic control method, including:
[0006] Obtain a request for accessing the cluster, and determine the request identifier corresponding to the request and the concurrency threshold corresponding to the request;
[0007] Determine at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request;
[0008] Determine the traffic threshold for the target node to receive the request according to the concurrency threshold of the request and the number of target nodes, and store the request in association with the traffic threshold; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold.
[0009] In a second aspect, this application provides a cluster-based traffic control device, including:
[0010] A request acquisition module, configured to obtain a request for accessing the cluster, and determine the request identifier corresponding to the request and the concurrency threshold corresponding to the request;
[0011] A node determination module, configured to determine at least one target node from at least two server nodes in the cluster according to a request identifier corresponding to the request;
[0012] A traffic threshold determination module, configured to determine a traffic threshold for the target node to receive the request according to a concurrency threshold of the request and the number of target nodes, and store the request and the traffic threshold in an associated manner; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold.
[0013] In a third aspect, the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;
[0014] The memory stores computer-executable instructions;
[0015] The processor executes the computer-executable instructions stored in the memory to implement the cluster-based traffic control method as described in the first aspect of the present application.
[0016] In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the cluster-based traffic control method as described in the first aspect of the present application.
[0017] In a fifth aspect, the present application provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the cluster-based traffic control method as described in the first aspect of the present application.
[0018] A cluster-based traffic control method, device, equipment and storage medium provided by the present application determine a request identifier corresponding to a request sent to the cluster, and determine a target node corresponding to the request identifier. That is, for the request with the request identifier, it is received by the target node. According to a preset concurrency threshold of the request and the number of target nodes, a traffic threshold for the request that each target node can receive is determined, so as to realize the traffic control of the request by the target node according to the traffic threshold. In the prior art, a management node performs traffic control on all requests, which poses a great challenge to the availability of the management node. The availability of the management node directly affects the accuracy and efficiency of traffic control. The problem of poor traffic control stability caused by traffic control through a management node in the prior art is solved. By determining the target node corresponding to the request and the traffic threshold of each target node, targeted traffic control of different requests is realized, and the accuracy and efficiency of traffic control are improved. Description of the Drawings
[0019] The accompanying drawings herein are incorporated into and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0020] Figure 1 A cluster current-limiting architecture diagram provided for an embodiment of the present application;
[0021] Figure 2 A flowchart of a traffic control method based on a cluster provided for an embodiment of the present application;
[0022] Figure 3 A cluster current-limiting architecture diagram provided for an embodiment of the present application;
[0023] Figure 4 A flowchart of a traffic control method based on a cluster provided for an embodiment of the present application;
[0024] Figure 5 A structural block diagram of a traffic control device based on a cluster provided for an embodiment of the present application;
[0025] Figure 6 A structural block diagram of a traffic control device based on a cluster provided for an embodiment of the present application;
[0026] Figure 7 A structural block diagram of an electronic device provided for an embodiment of the present application;
[0027] Figure 8 A structural block diagram of an electronic device provided for an embodiment of the present application.
[0028] Through the above-mentioned accompanying drawings, specific embodiments of the present application have been shown, and there will be more detailed descriptions hereinafter. These drawings and textual descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Specific Embodiments
[0029] To make the objectives, technical solutions, and advantages of the present application clearer, the following will further describe in detail the embodiments of the present application in conjunction with the accompanying drawings.
[0030] It should be clear that the described embodiments are only a part of the embodiments of the present application, rather than all of them. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application without creative efforts fall within the scope of protection of the present application.
[0031] When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects and do not necessarily have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to specific circumstances. In addition, in the description of the present application, unless otherwise specified, "a plurality of" means two or more. "And / or" describes the association relationship of associated objects and indicates that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects before and after.
[0033] It should be noted that due to space limitations, the specification of the present application does not exhaust all optional embodiments. After reading the specification of the present application, those skilled in the art should be able to think that as long as the technical features do not conflict with each other, any combination of technical features can constitute an optional embodiment. The following will explain each embodiment in detail.
[0034] With the popularization of microservices, more and more enterprises have started to use microservices. Microservice governance is a very important link in the process of using microservices. How to ensure the high availability of microservices is an important task in current service governance. In the field of service governance, traffic limiting is an important isolation means.
[0035] Traffic limiting is also known as flow control. The principle of traffic limiting is to monitor metrics such as the throughput of application traffic or the number of concurrent threads. When metrics such as throughput or concurrency reach a specified threshold, traffic is controlled to prevent the system from being overwhelmed by an instantaneous traffic peak and to ensure the high availability of the application.
[0036] The implementation of traffic limiting for a single server node is closed-loop within the node. In a distributed business scenario, it is often necessary to perform overall traffic limiting control on multiple server nodes. Such overall control is called cluster traffic limiting. Since cluster traffic limiting involves multiple distributed server nodes at the same time, it is necessary to collect and uniformly control the situation of each server node, which is relatively difficult to implement and relatively weak in terms of security.
[0037] Most of the current cluster flow limiting methods collect the flow limiting situations of each server node by setting up a unified "management node". The "management node" is mostly a distributed cache device such as Redis (Remote Dictionary Server). Figure 1 It is the cluster flow limiting architecture diagram in the related art. As Figure 1 shown, requests are sent into the cluster, and the cluster access management node determines whether to intercept the current request. Redis records the situation of each request on each node and responds in real time whether the current node needs flow limiting. After receiving the message from the management node, the node decides whether to release the current request. If the message returned by the management node is to release, the server node releases the request; if the message returned by the management node is to reject, the server node refuses to release the request.
[0038] Each transaction of the server node needs to interact with the management node. In a large-scale distributed cluster, such interaction and invocation will occupy a lot of performance overhead and will increase the latency of requests to a certain extent. In addition, due to thousands of connections accessing the management node, it will pose a great challenge to the availability of the management node. When the management node is unavailable, it will seriously affect the flow control efficiency and accuracy of the cluster.
[0039] A cluster-based traffic control method, device, equipment and storage medium provided by this application aim to solve the above technical problems in the prior art.
[0040] The following uses specific embodiments to detail the technical solutions of this application and how the technical solutions of this application solve the above technical problems. These specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of this application will be described below with reference to the accompanying drawings.
[0041] Figure 2 It is a schematic flowchart of a cluster-based traffic control method provided according to an embodiment of this application. This method can be executed by a cluster-based traffic control device. As Figure 2 shown, this method includes the following steps:
[0042] S201. Obtain a request for accessing the cluster, and determine the request identifier corresponding to the request and the concurrency threshold corresponding to the request.
[0043] Exemplarily, the cluster may include multiple server nodes and a load balancer, and the load balancer is connected to each server node. A request is entered into the cluster, and the request to access the cluster is received by the load balancer. Each request corresponds to a unique request identifier, for example, the load balancer can obtain the request identifier from a preset field in the request. Each request identifier can represent a type of request, for example, for a payment type request, the request identifier is 001, and for a query type request, the request identifier is 002.
[0044] When sending requests to the cluster, each type of request can send multiple requests at the same time, that is, each type of request can be entered into the cluster concurrently. For example, for a type of request with a request identifier of 001, the concurrency of this type of request can be up to 50, that is, up to 50 requests of this type can be sent to the cluster at the same time. The maximum concurrency of each type of request is determined as the concurrency threshold of each type of request. The concurrency threshold of each type of request can be counted by the staff, and when the request actually accesses the cluster, the concurrency will not exceed the concurrency threshold. The type of request is represented by the request identifier, the concurrency threshold of each type of request is pre-set, and the request identifier is associated with the corresponding concurrency threshold and stored. After determining the request identifier of the request, the concurrency threshold corresponding to the request can be determined. When performing flow control, the concurrency of the request actually received by the cluster is equal to or less than the preset concurrency threshold.
[0045] An identification database is pre-set, and the identification database can store the request identifications of the requests received by the cluster. After obtaining the request identification, it can be determined whether the request identification of the request exists in the identification database. If not, the concurrency threshold of the request can be further determined. Every time the cluster receives a new type of request, it will record the server node that processes the request, and associate the request identification of the request with the server node that processes the request and store it in the identification database. Each time a new type of request is received, the traffic threshold that the corresponding server node can receive can also be determined. The traffic threshold can be the maximum traffic value of the request of this type that the server node can receive. The request identification and the traffic threshold can be associated and stored in the identification database.
[0046] In this embodiment, requests with different request identifiers may correspond to the same or different server nodes, that is, requests with different request identifiers are received and processed by the corresponding server nodes. For example, for the request with the request identifier 001, it can be received by server node one and server node two; for the request with the request identifier 001, it can be received by server node three and server node four; for the request with the request identifier 003, it can be received by server node five and server node one. If the cluster has received a request with a certain request identifier, the numbers of the server nodes that received the request can be associated and stored in a preset identifier database, so as to directly determine the corresponding server node for request processing when a request with the same request identifier comes in next time. Therefore, after obtaining the request identifier, it is determined whether the request identifier of the request exists in the identifier database. If it exists, the server node corresponding to the request identifier is determined, and the subsequent steps are not required, that is, it is not necessary to determine the target node from at least two server nodes in the cluster according to the request identifier corresponding to the request. If the identifier database records the traffic threshold that the server node corresponding to the request identifier can receive, it is also not necessary to determine the concurrency threshold corresponding to the request.
[0047] S202. Determine at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request.
[0048] Exemplarily, the cluster includes multiple server nodes. After obtaining the request identifier, one or more nodes are determined from the multiple server nodes as the target nodes. For example, it can be checked whether the request identifier is stored in a preset identifier database. If so, the server node corresponding to the request identifier is determined as the target node.
[0049] Each server node can be numbered in advance. After obtaining the request identifier, if the request identifier is not in the preset identifier database, the request identifier can be calculated based on a preset number calculation rule, and the calculated result is the number of the target node, thereby determining the target node.
[0050] In this embodiment, after determining at least one target node from at least two server nodes, it further includes: associating and storing the request identifier corresponding to the request with the target node in a preset identifier database.
[0051] Specifically, after determining the target node corresponding to the request identifier, the request identifier and the target node are associated and stored in a preset identifier database, which is convenient for directly determining the corresponding target node from the identifier database when a request with the same request identifier is received again, avoiding the process of calculating the target node every time a request is received, improving the determination efficiency of the target node, and further improving the traffic control efficiency.
[0052] In this embodiment, determining at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request includes: if the request identifier corresponding to the request exists in the preset identifier database, then according to the association relationship between the request identifier and the server nodes in the identifier database, determine the server node associated with the request identifier corresponding to the request as the target node.
[0053] Specifically, after determining the request identifier, the target node corresponding to the request identifier can be determined according to a preset calculation method. It is also possible to first check whether the request identifier exists in the identifier database. If it does not exist, then calculate the target node corresponding to the request identifier; if it exists, then directly determine the server node associated with the request identifier corresponding to the request from the identifier database according to the preset association relationship between the request identifier and the server nodes, and use it as the target node. This improves the efficiency of determining the target node, and thus improves the processing efficiency of the request.
[0054] In this embodiment, after determining the server node associated with the request identifier corresponding to the request as the target node, it further includes: sending the traffic of the request to the target node; where the target node is used to, if the received request traffic is less than or equal to the traffic threshold corresponding to the request, release the request; if the received request traffic is greater than the traffic threshold corresponding to the request, refuse to release the request.
[0055] Specifically, if the request identifier exists in the identifier database, it means that the cluster has received a request with this request identifier and has performed traffic control on the request with this request identifier. The traffic threshold that the target node corresponding to this request identifier can receive is recorded in the identifier database. The load balancer sends the request to the corresponding target nodes. For example, the load balancer can evenly distribute the traffic of the request and send it to each target node. When each target node receives the traffic of the request, it can also receive the traffic threshold for processing this request by itself, and compare the received traffic with the traffic threshold. If the received request traffic is less than or equal to the traffic threshold corresponding to the request, release the request; if the received request traffic is greater than the traffic threshold corresponding to the request, refuse to release the request, that is, intercept the request.
[0056] The beneficial effect of this setting is that if the cluster has received a request with the same request identifier, the target node and the traffic threshold can be directly determined. The target node controls the traffic of the request according to the traffic threshold, realizing targeted control of the traffic of requests with different request identifiers, improving the accuracy and efficiency of traffic limiting. And it avoids the target node releasing too much traffic resulting in a traffic peak, realizing traffic limiting of the cluster.
[0057] S203. Determine the traffic threshold for the target node to receive requests according to the concurrent number threshold of the requests and the number of target nodes, and store the requests in association with the traffic threshold; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold.
[0058] Exemplarily, if the request identifier does not exist in the identification database, calculate the number of the target node according to the request identifier, so as to determine the target node. For requests with a certain request identifier, the target node can be one or more. Determine the number of target nodes, and determine the traffic threshold for each target node to receive the request according to the concurrent number threshold of the requests and the number of target nodes, that is, determine the maximum traffic value that each target node can receive for the request. And store the request identifier of the request in association with the traffic threshold, which can be stored in the identification database, so that when the cluster receives a request with the request identifier next time, it can directly determine the traffic threshold of the target node. Through the traffic threshold, the target node can limit the flow of requests, receive requests less than or equal to the traffic threshold, and reject requests greater than the traffic threshold.
[0059] In this embodiment, determining the traffic threshold for the target node to receive requests according to the concurrent number threshold of the requests and the number of target nodes includes: dividing the concurrent number of the requests by the number of target nodes to obtain the traffic threshold when the target node receives the requests.
[0060] Specifically, the concurrent number thresholds corresponding to requests with different request identifiers are preset. After determining the number of target nodes, the concurrent number thresholds can be evenly distributed to each target node. That is, divide the concurrent number threshold of the requests by the number of target nodes to obtain the traffic threshold that each target node can receive when receiving the requests. For example, the concurrent number threshold of the requests is 50, and the target nodes are server node one and server node two. Then the traffic thresholds for server node one and server node two to receive the requests are 25, that is, the maximum concurrent number of this request that these two target nodes can receive is 25 respectively.
[0061] The beneficial effect of such a setting is that it can make the traffic reception capabilities of the target nodes for a certain type of request the same, which is convenient for making the request processing progress of each target node relatively consistent. And the same traffic threshold is convenient for the load balancer to evenly distribute requests to each target node. The load balancer does not need to distribute requests according to the traffic reception capabilities of the target nodes, which improves the traffic control efficiency and accuracy, and further improves the request processing efficiency of the target node.
[0062] Figure 3 This is the cluster flow limiting architecture diagram in this embodiment. Figure 3The request identifier is A, and the concurrency threshold for request A is 50. After request A is injected into the cluster, the load balancer determines that server node 1 and server node 2 are the target nodes, and the traffic threshold for the target nodes is 25. Then the load balancer distributes the received request A to server node 1 and server node 2. The concurrency of request A received by the load balancer is equal to or less than 50. There may be a preset load balancing policy in the load balancer, and according to the preset load balancing policy, request A is distributed to server node 1 and server node 2. For example, request A can be evenly distributed to the two target nodes. After receiving the request, server node 1 and server node 2 can determine whether the received request traffic exceeds 25. If it exceeds 25, the target node rejects the request for release; if it does not exceed 25, the target node releases the request. By combining with the load balancer, the original load policy of the cluster is adjusted targeted, and a large number of original requests of the cluster are divided into several nodes, and a small number of nodes undertake all the traffic of a certain request, improving the pertinence of traffic control.
[0063] A traffic control method based on a cluster provided by an embodiment of the present application determines the request identifier corresponding to the request injected into the cluster and determines the target nodes corresponding to the request identifier. That is, for the request with this request identifier, it is received by the target nodes. According to the preset concurrency threshold of this request and the number of target nodes, the traffic threshold that each target node can receive for this request is determined, so as to realize that the target nodes control the traffic of the request according to the traffic threshold. In the prior art, a management node controls the traffic of all requests, which poses a great challenge to the availability of the management node. The availability of the management node directly affects the accuracy and efficiency of traffic control. It solves the problem of poor traffic control stability caused by traffic control through a management node in the prior art. By determining the target nodes corresponding to the request and the traffic thresholds of each target node, targeted traffic control for different requests is realized, improving the accuracy and efficiency of traffic control.
[0064] Figure 4 It is a schematic flowchart of a traffic control method based on a cluster provided by an embodiment of the present application, and this embodiment is an optional embodiment based on the above embodiment.
[0065] In this embodiment, determining at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request can be refined as follows: If the request identifier corresponding to the request does not exist in the preset identifier database, then determine the number of target nodes according to the request identifier corresponding to the request and the number of server nodes in the cluster; Determine at least one target node from at least two server nodes in the cluster according to the number of target nodes and the preset node sorting of the server nodes; Wherein, the preset node sorting of the server nodes is used to represent the sorting of the preset node numbers of the server nodes from small to large.
[0066] As Figure 4 shown, the method includes the following steps:
[0067] S401. Obtain the request for accessing the cluster, and determine the request identifier corresponding to the request and the concurrency threshold corresponding to the request.
[0068] Exemplarily, obtain the request sent to the cluster, and determine the preset request identifier corresponding to the request and the preset concurrency threshold corresponding to the request.
[0069] In this embodiment, determining the request identifier corresponding to the request includes: determining the field content of the preset field in the request; According to the preset hash algorithm, determine the hash code corresponding to the field content of the preset field, which is the request identifier corresponding to the request.
[0070] Specifically, the request may include multiple fields. For example, it may include fields such as customer number, channel number, and request ID. Preset the determination algorithm of the request identifier. For example, it may be a hash algorithm. Obtain the field content of the preset field in the request. For example, the request ID and customer number can be obtained. According to the preset hash algorithm, perform a hash calculation on the field content of the preset field, convert the field content of the preset field into a hash code, and determine the obtained hash code as the request identifier of the request.
[0071] The beneficial effect of such a setting is that a unique request identifier can be generated according to the content in the request, which is convenient for searching in the identifier database, thereby realizing traffic control.
[0072] S402. If the request identifier corresponding to the request does not exist in the preset identifier database, then determine the number of target nodes according to the request identifier corresponding to the request and the number of server nodes in the cluster.
[0073] Exemplarily, after determining the request identifier, determine whether the request identifier exists in the preset identifier database. If it exists, determine the target node and traffic threshold corresponding to the request identifier, and assign the request to the target node. The target node performs traffic control according to the traffic threshold.
[0074] There are multiple server nodes preset in the cluster, and the number of server nodes in the cluster is determined. If the request identifier does not exist in the preset identifier database, the number of target nodes is determined according to the request identifier corresponding to the request and the number of server nodes in the cluster. For example, the number of target nodes corresponding to different request identifiers can be preset, or a node number determination algorithm can be preset to calculate the number of target nodes according to the request identifier and the number of server nodes in the cluster.
[0075] In this embodiment, determining the number of target nodes according to the request identifier corresponding to the request and the number of server nodes in the cluster includes: taking the remainder of the hash code divided by the number of server nodes in the cluster, and adding one to the remainder to obtain the number of target nodes.
[0076] Specifically, the preset node number determination algorithm can be that after obtaining the hash code, that is, obtaining the request identifier, divide the hash code by the number of server nodes in the cluster, that is, divide the request identifier by the number of server nodes. After division, take the remainder, and then add one to the remainder. The result obtained is the number of target nodes. For example, if the number of server nodes in the cluster is 5, divide the request identifier by 5 and take the remainder. The remainder ranges from 0 to 4. Add one to the remainder, and the number of target nodes is from 1 to 5.
[0077] Through simple division and addition, the number of target nodes can be quickly obtained, and it is ensured that the number of target nodes is less than or equal to the number of server nodes in the cluster, ensuring the feasibility of traffic limiting.
[0078] S403. Determine at least one target node from at least two server nodes in the cluster according to the number of target nodes and the preset node sorting of the server nodes; wherein, the preset node sorting of the server nodes is used to represent the sorting of the preset node numbers of the server nodes from small to large.
[0079] Exemplarily, the server nodes are numbered in advance. For example, natural numbers can be used to number the server nodes. Sort the server nodes according to the number size to obtain the preset node sorting. The preset node sorting can be the sorting result obtained by sorting the preset node numbers of the server nodes from small to large. For example, if there are five server nodes in the cluster and the numbers of the server nodes are 1 to 5, the preset node sorting is 1, 2, 3, 4, 5.
[0080] Determine at least one target node from at least two server nodes in the cluster according to the number of target nodes and the preset node sorting of the server nodes. Server nodes with the number of target nodes can be randomly selected from the preset node sorting as the target nodes. The numbers of the selected target nodes can be adjacent numbers. It is also possible to start from the first server node in the preset node sorting and determine server nodes with the number of target nodes as the target nodes. For example, if the number of target nodes is two, the server nodes numbered 1 and 2 can be determined as the target nodes.
[0081] In this embodiment, determining at least one target node from at least two server nodes in the cluster according to the number of target nodes and the preset node sorting of the server nodes includes: determining the server node that was last determined as a target node in the preset node sorting as the current node; determining, from the preset node sorting of the server nodes, server nodes with the number of target nodes that are ranked after the current node as the target nodes.
[0082] Specifically, each time the cluster determines the target node corresponding to a request, it records the number of the target node determined this time in the preset node sorting. So that when determining the target node each time, the target node determined last time can be determined. For example, when the cluster receives a request for the first time, the request identifier is 001, and the corresponding target nodes determined are server node one and server node two; when the cluster receives a request for the second time, the request identifier is 002, and it can be determined that the target nodes determined last time are server node one and server node two.
[0083] When determining the target node this time, determine the server node that was last determined as a target node in the preset node sorting as the current node. The last target node in the sorting among the target nodes determined last time can be used as the current node. After obtaining the current node, determine, from the preset node sorting, server nodes that are ranked after the current node and have the number of target nodes. Determine the server nodes that are ranked after the current node and have the number of target nodes as the target nodes this time. For example, if the number of target nodes is two, the preset node sorting is 1, 2, 3, 4, 5, and the current node is the server node numbered 2, then the target nodes this time are the server nodes numbered 3 and 4.
[0084] The beneficial effect of such a setting is that by sorting to determine the target nodes, it is avoided that each time the target nodes are determined from the beginning, resulting in excessive pressure on the server nodes ranked in the front, realizing the efficient utilization of the server nodes. Different server nodes can perform traffic control on different requests, achieving the effect of cluster flow limiting.
[0085] In this embodiment, a server node that determines the number of target nodes after the current node from the preset node sorting of the server nodes is the target node, including: if the number of server nodes after the current node is less than the number of target nodes, determining the numerical difference between the number of server nodes after the current node and the number of target nodes; starting from the first server node in the preset node sorting of the server nodes, determining the server nodes with the numerical difference; and determining the server nodes after the current node and the server nodes with the numerical difference starting from the first server node in the preset node sorting as the target nodes.
[0086] Specifically, after determining the number of target nodes and the current node, it can be determined whether the number of server nodes after the current node in the preset node sorting is greater than or equal to the number of target nodes. If so, determining the nodes with the number of target nodes from the server nodes after the current node as the target nodes; if not, determining the server nodes after the current node and some server nodes starting from the beginning in the preset node sorting as the target nodes.
[0087] The numerical difference between the number of server nodes after the current node and the number of target nodes can be determined, and starting from the first server node in the preset node sorting, the server nodes with the numerical difference are determined. For example, if the numerical difference is 1, the first server node can be determined from the preset node sorting. Determining all the server nodes after the current node and the server nodes with the numerical difference starting from the first server node in the preset node sorting as the target nodes for this time. For example, the preset node sorting is 1, 2, 3, 4, 5, the current node is the server node numbered 3, and the number of target nodes is three. It can be determined that the number of server nodes after the current node is 2, which is less than the number of target nodes, so the numerical difference between the number of server nodes after the current node and the number of target nodes is determined to be 1. Determining all the server nodes after the current node, that is, the server node numbered 4 and the server node numbered 5 as the target nodes, and then determining the server node numbered 1 in the preset node sorting as the target node. When determining the target node next time, the server node numbered 1 is the current node.
[0088] The beneficial effect of such a setting is that the target nodes can be determined cyclically in the preset node sorting, enabling each node to be specifically responsible for the traffic control of one or more types of requests, and improving the accuracy of traffic control in the cluster.
[0089] S404. Determine the traffic threshold for the target node to receive requests according to the threshold of the number of concurrent requests and the number of target nodes, and store the requests and the traffic threshold in an associated manner; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold.
[0090] Exemplarily, this step can refer to step S203 above and will not be elaborated here.
[0091] A traffic control method based on a cluster provided by an embodiment of the present application determines the request identifier corresponding to the request sent to the cluster, and determines the target node corresponding to the request identifier. That is, for the request with this request identifier, it is received by the target node. According to the preset threshold of the number of concurrent requests of this request and the number of target nodes, the traffic threshold that each target node can receive for this request is determined, so as to realize the traffic control of requests by the target node according to the traffic threshold. In the prior art, a management node performs traffic control on all requests, which poses a great challenge to the availability of the management node. The availability of the management node directly affects the accuracy and efficiency of traffic control. This solves the problem of poor traffic control stability caused by traffic control through a management node in the prior art. By determining the target node corresponding to the request and the traffic threshold of each target node, targeted traffic control of different requests is realized, improving the accuracy and efficiency of traffic control.
[0092] Figure 5 This is a structural block diagram of a traffic control device based on a cluster provided by an embodiment of the present application. For the sake of convenience of description, only the parts related to the embodiments of the present disclosure are shown. Referring to Figure 5 the device includes: a request acquisition module 501, a node determination module 502, and a traffic threshold determination module 503.
[0093] The request acquisition module 501 is configured to acquire requests for accessing the cluster, and determine the request identifier corresponding to the requests and the threshold of the number of concurrent requests corresponding to the requests;
[0094] The node determination module 502 is configured to determine at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the requests;
[0095] The traffic threshold determination module 503 is configured to determine the traffic threshold for the target node to receive the requests according to the threshold of the number of concurrent requests of the requests and the number of target nodes, and store the requests and the traffic threshold in an associated manner; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold.
[0096] Figure 6 This is a structural block diagram of a traffic control device based on a cluster provided by an embodiment of the present application. In Figure 5Based on the illustrated embodiments, as Figure 6 shown, the node determination module 502 includes a quantity determination unit 5021 and a target node determination unit 5022.
[0097] The quantity determination unit 5021 is configured to determine the quantity of target nodes according to the request identifier corresponding to the request and the quantity of server nodes in the cluster if the request identifier corresponding to the request does not exist in a preset identifier database.
[0098] The target node determination unit 5022 is configured to determine at least one target node from at least two server nodes in the cluster according to the quantity of target nodes and a preset node sorting of the server nodes; wherein, the preset node sorting of the server nodes is used to represent a sorting of the preset node numbers of the server nodes from small to large.
[0099] In one example, the request acquisition module 501 is specifically configured to:
[0100] Determine the field content of a preset field in the request;
[0101] According to a preset hash algorithm, determine a hash code corresponding to the field content of the preset field as the request identifier corresponding to the request.
[0102] In one example, the quantity determination unit 5021 is specifically configured to:
[0103] Divide the hash code by the quantity of server nodes in the cluster and take the remainder, then add one to the remainder to obtain the quantity of target nodes.
[0104] In one example, the target node determination unit 5022 includes:
[0105] A current node determination subunit, configured to determine the server node that was determined as a target node last in the preset node sorting as the current node;
[0106] A target node selection subunit, configured to determine, from the preset node sorting of the server nodes, the server nodes with a quantity equal to the quantity of target nodes that are arranged after the current node as the target nodes.
[0107] In one example, the target node selection subunit is specifically configured to:
[0108] If the quantity of server nodes arranged after the current node is less than the quantity of target nodes, determine the quantity difference between the quantity of server nodes arranged after the current node and the quantity of target nodes;
[0109] Starting from the first server node in the preset node sorting of the server nodes, determine the server nodes with the quantity difference;
[0110] Determine the server nodes ranked after the current node and the server nodes with the quantity difference starting from the first server node in the preset node sorting as the target nodes.
[0111] In one example, the apparatus further includes:
[0112] An identification storage module, configured to, after determining at least one target node from at least two server nodes in the cluster, associatively store the request identifier corresponding to the request and the target nodes in a preset identification database.
[0113] In one example, the node determination module 502 is specifically configured to:
[0114] If the request identifier corresponding to the request exists in the preset identification database, determine, according to the association relationship between the request identifier and the server nodes in the identification database, the server node associated with the request identifier corresponding to the request as the target node.
[0115] In one example, the apparatus further includes:
[0116] A traffic sending module, configured to, after determining the server node associated with the request identifier corresponding to the request as the target node, send the traffic of the request to the target node; wherein, the target node is configured to, if the received request traffic is less than or equal to the traffic threshold corresponding to the request, release the request; if the received request traffic is greater than the traffic threshold corresponding to the request, reject releasing the request.
[0117] In one example, the traffic threshold determination module 503 is specifically configured to:
[0118] Divide the concurrency threshold of the request by the number of target nodes to obtain the traffic threshold when the target nodes receive the request.
[0119] Figure 7 The structural block diagram of an electronic device provided by an embodiment of the present application is as Figure 7 shown, the electronic device includes: a memory 71, a processor 72; the memory 71; a memory for storing executable instructions of the processor 72.
[0120] Wherein, the processor 72 is configured to execute the method provided in the above embodiment.
[0121] The electronic device further includes a receiver 73 and a transmitter 74. The receiver 73 is used to receive instructions and data sent by other devices, and the transmitter 74 is used to send instructions and data to external devices.
[0122] Figure 8 is a block diagram of an electronic device shown according to an exemplary embodiment, and the device may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0123] Device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.
[0124] The processing component 802 generally controls the overall operation of the device 800, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above methods. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.
[0125] The memory 804 is configured to store various types of data to support the operation of the device 800. Examples of such data include instructions for any application or method operating on the device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.
[0126] The power component 806 provides power to various components of the device 800. The power component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device 800.
[0127] The multimedia component 808 includes a screen that provides an output interface between the device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0128] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive external audio signals when the device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting audio signals.
[0129] The I / O interface 812 provides an interface between the processing component 802 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include, but are not limited to: a home button, a volume button, a power button, and a lock button.
[0130] The sensor component 814 includes one or more sensors for providing a status assessment of various aspects of the device 800. For example, the sensor component 814 can detect the on / off state of the device 800, the relative positioning of components, such as the display and the keypad of the device 800. The sensor component 814 can also detect a change in the position of the device 800 or a component of the device 800, the presence or absence of user contact with the device 800, the orientation or acceleration / deceleration of the device 800, and the temperature change of the device 800. The sensor component 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 814 can also include a light sensor, such as a CMOS or a CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0131] The communication component 816 is configured to facilitate communication, either wired or wirelessly, between the device 800 and other devices. The device 800 may access a wireless network based on communication standards, such as WiFi, 2G, or 3G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0132] In an exemplary embodiment, the device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.
[0133] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 804 including instructions, and the above instructions may be executed by a processor 820 of the device 800 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0134] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a terminal device, enables the terminal device to perform the above-described cluster-based traffic control method of the terminal device.
[0135] This application also discloses a computer program product, including a computer program, which when executed by a processor implements the method as described in this embodiment.
[0136] The various embodiments of the systems and techniques described above in this application can be implemented in digital electronic circuitry, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special-purpose or general-purpose programmable processor that receives data and instructions from a storage system, at least one input device, and at least one output device, and transmits the data and instructions to the storage system, the at least one input device, and the at least one output device.
[0137] The program code for implementing the methods of this application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when the program codes are executed by the processor or controller, the functions / operations specified in the flowchart and / or block diagram are implemented. The program codes can be executed entirely on the machine, partially on the machine, executed partially on the machine as an independent software package and partially on a remote machine, or executed entirely on a remote machine or electronic device.
[0138] In the context of this application, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media would include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0139] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and a pointing device (e.g., a mouse or a trackball), by which the user can provide input to the computer. Other kinds of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, speech input, or tactile input).
[0140] The systems and techniques described herein can be implemented in a computing system including backend components (e.g., as a data electronic device), or a computing system including middleware components (e.g., an application electronic device), or a computing system including frontend components (e.g., a user computer having a graphical user interface or a web browser through which the user can interact with an implementation of the systems and techniques described herein), or a computing system including any combination of such backend components, middleware components, or frontend components. The components of the system can be interconnected to each other by digital data communication in any form or medium (e.g., a communication network). Examples of communication networks include: local area network (LAN), wide area network (WAN), and the Internet.
[0141] A computer system can include a client and an electronic device. The client and the electronic device are generally far from each other and usually interact through a communication network. The relationship between the client and the electronic device is generated by computer programs running on respective computers and having a client - electronic device relationship with each other. The electronic device can be a cloud electronic device, also known as a cloud computing electronic device or a cloud host, which is a host product in the cloud computing service system, solving the defects of difficult management and weak business scalability existing in traditional physical hosts and VPS services ("Virtual Private Server", or simply "VPS"). The electronic device can also be an electronic device of a distributed system, or an electronic device combined with a blockchain. It should be understood that the various forms of processes shown above can be reordered, added, or deleted steps. For example, the steps recited in this application can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this application can be achieved, and no limitation is made herein.
[0142] Other embodiments of the present application will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. The present application is intended to cover any variations, uses, or adaptations of the present application, which follow the general principles of the present application and include known common knowledge or conventional technical means in the technical field not disclosed in the present application. The specification and examples are only illustrative, and the true scope and spirit of the present application are pointed out by the following claims.
[0143] It should be understood that the present application is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present application is only limited by the appended claims.
Claims
1. A cluster-based traffic control method, characterized in that, The method includes: Obtaining a request to access a cluster, and determining a request identifier corresponding to the request and a concurrency threshold corresponding to the request; Determining at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request; Determining a traffic threshold for the target node to receive the request according to the concurrency threshold of the request and the number of the target nodes, and associatively storing the request and the traffic threshold; wherein, the traffic threshold is used for the target node to receive requests less than or equal to the traffic threshold; The determining the request identifier corresponding to the request includes: Determining the field content of a preset field in the request; Determining a hash code corresponding to the field content of the preset field according to a preset hash algorithm, as the request identifier corresponding to the request; The determining at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request includes: If the request identifier corresponding to the request does not exist in a preset identifier database, then taking the remainder of dividing the hash code by the number of the server nodes in the cluster, and adding one to the remainder to obtain the number of the target nodes; Determining at least one target node from at least two server nodes in the cluster according to the number of the target nodes and the preset node sorting of the server nodes; wherein, the preset node sorting of the server nodes is used to represent the sorting of the preset node numbers of the server nodes from small to large.
2. The method according to claim 1, characterized in that, The determining at least one target node from at least two server nodes in the cluster according to the number of the target nodes and the preset node sorting of the server nodes includes: Determining the server node that was previously determined as a target node in the preset node sorting as the current node; Determining, from the preset node sorting of the server nodes, the server nodes with the number of the target nodes arranged after the current node as the target nodes.
3. The method according to claim 2, wherein The determining, from the preset node sorting of the server nodes, the server nodes with the number of the target nodes arranged after the current node as the target nodes includes: If the number of server nodes arranged after the current node is less than the number of the target nodes, then determining the difference in the number between the number of server nodes arranged after the current node and the number of the target nodes; Starting from the first server node in the preset node sorting of the server nodes, determining the server nodes with the difference in the number; Determining the server nodes arranged after the current node and the server nodes with the difference in the number starting from the first server node in the preset node sorting as the target nodes.
4. The method according to claim 1, wherein After determining at least one target node from at least two server nodes in the cluster, it further includes: Associatively storing the request identifier corresponding to the request and the target nodes in a preset identifier database.
5. The method according to claim 1, wherein The determining at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request includes: If the request identifier corresponding to the request exists in a preset identifier database, then, according to the association relationship between the request identifier and the server node in the identifier database, determine the server node associated with the request identifier corresponding to the request as the target node.
6. The method according to claim 5, wherein After determining the server node associated with the request identifier corresponding to the request as the target node, it further includes: Send the traffic of the request to the target node; wherein, the target node is used to release the request if the received request traffic is less than or equal to the traffic threshold corresponding to the request; if the received request traffic is greater than the traffic threshold corresponding to the request, reject releasing the request.
7. According to the method described in any one of claims 1-6, characterized in that, Determining the traffic threshold for the target node to receive the request according to the concurrency threshold of the request and the number of target nodes includes: Divide the concurrency threshold of the request by the number of target nodes to obtain the traffic threshold for the target node to receive the request.
8. A cluster-based traffic control device, characterized in that, The device includes: A request acquisition module, configured to acquire a request for accessing a cluster, and determine the request identifier corresponding to the request and the concurrency threshold corresponding to the request; A node determination module, configured to determine at least one target node from at least two server nodes in the cluster according to the request identifier corresponding to the request; A traffic threshold determination module, configured to determine the traffic threshold for the target node to receive the request according to the concurrency threshold of the request and the number of target nodes, and store the request and the traffic threshold in an associated manner; wherein, the traffic threshold is used to receive requests less than or equal to the traffic threshold by the target node; The request acquisition module is specifically configured to determine the field content of a preset field in the request; according to a preset hash algorithm, determine the hash code corresponding to the field content of the preset field as the request identifier corresponding to the request; The node determination module is specifically configured to, if the request identifier corresponding to the request does not exist in the preset identifier database, divide the hash code by the number of server nodes in the cluster and take the remainder, add one to the remainder to obtain the number of target nodes; according to the number of target nodes and the preset node sorting of the server nodes, determine at least one target node from at least two server nodes in the cluster; wherein, the preset node sorting of the server nodes is used to represent the sorting of the preset node numbers of the server nodes from smallest to largest.
9. An electronic device, characterized in that, It includes: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the cluster-based traffic control method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, Computer-executable instructions are stored in the computer-readable storage medium, and when the computer-executable instructions are executed by a processor, they are used to implement the cluster-based traffic control method according to any one of claims 1-7.
11. A computer program product, characterized in that, Comprising a computer program which, when executed by a processor, implements the cluster-based traffic control method according to any one of claims 1-7.
Citation Information
Patent Citations
Access control method and device
CN108173937A
Call chain-based concurrency control method, device, and control node
CN108633311A
Flow control method, device and equipment and computer storage medium
CN114710450A