Flow limiting processing method and device, equipment and storage medium

By using the counting mechanism of local and remote trees in the server of the traffic control cluster, the current limiting results are determined, and the problem of insufficient current limiting stability in large traffic scenarios is solved, and stable and low-latency traffic limit is achieved.

CN119520398APending Publication Date: 2025-02-25BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311061509.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-22
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In larger traffic scenarios, the existing current limiting methods are insufficient in stability, which affects the call of downstream resources.

Method used

By establishing local trees and remote trees in the server of the traffic control cluster, the resource request count of the local trees and the resource usage count of the remote trees determine the flow limit results, achieving relatively stable and low latency traffic limits.

Benefits of technology

It realizes stable traffic limit in larger traffic scenarios, reduces current limit delay, and avoids the impact of instability of database services on current limit processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

The invention discloses a flow limiting processing method applied to a server included in a flow control cluster, a flow limiting processing method and device applied to a database cluster, equipment and a storage medium, and belongs to the technical field of computers. The flow control cluster is respectively connected with one database cluster and at least one service cluster. The server obtains a resource calling request sent by the service cluster, and modifies a resource request count of a local tree of the server; and determining a current limiting result by using the resource request count of the local tree and the resource use count of the remote tree of the server, and feeding back the current limiting result to the service cluster. And the server interacts with the database cluster, sends the local tree to the database cluster, and obtains the database tree of the database cluster to update the remote tree of the server. Therefore, the current limiting processing is carried out locally, decoupling of the current limiting processing and the database service is realized, the influence of instability of the database service on the current limiting processing is avoided, and the current limiting processing with relatively high stability and relatively small delay is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In some business scenarios, it is necessary to call downstream resources for business processing. When downstream resources are limited, it is necessary to limit the flow of requests for calling downstream resources to prevent affecting the normal operation of downstream resources.

[0003] For example, in the content security review business, it is necessary to determine whether the content has security risks. During the review process, it is necessary to call the pre-established security review model to judge the security risks of the content. There are corresponding security review models for different types of content. For example, for text-type content, a model that can perform security review on text is used. For image-type content, a model that can perform security review on images is used. For different types of security projects, corresponding security review models are also required. When requesting to call a model for security review, a large amount of traffic may be generated. However, the resources of the model are limited. If traffic restrictions are not performed in scenarios with large traffic, that is, current limiting, it is easy to cause the model service to crash.

[0004] Currently, the current limiting method in large traffic scenarios has the problem of insufficient stability, which affects the call of downstream resources. Summary of the invention

[0005] In view of this, the present application provides a flow limiting processing method, device, equipment and storage medium, which can achieve relatively stable and low-latency flow limiting in scenarios with large flow rates.

[0006] Based on this, the technical solutions provided by this application are as follows:

[0007] In a first aspect, the present application provides a flow limiting processing method, the method is applied to a server included in a flow control cluster, the flow control cluster is respectively connected to a database cluster and at least one service cluster, the method comprising:

[0008] Obtain a resource call request sent by the service cluster, and modify the resource request count of the local tree of the server; determine a flow limiting result using the resource request count of the local tree and the resource usage count of the remote tree of the server, wherein the resource usage count of the remote tree is determined based on the resource usage count of the database tree of the database cluster, and the resource usage count is the sum of the resource request counts of the local trees of the servers included in the flow control cluster obtained by the database cluster; and feed back the flow limiting result to the service cluster that sent the resource call request.

[0009] In a possible implementation, the local tree and the remote tree each include only one node, and determining the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes:

[0010] Calculate the sum of the resource request count of the local tree and the resource usage count of the remote tree to obtain a first count; if the first count is less than the resource limit, the flow limiting result is no flow limiting; if the first count is greater than or equal to the resource limit, the flow limiting result is flow limiting.

[0011] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the root node corresponds to available resources, the leaf nodes correspond to services requesting to call the available resources, the resource request count includes the request count of the root node of the local tree and the request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the remote tree includes a root node and multiple leaf nodes, each node of the local tree corresponds one-to-one to each node of the remote tree, the resource usage count of the remote tree includes the usage count of the root node of the remote tree and the usage count of each of the leaf nodes of the remote tree, the usage count of the root node of the remote tree is the sum of the usage counts of each of the leaf nodes of the remote tree.

[0012] In a possible implementation, the number of resource call requests is 1, the resource call request includes information about target available resources and information about target services, and the modifying of the resource request count of the local tree of the server includes:

[0013] The request count of the root node corresponding to the target available resource included in the local tree is increased by 1, and the request count of the leaf node corresponding to the target service included in the root node corresponding to the target available resource is increased by 1.

[0014] In a possible implementation, determining the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes:

[0015] Calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count; if the second count is less than the root limit of the root node corresponding to the target available resources, the flow limiting result is no flow limiting; if the second count is greater than or equal to the root limit of the root node corresponding to the target available resources, the flow limiting result is flow limiting.

[0016] In a possible implementation, determining the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes:

[0017] Calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count; calculate the sum of the request count of the leaf node corresponding to the target business of the local tree and the leaf node corresponding to the target business of the remote tree to obtain a third count of the leaf node corresponding to the target business; if the second count is less than the root limit of the root node corresponding to the target available resources, and the third count is less than the leaf limit of the leaf node corresponding to the target business, the flow limiting result is no flow limiting; if the second count is greater than or equal to the root limit of the root node corresponding to the target available resources, or the third count is greater than or equal to the leaf limit of the leaf node corresponding to the target business, the flow limiting result is flow limiting.

[0018] In one possible implementation, the existence duration of the local tree and the remote tree is a current limiting unit duration, the root limit and the leaf limits of each leaf node are determined based on the resource request count of the local tree and the resource usage count of the remote tree within the historical current limiting unit duration, and the root limit is the sum of the leaf limits of each leaf node.

[0019] In a possible implementation, each leaf node included in the local tree has a priority, and the leaf quota of each leaf node is determined based on the root quota and the priority of each leaf node, and the leaf quota of the leaf node is positively correlated with the priority of the leaf node.

[0020] In a possible implementation, the method further includes:

[0021] The local tree of the server is sent to the database cluster at a first frequency, and the local tree of the server is used to update the resource usage count of the database tree of the database cluster.

[0022] In a possible implementation, the method further includes:

[0023] The database tree is obtained at a second frequency, and the remote tree of the server is updated using the database tree.

[0024] In a second aspect, the present application provides a flow limiting processing method, the method is applied to a database cluster, the database cluster is connected to a flow control cluster, and the method includes:

[0025] Acquire a local tree sent by a server included in the flow control cluster; use the local tree to update a database tree, wherein a resource usage count of the database tree is the sum of resource request counts of the local trees of each server; and send the database tree to the server included in the flow control cluster.

[0026] In a possible implementation, the local tree and the database tree include only one node, and updating the database tree by using the local tree includes:

[0027] The resource request counts of the local trees are added together to obtain the resource usage count of the database tree.

[0028] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the resource request count includes a request count of the root node of the local tree and a request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the database tree includes a root node and multiple leaf nodes, each node of the database tree corresponds one-to-one to each node of the local tree, the resource usage count of the database tree includes a usage count of the root node of the database tree and a usage count of each of the leaf nodes of the database tree, the usage count of the root node of the database tree is the sum of the usage counts of each of the leaf nodes of the database tree.

[0029] In a possible implementation, the updating of the database tree by using the local tree includes:

[0030] Calculate the request count of the root node of each local tree and the sum of the historical usage counts of the root node of the database tree to obtain the usage count of the root node of the database tree after update; calculate the historical usage count of the target leaf node of the database tree and the sum of the request counts of the leaf nodes of each local tree corresponding to the target leaf node of the database tree to obtain the usage count of the target leaf node of the database tree after update, wherein the target leaf node of the database tree is one of the leaf nodes included in the database tree.

[0031] In a third aspect, the present application provides a flow limiting processing device, which is applied to a server included in a flow control cluster, wherein the flow control cluster is respectively connected to a database cluster and at least one service cluster, and the device includes:

[0032] An acquisition unit, configured to acquire a resource call request sent by the service cluster and modify a resource request count of a local tree of the server;

[0033] A determination unit, configured to determine a flow limiting result by using a resource request count of the local tree and a resource usage count of a remote tree of the server, wherein the resource usage count of the remote tree is determined based on a resource usage count of a database tree of the database cluster, and the resource usage count is a sum of resource request counts of local trees of various servers included in the flow control cluster acquired by the database cluster;

[0034] A feedback unit is used to feed back the current limiting result to the service cluster that sends the resource call request.

[0035] In one possible implementation, the local tree and the remote tree each include only one node, and the determination unit is specifically used to calculate the sum of the resource request count of the local tree and the resource usage count of the remote tree to obtain a first count; if the first count is less than the resource limit, the flow limiting result is no flow limiting; if the first count is greater than or equal to the resource limit, the flow limiting result is flow limiting.

[0036] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the root node corresponds to available resources, the leaf nodes correspond to services requesting to call the available resources, the resource request count includes the request count of the root node of the local tree and the request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the remote tree includes a root node and multiple leaf nodes, each node of the local tree corresponds one-to-one to each node of the remote tree, the resource usage count of the remote tree includes the usage count of the root node of the remote tree and the usage count of each of the leaf nodes of the remote tree, the usage count of the root node of the remote tree is the sum of the usage counts of each of the leaf nodes of the remote tree.

[0037] In a possible implementation, the number of resource call requests is 1, the resource call request includes information about target available resources and information about target services, and the acquisition unit is used to modify the resource request count of the local tree of the server, including:

[0038] The acquisition unit is used to add 1 to the request count of the root node corresponding to the target available resource included in the local tree, and to add 1 to the request count of the leaf node corresponding to the target service included in the root node corresponding to the target available resource.

[0039] In one possible implementation, the determination unit is specifically used to calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count; if the second count is less than the root limit of the root node corresponding to the target available resources, the flow limiting result is no flow limiting; if the second count is greater than or equal to the root limit of the root node corresponding to the target available resources, the flow limiting result is flow limiting.

[0040] In a possible implementation, the determination unit is specifically used to calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count; calculate the sum of the request count of the leaf node corresponding to the target business of the local tree and the leaf node corresponding to the target business of the remote tree to obtain a third count of the leaf node corresponding to the target business; if the second count is less than the root limit of the root node corresponding to the target available resources, and the third count is less than the leaf limit of the leaf node corresponding to the target business, the flow limiting result is no flow limiting; if the second count is greater than or equal to the root limit of the root node corresponding to the target available resources, or the third count is greater than or equal to the leaf limit of the leaf node corresponding to the target business, the flow limiting result is flow limiting.

[0041] In one possible implementation, the existence duration of the local tree and the remote tree is a current limiting unit duration, the root limit and the leaf limits of each leaf node are determined based on the resource request count of the local tree and the resource usage count of the remote tree within the historical current limiting unit duration, and the root limit is the sum of the leaf limits of each leaf node.

[0042] In a possible implementation, each leaf node included in the local tree has a priority, and the leaf quota of each leaf node is determined based on the root quota and the priority of each leaf node, and the leaf quota of the leaf node is positively correlated with the priority of the leaf node.

[0043] In a possible implementation manner, the device further includes:

[0044] A sending unit is used to send the local tree of the server to the database cluster at a first frequency, and the local tree of the server is used to update the resource usage count of the database tree of the database cluster.

[0045] In a possible implementation manner, the device further includes:

[0046] An updating unit is used to obtain the database tree at a second frequency, and update the remote tree of the server using the database tree.

[0047] In a fourth aspect, the present application provides a flow limiting processing device, the device is applied to a database cluster, the database cluster is connected to a flow control cluster, and the device includes:

[0048] An acquisition unit, configured to acquire a local tree sent by a server included in the flow control cluster;

[0049] An updating unit, configured to update a database tree using the local tree, wherein the resource usage count of the database tree is the sum of the resource request counts of the local trees of the respective servers;

[0050] A sending unit is used to send the database tree to the server included in the traffic control cluster.

[0051] In a possible implementation, the local tree and the database tree include only one node, and the updating unit is specifically configured to add the resource request counts of the local trees to obtain the resource usage count of the database tree.

[0052] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the resource request count includes a request count of the root node of the local tree and a request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the database tree includes a root node and multiple leaf nodes, each node of the database tree corresponds one-to-one to each node of the local tree, the resource usage count of the database tree includes a usage count of the root node of the database tree and a usage count of each of the leaf nodes of the database tree, the usage count of the root node of the database tree is the sum of the usage counts of each of the leaf nodes of the database tree.

[0053] In a possible implementation, the update unit is specifically used to calculate the request count of the root node of each of the local trees and the sum of the historical usage counts of the root node of the database tree to obtain the usage count of the root node of the database tree after update; calculate the historical usage count of the target leaf node of the database tree and the sum of the request counts of the leaf nodes of each of the local trees corresponding to the target leaf node of the database tree to obtain the usage count of the target leaf node of the database tree after update, and the target leaf node of the database tree is one of the leaf nodes included in the database tree.

[0054] In a fifth aspect, the present application provides an electronic device, including:

[0055] one or more processors;

[0056] a storage device having one or more programs stored thereon,

[0057] When the one or more programs are executed by the one or more processors, the one or more processors implement any method described in the first aspect or any method described in the second aspect.

[0058] In a sixth aspect, the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the program implements any method described in the first aspect or any method described in the second aspect.

[0059] In a seventh aspect, the present application provides a computer program product, which, when running on a device, enables the device to execute the method described in the first aspect, or any method described in the second aspect.

[0060] It can be seen that this application has the following beneficial effects:

[0061] The present application provides a flow limiting processing method applied to a server included in a flow control cluster, as well as a flow limiting processing method, device, equipment and storage medium applied to a database cluster. The flow control cluster is connected to a database cluster and at least one service cluster respectively. In the method, the server obtains a resource call request sent by the service cluster, modifies the resource request count of the local tree of the server; determines the flow limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server, and feeds back the flow limiting result to the service cluster. The server interacts with the database cluster, sends a local tree to the database cluster, and obtains the database tree of the database cluster to update the remote tree of the server. Among them, the resource usage count of the remote tree is determined based on the resource usage count of the database tree of the database cluster, and the resource usage count is the sum of the resource request counts of the local trees of each server included in the flow control cluster obtained by the database cluster. In this way, flow limiting processing can be performed locally, decoupling of flow limiting processing and database service is achieved, the influence of the instability of the database service on the flow limiting processing is avoided, and a flow limiting processing with higher stability is achieved, and the flow limiting delay is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1 A schematic diagram of a framework of an exemplary application scenario provided in an embodiment of the present application;

[0063] Figure 2 A schematic diagram of a framework of an exemplary application scenario provided in an embodiment of the present application;

[0064] Figure 3 A flow chart of a flow limiting processing method for a server in a flow control cluster provided in an embodiment of the present application;

[0065] Figure 4 A schematic diagram of a local tree provided in an embodiment of the present application;

[0066] Figure 5 A schematic diagram of a remote tree provided in an embodiment of the present application;

[0067] Figure 6A schematic diagram of quota allocation of a local tree provided in an embodiment of the present application;

[0068] Figure 7 A flow chart of a current limiting processing method applied to a database cluster provided in an embodiment of the present application;

[0069] Figure 8 A schematic diagram of the structure of a flow limiting processing device applied to a server of a flow control cluster provided in an embodiment of the present application;

[0070] Fig. 9 A schematic diagram of the structure of a current limiting processing device applied to a database cluster provided in an embodiment of the present application;

[0071] Fig.10 A schematic diagram of the basic structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0072] In order to facilitate the understanding and explanation of the technical solutions provided by the embodiments of the present application, the background technology of the present application will be described below.

[0073] In the content security audit business, in order to audit various types of content for various security items, it is necessary to call models for different types of content and different security items for auditing. In this way, in the process of security auditing a large amount of content, a large number of models need to be called for auditing. In the case of limited model resources, it is necessary to limit the request for calling the model to ensure that the model can provide services normally.

[0074] In the current flow control method, Redis (Remote Dictionary Server) is used to count the inventory of resources. The flow control process is not completely decoupled from Redis. When the inventory (stocks) of the resources recorded locally is sufficient, the local inventory is deducted and the request is processed without flow control. When the local inventory is insufficient, it is necessary to wait for the inventory to be pulled from Redis. Whether to limit the flow depends on the inventory situation fed back by Redis, and the flow control process is affected by the stability of Redis. When Redis is unstable, it affects the judgment of whether the request is limited, which leads to unstable flow control.

[0075] Based on this, the embodiment of the present application provides a flow limiting processing method, device, equipment and storage medium, which is applied to the server included in the flow control cluster, and the flow control cluster is respectively connected to a database cluster and at least one service cluster. The method obtains the resource call request sent by the service cluster, modifies the resource request count of the local tree of the server; determines the flow limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server, and feeds back the flow limiting result to the service cluster. Among them, the resource usage count of the remote tree is determined based on the resource usage count of the database tree of the database cluster, and the resource usage count is the sum of the resource request counts of the local trees of each server included in the flow control cluster obtained by the database cluster. In this way, flow limiting processing can be performed locally, and the decoupling of processing requests and requesting resources from the database is realized, avoiding the influence of the instability of the database service on the flow limiting processing, and realizing the flow limiting processing with higher stability.

[0076] In order to facilitate understanding of a current limiting processing method provided in an embodiment of the present application, a current limiting processing method provided in an embodiment of the present application is described below in conjunction with the accompanying drawings. Figure 1 and Figure 2 See the example scenario shown. Figure 1 and Figure 2 As shown, this figure is a framework diagram of an exemplary application scenario provided in an embodiment of the present application.

[0077] Those skilled in the art will understand that Figure 1 and Figure 2 The framework diagram shown is only an example in which the embodiments of the present application can be implemented. The scope of application of the embodiments of the present application is not limited by any aspect of the framework.

[0078] The present application embodiment provides a flow control cluster server included in the flow control processing method and a database cluster flow control processing method. Figure 1 As shown, each flow control cluster is connected to a database cluster and multiple service clusters. The database cluster is, for example, a distributed cluster, such as a Redis cluster. Each service cluster can send a request to call a resource to the flow control cluster, that is, a resource call request. The flow control cluster is used to limit the flow of requests from the service cluster. The flow control cluster corresponds one-to-one to the database cluster.

[0079] See also Figure 2As shown, the server 1 included in the flow control cluster establishes a local tree and a remote tree in the local memory. Among them, the local tree includes a root node and a leaf node, and the local tree has a resource request count. The resource request count is used to count the number of requests. The remote tree includes a root node and a leaf node. The remote tree includes a resource usage count. The resource usage count is used to count the number of resource usage. The resource usage count of the remote tree is determined based on the resource usage count of the database tree of the database cluster. The resource usage count of the database tree is obtained by the database cluster counting the resource request counts of the local trees of each server in the flow control cluster.

[0080] The server obtains the resource call request sent by the service cluster, and modifies the resource request count of the local tree for this request. The server sends the local tree to the database cluster at a first frequency. The database cluster updates the database tree using the local trees of each server included in the acquired flow control cluster. The database cluster sends the database tree to the server at a second frequency. The server updates the remote tree using the acquired database tree. The server determines the flow limiting result using the resource request count of the local tree and the resource usage count of the remote tree, and feeds back the flow limiting result to the service cluster. The service cluster can determine whether the corresponding resource can be called based on the flow limiting result.

[0081] Establishing a local tree and a remote tree in the local memory of the server, and using the database tree of the database cluster to asynchronously update the remote tree, can decouple the current limiting process from the database service, avoid the instability of the current limiting process caused by the instability of the database service, and improve the stability of the current limiting process.

[0082] In order to facilitate understanding of the technical solution provided by the embodiment of the present application, the current limiting processing method provided by the embodiment of the present application and applied to the server of the flow control cluster is described below in conjunction with the accompanying drawings. The current limiting processing method provided by the embodiment of the present application is applied to the server included in the flow control cluster. The flow control cluster is respectively connected to a database cluster and at least one service cluster. It should be noted that the current limiting processing method can be applied to any instance of implementing a current limiting service established based on the server.

[0083] See also Figure 3 As shown in FIG. 1 , this figure is a flow chart of a flow limiting processing method for a server in a flow control cluster provided in an embodiment of the present application, such as Figure 3 As shown, the method may include S301-S303:

[0084] S301: Obtain a resource call request sent by a service cluster, and modify the resource request count of a local tree of the server.

[0085] When the service cluster needs to call resources during the business process, it triggers the sending of resource call requests to the flow control cluster. In one possible implementation, the SDK (Software Development Kit) of the flow control cluster determines the service cluster that processes the resource call request according to the hash value of the resource name to be called by the resource call request. In this way, resource call requests that call the same resource can be processed by the same service cluster.

[0086] The resource call request is used to request to call resources required for processing a business. As an example, the resource call request is an RPC (Remote Procedure Call) request.

[0087] The embodiments of the present application do not limit the specific content of the resource call request. As an example, the resource call request includes relevant information of the resource requested to be called and relevant information of the business using the resource. The flow control cluster can allocate resource call requests to be processed to the server based on the load of each server.

[0088] A local tree is pre-created in the local memory of the server. The resource request count of the local tree is used to record the resource request situation. For example, the resource request count of the local tree is QPS (Queries per second), or for each current limiting unit duration, that is, the number of queries for the current limiting scale. The embodiment of the present application limits the current limiting unit duration, that is, the specific value of the current limiting scale. Those skilled in the art can configure it based on needs. As an example, the current limiting unit duration is 10 seconds. Configuring an extended current limiting unit duration can reduce the frequency of interaction with the database service and improve the accuracy of the current limiting method.

[0089] It should be noted that the local tree can be created for each flow limiting unit duration. That is, before the start time of each flow limiting unit duration, the local tree of the flow limiting unit duration is created in advance. The created local tree is used to record the resource requests within the flow limiting unit duration. After the end time of the flow limiting unit duration, the local tree can be deleted, or the preset time can be retained to configure the limit of the subsequent flow limiting unit duration.

[0090] In addition, the embodiment of the present application does not limit the number of nodes included in the local tree. In one possible implementation, the local tree includes only one node. The node can be created for an available resource. The local tree can be used to implement current limiting processing of requests for calling the available resource. In another possible implementation, the local tree is a map structure. The local tree includes a root node and multiple leaf nodes. See Figure 4As shown, this figure is a schematic diagram of a local tree provided in an embodiment of the present application. The root node is created for the available resources, and the leaf nodes correspond to the services requesting to call the available resources. Different services can be reflected by different users sending resource call requests. The resource request count of the local tree includes the request count of the root node of the local tree and the request count of each leaf node of the local tree. The request count of the root node is the sum of the request counts of each leaf node. The local tree using a multi-node structure can implement current limiting processing of requests to call the available resources, and can implement current limiting processing of multiple services when multiple services request to call the available resources.

[0091] After the server obtains the resource call request sent by the service cluster, the resource request count of the local tree is modified. Specifically, the resource request count of the local tree can be modified using the counter of the local tree.

[0092] When the local tree includes only one node, the resource request count of the node is modified. For example, based on a request obtained this time, the resource request count is increased by 1.

[0093] In the case where the local tree includes a root node and a leaf node, the resource call request includes information about the target available resource and information about the target service. Modify the request count of the root node corresponding to the target available resource included in the local tree, and the request count of the leaf node corresponding to the target service included under the root node. For example, based on a request obtained this time, add 1 to the request count of the root node corresponding to the target available resource included in the local tree, and add 1 to the request count of the leaf node corresponding to the target service included under the root node.

[0094] S302: Determine the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server.

[0095] The local memory of the server also pre-builds the remote tree. The resource usage count of the remote tree is used to record the resource usage of the database cluster.

[0096] The remote tree is a mirror of the database tree established by the database cluster. The database tree of the database cluster is used to record the resource request status of each server in the flow control cluster. The resource usage count of the database tree is the sum of the resource request counts of the local trees of each server included in the flow control cluster obtained by the database cluster. For the update method of the database tree of the database cluster, see below.

[0097] In one possible implementation, a database tree is obtained from a database cluster at a preset frequency, and the database tree is used to update the remote tree. As an example, the remote tree is overwritten by the database tree. The embodiment of the present application does not limit the specific value of the frequency of obtaining the database tree. For example, when the current limiting unit duration is 10 seconds, the frequency is to obtain the database tree once every 100 milliseconds. When the frequency of obtaining the database tree is high, the remote tree in the local memory of the server is infinitely close to the database tree. In this way, the remote tree can be used to perform current limiting processing more accurately, and decoupling from the database service can be achieved to ensure the stability of the current limiting processing.

[0098] It should be noted that the remote tree can also be created for each current limiting unit duration. That is, before the start time of each current limiting unit duration, the local tree and remote tree of the current limiting unit duration are created in advance. The created remote tree is used to record the resource usage within the current limiting unit duration. After the end time of the current limiting unit duration, the remote tree can be deleted, or the preset time can be retained to configure the limit of the subsequent current limiting unit duration.

[0099] In addition, the embodiment of the present application does not limit the number of nodes included in the remote tree. The remote tree and the local tree include the same nodes. In one possible implementation, the local tree and the remote tree include only one node. In another possible implementation, the remote tree is a map structure. The remote tree includes a root node and multiple leaf nodes. Figure 5 As shown, this figure is a schematic diagram of a remote tree provided in an embodiment of the present application. Figure 5 The remote tree shown is the same as Figure 4 The local tree shown in FIG. 1 corresponds to each node in the remote tree. Each node in the remote tree corresponds to each node in the local tree. The resource usage count of the remote tree includes the usage count of the root node of the remote tree and the usage count of each leaf node of the remote tree. The usage count of the root node of the remote tree is the sum of the usage counts of each leaf node.

[0100] Whether to limit the current request can be determined based on the resource request count of the local tree and the resource usage count of the remote tree.

[0101] As a possible implementation, a quota is preconfigured. The quota is used to indicate the highest count that can call a resource. When the resource request count, or the resource usage count, or the sum of the resource request count and the resource usage count is greater than or equal to the quota, the flow limiting result is determined to be flow limiting, and flow limiting processing is performed on this request.

[0102] For local trees and remote trees of different structures, the methods for determining whether to limit the flow are different. The present application embodiment provides several specific implementation methods for determining the flow limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server, please refer to the detailed description below.

[0103] As another possible implementation, a pre-trained artificial intelligence model can be used to process resource request counts and resource usage counts to determine the current limiting result. The artificial intelligence model can be pre-trained using training samples. The training samples include resource request count samples, resource usage count samples, and labels corresponding to the resource request count samples and resource usage count samples. The label is a pre-labeled current limiting result.

[0104] S303: Feedback the current limiting result to the service cluster that sent the resource call request.

[0105] After determining the current limiting result, the current limiting result is fed back to the service cluster that sent the resource call request. As an example, the current limiting result is no current limiting. The service cluster can call the corresponding resource based on the current limiting result. As another example, the current limiting result is current limiting. The service cluster is denied to call the corresponding resource.

[0106] Based on the relevant contents of S301-S303 above, it can be known that a local tree and a remote tree are established in the local memory of the server. The local tree can record the resource request. As a mirror of the database tree of the database cluster, the remote tree can reflect the resource usage of the database cluster. After the server obtains the resource call request, it can judge whether to limit the flow based on the local tree and remote tree in the local memory. In this way, the flow limiting process is decoupled from the services provided by the database cluster, and the stability of the database cluster does not affect the stability of the flow limiting process, so that a relatively stable flow limiting process is achieved. In addition, the flow limiting process is implemented based on the local tree and remote tree in the local memory of the server, which can improve the efficiency of the flow limiting process and reduce the delay of the flow limiting. Especially for ultra-large traffic scenarios, stable, low-latency, and high-precision flow limiting can be achieved.

[0107] For local trees and remote trees of different structures, the methods of determining the current limiting result using the resource request count of the local tree and the resource usage count of the remote tree are different. As some examples, the embodiments of the present application provide three specific implementation methods of determining the current limiting result using the resource request count of the local tree and the resource usage count of the remote tree.

[0108] The first one: Both the local tree and the remote tree contain only one node.

[0109] When both the local tree and the remote tree have only one node, the sum of the resource request count of the local tree and the resource usage count of the remote tree is calculated to obtain the first count. The first count is the count of the resources currently used and requested. If the first count is less than the resource limit, it means that the resources currently used and requested do not exceed the limit, and the flow limiting result is unlimited flow. If the first count is greater than or equal to the resource limit, it means that the resources currently used and requested have exceeded the limit, and the flow limiting result is limited flow. Among them, the resource limit is a pre-configured limit.

[0110] The second type: Both the local tree and the remote tree include root nodes and leaf nodes.

[0111] The request count of the root node of the local tree is the sum of the request counts of each leaf node. The usage count of the root node of the remote tree is the sum of the usage counts of each leaf node.

[0112] The request count of the root node of the local tree and the usage count of the root node of the remote tree can reflect the sum of the currently used and requested resources. The resource call request obtained by the server includes information about target available resources and information about target services.

[0113] Calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count. The second count is a count for the target available resources that are currently used and requested. Compare the second count with the root limit. The root limit is a preset limit for the count of the root node, and the root limit can be used to limit resources for the target available resources. The root limit is used to indicate the total amount limit for the target available resources. If the second count is less than the root limit, it means that the target available resources that are currently used and requested do not exceed the total amount limit, and the current limiting result is current limiting. If the second count is greater than or equal to the root limit, it means that the target available resources that are currently used and requested have exceeded the limit, and the current limiting result is current limiting.

[0114] The third type: Both the local tree and the remote tree include root nodes and leaf nodes.

[0115] The request count of the root node of the local tree is the sum of the request counts of each leaf node. The usage count of the root node of the remote tree is the sum of the usage counts of each leaf node.

[0116] The request count of the root node of the local tree and the usage count of the root node of the remote tree can reflect the sum of the currently used and requested resources. The resource call request obtained by the server includes information about target available resources and information about target services.

[0117] The sum of the request count of the root node corresponding to the target available resource of the local tree and the request count of the root node corresponding to the target available resource of the remote tree is calculated to obtain a second count, which is a count of the currently used and requested target available resources.

[0118] The request count of the leaf node corresponding to the target service of the local tree is calculated, and the sum of the request count of the leaf node corresponding to the target service of the remote tree is calculated to obtain a third count. The third count is the count of the target service currently used and requested.

[0119] The second count is compared with the root limit of the root node corresponding to the target available resource, and the third count is compared with the leaf limit of the leaf node corresponding to the target service.

[0120] The root limit is a limit preset for the count of the root node corresponding to the target available resource, and the root limit can be used to limit the target available resource. The root limit is used to indicate the total limit for the target available resource. The leaf limit is a limit preset for the count of the leaf node corresponding to the target business that calls the target available resource, and the leaf limit can be used to limit the target business. The leaf limit is used to indicate the limit on calling the target available resource for the target business.

[0121] If the second count is less than the root limit, and the third count is less than the leaf limit, it means that the target available resources currently used and requested by the current target business do not exceed the limit, and the flow limiting result is no flow limiting. If the second count is greater than or equal to the root limit, it means that the target available resources currently used and requested exceed the limit, and the flow limiting result is flow limiting. If the third count is greater than or equal to the leaf limit, it means that the target available resources currently used and requested by the target business exceed the limit, and the flow limiting result is flow limiting. The root limit and leaf limit can be used to implement flow limiting control in two dimensions: resources and business, and to implement flow limiting in scenarios where multiple business requests call the same resource.

[0122] It should be noted that, as an implementation method, the root limit and the leaf limit can be pre-configured fixed values. The root limit and the leaf limit can be configured based on the flow limiting needs of resources and services. As another implementation method, the existence duration of the local tree and the remote tree is a flow limiting unit duration. The root limit and the leaf limit of each leaf node are determined based on the resource request count of the local tree and the resource usage count of the remote tree within the historical flow limiting unit duration. Among them, the root limit is the sum of the leaf limits of each leaf node. The historical flow limiting unit duration is specifically, for example, the previous flow limiting unit duration of the current flow limiting unit duration, or the previous multiple flow limiting unit durations. Based on the resource request count of the local tree and the resource usage count of the remote tree within the historical flow limiting unit duration, the request and usage of resources within the historical flow limiting unit duration can be determined, and then the specific values ​​of the root limit and the leaf limit within the current flow limiting unit duration can be determined.

[0123] As an example, based on the resource request count of the local tree and the resource usage count of the remote tree within the historical flow limiting unit time, if it can be determined that there is no flow limiting, the root limit and the leaf limit within the current flow limiting unit time can be left unchanged, or the values ​​of the root limit and the leaf limit within the current flow limiting unit time can be reduced. If it can be determined that there is flow limiting, the values ​​of the root limit and the leaf limit within the current flow limiting unit time can be increased. The increased value can be a preset increase step, or an increase step corresponding to the value of the resource request count of the local tree and the resource usage count of the remote tree exceeding the limit within the historical flow limiting unit time.

[0124] Furthermore, the priorities of available resources for different business requests may be different, and each leaf node included in the local tree has the priority of the available resources for the corresponding business requests. After determining the root quota, the leaf quota of each leaf node is determined according to the priority of each leaf node. In a possible implementation, the leaf quota of a leaf node is positively correlated with the priority of the leaf node. A leaf quota with a higher priority is higher. A leaf quota with a lower priority is lower.

[0125] In another possible implementation, resource usage and request requirements of leaf nodes with higher priorities are met first, and then resource usage and request requirements of leaf nodes with lower priorities are configured. For leaf nodes with the same priority, the leaf quotas of the leaf nodes can be the same.

[0126] As an example, see Figure 6 As shown, the figure is a schematic diagram of quota allocation of a local tree provided by an embodiment of the present application. The root node includes 4 leaf nodes. The root quota of the root node is 10000. The highest priority of leaf node 1 is level 1, the second highest priority of leaf node 2 and leaf node 3 is level 2, and the lowest priority of leaf node 4 is level 3. The sum of the resource request count and resource usage count within the historical flow limiting unit time of leaf node 1 is 7000, that is, the demand for calling resources within the historical flow limiting unit time of leaf node 1 is 7000. The sum of the resource request count and resource usage count within the historical flow limiting unit time of leaf node 2 is 2500. The sum of the resource request count and resource usage count within the historical flow limiting unit time of leaf node 3 is 1500. The sum of the resource request count and resource usage count within the historical flow limiting unit time of leaf node 4 is 1000. A leaf quota of 7000 is allocated to leaf node 1. Leaf quotas of 1500 are allocated to leaf nodes 2 and 3 respectively. Assign a leaf quota of 0 to leaf node 3.

[0127] Using priorities to determine leaf quotas can achieve dynamic allocation of leaf quotas. The leaf quotas obtained in this way can better meet the needs of business request resources, achieve reasonable allocation of quotas, and make greater use of limited resources.

[0128] Furthermore, it should be noted that the method for determining whether the limit is exceeded by using the limit provided in the embodiment of the present application can reduce the occurrence of premature current limiting, reduce the possibility of misjudgment of current limiting, and improve the accuracy of current limiting.

[0129] The above is a specific implementation method for the server of the flow control cluster to determine whether the limit is exceeded and determine the limit. In some implementations, the server included in the flow control cluster sends the local tree of the server to the database cluster at a certain frequency. The embodiment of the present application does not limit the specific value of the frequency of sending the local tree. For example, when the flow limit unit duration is 10 seconds, the frequency is to send the local tree once every 200 milliseconds.

[0130] The local tree sent by the server to the database cluster is used to update the resource usage count of the database tree of the database cluster.

[0131] Correspondingly, the embodiment of the present application also provides a flow control processing method applied to a database cluster. The database cluster is connected to the flow control cluster. Figure 7 As shown in FIG. 1 , this figure is a flow chart of a current limiting processing method applied to a database cluster provided in an embodiment of the present application, such as Figure 7 As shown, the method may include S701-S703.

[0132] S701: Acquire a local tree sent by a server included in a traffic control cluster.

[0133] The flow control cluster includes multiple servers. Each server included in the flow control cluster sends a local tree to the database cluster at a certain frequency. The database cluster obtains the local tree sent by each server.

[0134] S702: Use the local tree to update the database tree, where the resource usage count of the database tree is the sum of the resource request counts of the local trees of each server.

[0135] The database cluster pre-establishes a database tree. As an example, a database tree is established for each type of available resources. The resource usage count of the database tree is used to count the resources that have been used based on the flow control cluster. The resource usage count of the database tree is obtained by superimposing the resource request counts of the local trees of each server obtained by the database cluster. In other words, the database tree is accumulated by the local trees obtained by the database cluster. For local trees and database trees of servers with different structures, the method of updating the database tree is different. The embodiments of the present application provide two methods for updating the database tree, please see below.

[0136] S703: Send the database tree to the servers included in the traffic control cluster.

[0137] The database cluster can also send database trees to servers in the flow control cluster, so that the server can use the obtained database tree to update the server's remote tree.

[0138] In one possible implementation, a server of the flow control cluster sends a query request to the database cluster. In response to the query request for obtaining a database tree, the database cluster feeds back the database tree to the server. In another possible implementation, a frequency at which the database cluster sends the database tree is preconfigured. The database cluster sends the database tree to each server of the flow control cluster according to the frequency.

[0139] Based on S701-S703, it can be seen that the flow control cluster and the database cluster interact to achieve the decoupling of the flow control processing and the services provided by the database cluster. In this way, the stability of the database cluster does not affect the stability of the flow control processing, and a relatively stable flow control processing is achieved.

[0140] In a possible implementation, the local tree and the database tree include only one node. The database tree is updated using the local tree, specifically by adding up the resource request counts of each local tree to obtain the resource usage count of the database tree.

[0141] In another possible implementation, the local tree includes a root node and a plurality of leaf nodes. The resource request count of the local tree includes the request count of the root node of the local tree and the request count of each leaf node of the local tree. The request count of the root node is the sum of the request counts of each leaf node. Correspondingly, the database tree includes a root node and a plurality of leaf nodes. Each node of the database tree corresponds one-to-one to each node of the local tree. The resource usage count of the database tree includes the usage count of the root node of the database tree and the usage count of each leaf node of the database tree. The usage count of the root node of the database tree is the sum of the usage counts of the leaf nodes of each database tree.

[0142] In the case that both the local tree and the database tree include a root node and leaf nodes, the database tree is updated using the local tree, including updating the usage count of the root node of the database tree and updating the usage count of each leaf node.

[0143] For updating the usage count of the root node of the database tree, the request counts of the root nodes of each local tree and the sum of the historical usage counts of the root node of the database tree are calculated to obtain the usage count of the root node of the updated database tree. It should be noted that, as an example, the initial usage count of the root node of the initially created database tree is the initial value. The initial value is, for example, 0.

[0144] For the update of the usage count of each leaf node of the database tree, the historical usage count of the leaf node of the database tree and the sum of the request counts of the corresponding leaf nodes of each local tree are calculated to obtain the usage count of the target leaf node of the updated database tree. It should be noted that, as an example, the initial usage count of each leaf node of the initially created database tree is the initial value. The initial value is, for example, 0.

[0145] Based on the current limiting processing method for a server of a flow control cluster provided in the above method embodiment, the present application embodiment also provides a current limiting processing device for a server of a flow control cluster. The device is applied to a server included in the flow control cluster, and the flow control cluster is respectively connected to a database cluster and at least one service cluster. The current limiting processing device for a server of a flow control cluster will be described below in conjunction with the accompanying drawings.

[0146] See also Figure 8 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a flow limiting processing device for a server in a flow control cluster provided by an embodiment of the present application. Figure 8 As shown, the flow limiting processing device applied to the server of the flow control cluster includes:

[0147] The acquisition unit 801 is used to acquire the resource call request sent by the service cluster and modify the resource request count of the local tree of the server;

[0148] A determination unit 802 is used to determine a flow limiting result by using a resource request count of the local tree and a resource usage count of a remote tree of the server, wherein the resource usage count of the remote tree is determined based on a resource usage count of a database tree of the database cluster, and the resource usage count is a sum of resource request counts of local trees of various servers included in the flow control cluster obtained by the database cluster;

[0149] The feedback unit 803 is used to feed back the current limiting result to the service cluster that sends the resource call request.

[0150] In one possible implementation, the local tree and the remote tree each include only one node, and the determination unit 802 is specifically used to calculate the sum of the resource request count of the local tree and the resource usage count of the remote tree to obtain a first count; if the first count is less than the resource limit, the flow limiting result is no flow limiting; if the first count is greater than or equal to the resource limit, the flow limiting result is flow limiting.

[0151] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the root node corresponds to available resources, the leaf nodes correspond to services requesting to call the available resources, the resource request count includes the request count of the root node of the local tree and the request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the remote tree includes a root node and multiple leaf nodes, each node of the local tree corresponds one-to-one to each node of the remote tree, the resource usage count of the remote tree includes the usage count of the root node of the remote tree and the usage count of each of the leaf nodes of the remote tree, the usage count of the root node of the remote tree is the sum of the usage counts of each of the leaf nodes of the remote tree.

[0152] In a possible implementation, the number of resource call requests is 1, the resource call request includes information about target available resources and information about target services, and the acquisition unit 801 is used to modify the resource request count of the local tree of the server, including:

[0153] The acquisition unit 801 is used to increase the request count of the root node corresponding to the target available resource included in the local tree by 1, and increase the request count of the leaf node corresponding to the target service included in the root node corresponding to the target available resource by 1.

[0154] In a possible implementation, the determination unit 802 is specifically configured to calculate the sum of the request count of the root node corresponding to the target available resource of the local tree and the request count of the root node corresponding to the target available resource of the remote tree to obtain a second count; if the second count is less than the root limit of the root node corresponding to the target available resource, the flow limiting result is no flow limiting. If the second count is greater than or equal to the root limit of the root node corresponding to the target available resource, the flow limiting result is flow limiting.

[0155] In a possible implementation, the determination unit 802 is specifically used to calculate the sum of the request count of the root node corresponding to the target available resources of the local tree and the request count of the root node corresponding to the target available resources of the remote tree to obtain a second count; calculate the request count of the leaf node corresponding to the target business of the local tree and the sum of the leaf node corresponding to the target business of the remote tree to obtain a third count of the leaf node corresponding to the target business; if the second count is less than the root limit of the root node corresponding to the target available resources, and the third count is less than the leaf limit of the leaf node corresponding to the target business, the flow limiting result is no flow limiting; if the second count is greater than or equal to the root limit of the root node corresponding to the target available resources, or the third count is greater than or equal to the leaf limit of the leaf node corresponding to the target business, the flow limiting result is flow limiting.

[0156] In one possible implementation, the existence duration of the local tree and the remote tree is a current limiting unit duration, the root limit and the leaf limits of each leaf node are determined based on the resource request count of the local tree and the resource usage count of the remote tree within the historical current limiting unit duration, and the root limit is the sum of the leaf limits of each leaf node.

[0157] In a possible implementation, each leaf node included in the local tree has a priority, and the leaf quota of each leaf node is determined based on the root quota and the priority of each leaf node, and the leaf quota of the leaf node is positively correlated with the priority of the leaf node.

[0158] In a possible implementation manner, the device further includes:

[0159] A sending unit is used to send the local tree of the server to the database cluster at a first frequency, and the local tree of the server is used to update the resource usage count of the database tree of the database cluster.

[0160] In a possible implementation manner, the device further includes:

[0161] An updating unit is used to obtain the database tree at a second frequency, and update the remote tree of the server using the database tree.

[0162] Based on the current limiting processing method applied to a database cluster provided by the above method embodiment, the present application embodiment also provides a current limiting processing device applied to a database cluster. The device is applied to a database cluster, and the database cluster is connected to a flow control cluster. The current limiting processing device applied to a database cluster will be described below in conjunction with the accompanying drawings.

[0163] See also Fig. 9 As shown in FIG. 1 , this figure is a schematic diagram of the structure of a current limiting processing device applied to a database cluster provided in an embodiment of the present application. Fig. 9 As shown, the current limiting processing device applied to the database cluster includes:

[0164] An acquiring unit 901 is used to acquire a local tree sent by a server included in the traffic control cluster;

[0165] An updating unit 902, configured to update a database tree using the local tree, wherein the resource usage count of the database tree is the sum of the resource request counts of the local trees of the respective servers;

[0166] The sending unit 903 is configured to send the database tree to the server included in the traffic control cluster.

[0167] In a possible implementation, the local tree and the database tree include only one node, and the updating unit 902 is specifically configured to add the resource request counts of the local trees to obtain the resource usage count of the database tree.

[0168] In one possible implementation, the local tree includes a root node and multiple leaf nodes, the resource request count includes a request count of the root node of the local tree and a request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the database tree includes a root node and multiple leaf nodes, each node of the database tree corresponds one-to-one to each node of the local tree, the resource usage count of the database tree includes a usage count of the root node of the database tree and a usage count of each of the leaf nodes of the database tree, the usage count of the root node of the database tree is the sum of the usage counts of each of the leaf nodes of the database tree.

[0169] In a possible implementation, the update unit 902 is specifically used to calculate the request count of the root node of each of the local trees and the sum of the historical usage counts of the root node of the database tree to obtain the usage count of the root node of the database tree after update; calculate the historical usage count of the target leaf node of the database tree and the sum of the request counts of the leaf nodes of each of the local trees corresponding to the target leaf node of the database tree to obtain the usage count of the target leaf node of the database tree after update, where the target leaf node of the database tree is one of the leaf nodes included in the database tree.

[0170] Based on the current limiting processing method applied to the server of the traffic control cluster and the current limiting processing method applied to the database cluster provided in the above method embodiments, the present application also provides an electronic device, including: one or more processors; a storage device, on which one or more programs are stored, when the one or more programs are executed by the one or more processors, the one or more processors implement the current limiting processing method applied to the server of the traffic control cluster or the current limiting processing method applied to the database cluster as described in any of the above embodiments.

[0171] Reference below Fig.10, which shows a schematic diagram of the structure of an electronic device 1000 suitable for implementing the embodiment of the present application. The terminal device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (portable android devices), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs (televisions), desktop computers, etc. Fig.10 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0172] like Fig.10 As shown, the electronic device 1000 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for the operation of the electronic device 1000 are also stored. The processing device 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0173] Typically, the following devices may be connected to the I / O interface 1005: an input device 1008 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 1007 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 1008 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 may allow the electronic device 1000 to communicate with other devices wirelessly or by wire to exchange data. Although Fig.10 The electronic device 1000 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0174] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 1009, or installed from the storage device 1008, or installed from the ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment of the present application are executed.

[0175] The electronic device provided in the embodiment of the present application and the current limiting processing method applied to the server of the traffic control cluster or the current limiting processing method applied to the database cluster provided in the above-mentioned embodiment belong to the same inventive concept. The technical details not fully described in this embodiment can be referred to the above-mentioned embodiment, and this embodiment has the same beneficial effects as the above-mentioned embodiment.

[0176] Based on the current limiting processing method applied to the server of the traffic control cluster and the current limiting processing method applied to the database cluster provided in the above method embodiments, an embodiment of the present application provides a computer storage medium on which a computer program is stored, wherein when the program is executed by a processor, the current limiting processing method applied to the server of the traffic control cluster or the current limiting processing method applied to the database cluster as described in any of the above embodiments is implemented.

[0177] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution device or device. The program code contained on the computer readable medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0178] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (Hyper Text Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0179] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0180] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device executes the above-mentioned current limiting processing method applied to the server of the traffic control cluster or the current limiting processing method applied to the database cluster.

[0181] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0182] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0183] The units involved in the embodiments described in this application may be implemented by software or hardware. The name of a unit / module does not limit the unit itself in some cases. For example, a voice data acquisition module may also be described as a "data acquisition module".

[0184] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

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

[0186] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referred to each other. For the system or device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0187] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0188] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0189] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0190] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A current limiting processing method, characterized in that: The method is applied to a server included in a traffic control cluster, wherein the traffic control cluster is respectively connected to a database cluster and at least one service cluster, and the method includes: Obtaining a resource call request sent by the service cluster, and modifying a resource request count of a local tree of the server; Determine the flow limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server, wherein the resource usage count of the remote tree is determined based on the resource usage count of the database tree of the database cluster, and the resource usage count is the sum of the resource request counts of the local trees of the servers included in the flow control cluster acquired by the database cluster; Feedback the current limiting result to the service cluster that sent the resource call request.

2. The method according to claim 1, characterized in that The local tree and the remote tree each include only one node, and the determining of the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes: Calculate the sum of the resource request count of the local tree and the resource usage count of the remote tree to obtain a first count; If the first count is less than the resource limit, the flow limiting result is no flow limiting; If the first count is greater than or equal to the resource limit, the current limiting result is current limiting.

3. The method according to claim 1, characterized in that The local tree includes a root node and multiple leaf nodes, the root node corresponds to available resources, the leaf nodes correspond to services requesting to call the available resources, the resource request count includes the request count of the root node of the local tree and the request count of each of the leaf nodes of the local tree, the request count of the root node is the sum of the request counts of each of the leaf nodes, the remote tree includes a root node and multiple leaf nodes, each node of the local tree corresponds one-to-one to each node of the remote tree, the resource usage count of the remote tree includes the usage count of the root node of the remote tree and the usage count of each of the leaf nodes of the remote tree, the usage count of the root node of the remote tree is the sum of the usage counts of each of the leaf nodes of the remote tree.

4. The method according to claim 3, characterized in that: The number of resource call requests is 1, the resource call request includes information of target available resources and information of target services, and the resource request count of modifying the local tree of the server includes: The request count of the root node corresponding to the target available resource included in the local tree is increased by 1, and the request count of the leaf node corresponding to the target service included in the root node corresponding to the target available resource is increased by 1.

5. The method according to claim 4, characterized in that The determining of the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes: Calculate the sum of the request count of the root node corresponding to the target available resource of the local tree and the request count of the root node corresponding to the target available resource of the remote tree to obtain a second count; If the second count is less than the root limit of the root node corresponding to the target available resource, the flow limiting result is no flow limiting; If the second count is greater than or equal to the root limit of the root node corresponding to the target available resource, the current limiting result is current limiting.

6. The method according to claim 4, characterized in that The determining of the current limiting result by using the resource request count of the local tree and the resource usage count of the remote tree of the server includes: Calculate the sum of the request count of the root node corresponding to the target available resource of the local tree and the request count of the root node corresponding to the target available resource of the remote tree to obtain a second count; Calculate the request count of the leaf node corresponding to the target business of the local tree and the sum of the request count of the leaf node corresponding to the target business of the remote tree to obtain a third count of the leaf node corresponding to the target business; If the second count is less than the root limit of the root node corresponding to the target available resource, and the third count is less than the leaf limit of the leaf node corresponding to the target service, the flow limiting result is no flow limiting; If the second count is greater than or equal to the root limit of the root node corresponding to the target available resource, or the third count is greater than or equal to the leaf limit of the leaf node corresponding to the target service, the flow limiting result is flow limiting.

7. The method according to claim 3, characterized in that The existence duration of the local tree and the remote tree is a current limiting unit duration. The root limit and the leaf limits of each leaf node are determined based on the resource request count of the local tree and the resource usage count of the remote tree within the historical current limiting unit duration. The root limit is the sum of the leaf limits of each leaf node.

8. The method according to claim 7, characterized in that Each leaf node included in the local tree has a priority, and the leaf quota of each leaf node is determined based on the root quota and the priority of each leaf node. The leaf quota of the leaf node is positively correlated with the priority of the leaf node.

9. The method according to claim 1, characterized in that: The method further comprises: The local tree of the server is sent to the database cluster at a first frequency, and the local tree of the server is used to update the resource usage count of the database tree of the database cluster.

10. The method according to claim 1, characterized in that The method further comprises: The database tree is obtained at a second frequency, and the remote tree of the server is updated using the database tree.

11. A current limiting processing method, characterized in that: The method is applied to a database cluster, the database cluster is connected to a traffic control cluster, and the method includes: Obtaining a local tree sent by a server included in the flow control cluster; Using the local tree to update the database tree, the resource usage count of the database tree is the sum of the resource request counts of the local trees of the respective servers; The database tree is sent to a server included in the traffic control cluster.

12. The method according to claim 11, characterized in that The local tree and the database tree include only one node, and the updating of the database tree using the local tree includes: The resource request counts of the local trees are added together to obtain the resource usage count of the database tree.

13. The method according to claim 11, characterized in that The local tree includes a root node and multiple leaf nodes, the resource request count includes the request count of the root node of the local tree and the request count of each leaf node of the local tree, the request count of the root node is the sum of the request counts of each leaf node, the database tree includes a root node and multiple leaf nodes, each node of the database tree corresponds one-to-one to each node of the local tree, the resource usage count of the database tree includes the usage count of the root node of the database tree and the usage count of each leaf node of the database tree, the usage count of the root node of the database tree is the sum of the usage counts of each leaf node of the database tree.

14. The method according to claim 13, characterized in that The method of updating the database tree by using the local tree comprises: Calculate the request count of the root node of each local tree and the sum of the historical usage count of the root node of the database tree to obtain the updated usage count of the root node of the database tree; Calculate the historical usage count of the target leaf node of the database tree and the sum of the request counts of the leaf nodes of each local tree corresponding to the target leaf node of the database tree to obtain the usage count of the updated target leaf node of the database tree, where the target leaf node of the database tree is one of the leaf nodes included in the database tree.

15. A current limiting processing device, characterized in that: The device is applied to a server included in a traffic control cluster, the traffic control cluster is respectively connected to a database cluster and at least one service cluster, and the device includes: An acquisition unit, configured to acquire a resource call request sent by the service cluster and modify a resource request count of a local tree of the server; A determination unit, configured to determine a flow limiting result by using a resource request count of the local tree and a resource usage count of a remote tree of the server, wherein the resource usage count of the remote tree is determined based on a resource usage count of a database tree of the database cluster, and the resource usage count is a sum of resource request counts of local trees of various servers included in the flow control cluster acquired by the database cluster; A feedback unit is used to feed back the current limiting result to the service cluster that sends the resource call request.

16. A current limiting processing device, characterized in that: The device is applied to a database cluster, the database cluster is connected to a flow control cluster, and the device includes: An acquisition unit, configured to acquire a local tree sent by a server included in the flow control cluster; An updating unit, configured to update a database tree using the local tree, wherein the resource usage count of the database tree is the sum of the resource request counts of the local trees of the respective servers; A sending unit is used to send the database tree to the server included in the traffic control cluster.

17. An electronic device, characterized in that: include: one or more processors; A storage device having one or more programs stored thereon, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the current limiting processing method as described in any one of claims 1-10, or the current limiting processing method as described in any one of claims 11-14.

18. A computer readable medium, characterized in that A computer program is stored thereon, wherein when the program is executed by a processor, the current limiting processing method according to any one of claims 1 to 10 or the current limiting processing method according to any one of claims 11 to 14 is implemented.