Flow control method and device, electronic device, and storage medium

By combining local and global token buckets in a cloud computing environment and using RDMA technology for communication, the high latency problem of distributed token bucket algorithms is solved, achieving more efficient token synchronization and service volume control.

CN119728564BActive Publication Date: 2026-05-01CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CLOUD TECH CO LTD
Filing Date
2024-11-25
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing distributed token bucket algorithms require multiple communications to synchronize token information in cloud computing environments, resulting in high latency, making it difficult to meet the rapidly evolving service processing capacity requirements, and impacting overall service performance.

Method used

By establishing a data connection between the client and the server, combining the local token bucket and the global token bucket, and using RDMA technology for communication, the number of communications during token synchronization is reduced. Tokens are acquired through the RDMA FAA primitive, and dynamically allocated based on the remaining number of tokens in the token bucket data structure and system pressure information.

Benefits of technology

This reduces the latency of token synchronization, improving overall service performance and the fairness and accuracy of service volume control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728564B_ABST
    Figure CN119728564B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a flow control method and device, electronic equipment and storage medium, which are applied to a client and the client is provided with a local token bucket, a data connection between the client and a server provided with a global token bucket is established, then in the case that tokens in the local token bucket are consumed, first residual token quantity information of the global token bucket is acquired from the server according to the data connection, and a first token acquisition target quantity is determined according to the first residual token quantity information, and then the first token acquisition target quantity and a token acquisition mode in the global token bucket are used according to the data connection. The number of communications required for token synchronization is reduced by combining the global token bucket and the local token bucket, and the residual token quantity information is introduced into the data structure of the global token bucket, and the dynamic allocation of tokens is realized, which further reduces the delay of token synchronization and improves the performance of the overall service.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of cloud computing technology, and in particular to a flow control method and apparatus, electronic device, and storage medium. Background Technology

[0002] Token bucket technology is a common traffic management technique, which can be viewed as a traffic control and rate limiting algorithm widely used in network transmission and service rate limiting. Its core idea is to control the data transmission rate by simulating a "bucket," ensuring data is transmitted smoothly and controllably while allowing for a certain degree of burst data processing.

[0003] The distributed token bucket algorithm is an extension of the traditional token bucket principle, designed to address the need for unified management and control of service volume across multiple nodes in a distributed system. In a distributed environment, each node maintains its own token bucket and synchronizes token information over the network to ensure the fairness and accuracy of overall service volume control.

[0004] However, the distributed token bucket algorithm in related technologies requires multiple communications to synchronize token information, resulting in high latency. This makes it difficult to meet the ever-increasing demand for service processing capabilities as cloud computing services rapidly develop, thus affecting the overall service performance. Summary of the Invention

[0005] In view of the above problems, a flow control method, apparatus, electronic device, and storage medium are proposed to overcome or at least partially solve the above problems, including:

[0006] A flow control method, applied to a client, wherein the client has a local token bucket, the method comprising:

[0007] Establish a data connection between the client and the server; wherein the server is configured with a global token bucket;

[0008] When the tokens in the local token bucket are exhausted, the server obtains the first remaining token quantity information of the global token bucket from the server through the data connection, and determines the first target quantity of tokens to be obtained based on the first remaining token quantity information; wherein, the server is further configured to determine the first remaining token quantity information, and send the first remaining token quantity information to the client through the data connection when the tokens in the local token bucket are exhausted.

[0009] Through the data connection, the target number is obtained based on the first token, and the token is retrieved from the global token bucket.

[0010] Optionally, the method further includes:

[0011] If the tokens in the local token bucket are not exhausted, in response to a token acquisition request, the server obtains the pressure information of the global token bucket from the server according to the data connection; wherein, the server is further configured to determine the pressure information, and if the tokens in the local token bucket are not exhausted and the client has a token acquisition request, the server sends the pressure information to the client according to the data connection.

[0012] Determine the second remaining token quantity information in the local token bucket, and based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information, determine the second token acquisition target quantity;

[0013] Based on the second token, obtain the target number and connect it to the data, and then obtain the token from the global token bucket.

[0014] Optionally, the data connection is a remote direct memory access data connection.

[0015] A flow control method, applied to a server, wherein the server is configured with a global token bucket, the method comprising:

[0016] Establish a data connection between the server and the client; wherein the client has a local token bucket.

[0017] The system determines the first remaining token quantity information of the global token bucket, and sends the first remaining token quantity information to the client via the data connection when the tokens in the local token bucket are exhausted; wherein, the client is further configured to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server via the data connection, and determine the first token acquisition target quantity based on the first remaining token quantity information; and acquire the tokens from the global token bucket via the data connection based on the first token acquisition target quantity.

[0018] Optionally, the method further includes:

[0019] The system determines the pressure information of the global token bucket, and sends the pressure information to the client via the data connection when the tokens in the local token bucket are not exhausted and the client has a token acquisition requirement; wherein, the client is further configured to, in response to the token acquisition requirement when the tokens in the local token bucket are not exhausted, obtain the pressure information from the server via the data connection; determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information; and obtain the token from the global token bucket based on the second token acquisition target quantity and the data connection.

[0020] Optionally, the method further includes:

[0021] Update the first remaining token quantity information based on the target quantity obtained from the first token or the target quantity obtained from the second token.

[0022] Optionally, the method further includes:

[0023] Based on the updated first remaining token quantity information, the first token acquisition target quantity, and the second token acquisition target quantity, the pressure information is updated.

[0024] Optionally, the global token bucket is provided with a redundancy bit, which is used to provide additional tokens when the global token bucket is over-consumed.

[0025] A flow control device is applied to a client, the client having a local token bucket, the device comprising:

[0026] The first data connection establishment module is used to establish a data connection between the client and the server; wherein the server is equipped with a global token bucket.

[0027] The first token acquisition target quantity determination module is used to obtain the first remaining token quantity information of the global token bucket from the server according to the data connection when the tokens in the local token bucket are exhausted, and to determine the first token acquisition target quantity according to the first remaining token quantity information; wherein, the server is further used to determine the first remaining token quantity information, and when the tokens in the local token bucket are exhausted, to send the first remaining token quantity information to the client according to the data connection.

[0028] The first token acquisition module is used to acquire the token from the global token bucket based on the target number of the first token acquisition and the data connection.

[0029] A flow control device is applied to a server, wherein the server is equipped with a global token bucket, and the device includes:

[0030] The second data connection establishment module is used to establish a data connection between the server and the client; wherein the client has a local token bucket.

[0031] The first remaining token quantity information determination module is used to determine the first remaining token quantity information of the global token bucket, and when the tokens in the local token bucket are exhausted, send the first remaining token quantity information to the client according to the data connection; wherein, the client is further used to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server according to the data connection, and determine the first token acquisition target quantity based on the first remaining token quantity information; and obtain the tokens from the global token bucket according to the first token acquisition target quantity through the data connection.

[0032] An electronic device includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the flow control method as described above.

[0033] A computer-readable storage medium is characterized in that a computer program is stored on the computer-readable storage medium, and the computer program, when executed by a processor, implements the flow control method as described above.

[0034] A computer program product includes a computer program that, when executed by a processor, implements the flow control method described above.

[0035] The embodiments of the present invention have the following advantages:

[0036] This invention provides a flow control method applied to a client-side application with a local token bucket. A data connection is established between the client and a server with a global token bucket. When the local token bucket is depleted, the method retrieves the first remaining token quantity information from the server based on the data connection, and determines a target number of tokens to acquire. Finally, tokens are acquired from the global token bucket based on the target number and the data connection. This method reduces the number of communications required for token synchronization by combining the global and local token buckets. Furthermore, by introducing remaining token quantity information into the global token bucket's data structure, it enables dynamic token allocation, further reducing token synchronization latency, improving overall service performance, and enhancing the fairness and accuracy of overall service volume control. Attached Figure Description

[0037] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a flowchart of the steps of a flow control method provided in some embodiments of the present invention;

[0039] Figure 2 These are example diagrams illustrating the data structure of the global token bucket provided in some embodiments of the present invention;

[0040] Figure 3 This is an example diagram of a distributed QoS interaction process provided in some embodiments of the present invention;

[0041] Figure 4 This is a flowchart of the steps of a flow control method provided in some embodiments of the present invention;

[0042] Figure 5 This is a schematic diagram of the structure of a flow control device provided in some embodiments of the present invention;

[0043] Figure 6 This is a schematic diagram of the structure of a flow control device provided in some embodiments of the present invention. Detailed Implementation

[0044] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0045] In the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect, only for the purpose of clearly describing the technical solution of the embodiments of this application, and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated.

[0046] In the embodiments of this application, the terms "upper" and "lower" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.

[0047] Token bucket technology is a common traffic management technique, which can be viewed as a traffic control and rate limiting algorithm, widely used in network transmission and service rate limiting. Its core idea is to control the data transmission rate by simulating a "bucket," ensuring data is transmitted smoothly and controllably while allowing for a certain degree of burst data processing.

[0048] The distributed token bucket algorithm is an extension of the traditional token bucket principle, designed to address the need for unified management and control of service volume across multiple nodes in a distributed system. In a distributed environment, each node maintains its own token bucket and synchronizes token information over the network to ensure the fairness and accuracy of overall service volume control.

[0049] However, the distributed token bucket algorithm in related technologies requires multiple communications to synchronize token information, resulting in high latency. This makes it difficult to meet the ever-increasing demand for service processing capabilities as cloud computing services rapidly develop, thus affecting the overall service performance.

[0050] To address the aforementioned problems, this invention, based on the core technical concept of reducing the number of communications required for token synchronization by combining a global token bucket and a local token bucket, improves upon the flow control methods in related technologies. The invention will be described in detail below with reference to the accompanying drawings:

[0051] Reference Figure 1 The diagram illustrates a flowchart of a flow control method according to some embodiments of the present invention, applied to a client. The client has a local token bucket and may specifically include the following steps:

[0052] Step 101: Establish a data connection between the client and the server; wherein the server is equipped with a global token bucket.

[0053] In the specific implementation, a data connection can be established between the client and the server, and a combination of a global token bucket and a local token bucket can be used. The server node can periodically generate tokens into the global token bucket, and each client node can periodically pull a certain number of tokens from the global token bucket to the local token bucket according to the data connection. After receiving a token acquisition request, each client can only consume the tokens in its own local token bucket. After consuming all the tokens, it can pull tokens from the global token bucket again.

[0054] In some embodiments of the present invention, the data connection is a remote direct memory access data connection.

[0055] For ease of explanation, the relevant terms involved in the embodiments of the present invention will be explained below:

[0056] RDMA (Remote Direct Memory Access) is a network communication technology designed to improve data transmission efficiency, especially in high-performance computing and data center environments.

[0057] One-Side RDMA (One-Side Remote Direct Memory Access): This is a type of RDMA communication primitive that allows data to be transferred directly between computer memories across a network without requiring data copying through the operating system or CPU, thereby greatly reducing data transmission latency and improving scalability.

[0058] Token bucket: A flow control and rate limiting algorithm widely used in network transmission and service rate limiting. Its core idea is to control the data transmission rate by simulating a "bucket," ensuring that data is transmitted in a smooth and controllable manner, while allowing a certain degree of burst data processing.

[0059] IOPS (Input / Output Operations Per Second) is an important metric for measuring the performance of computer storage devices. IOPS represents the number of read and write operations a storage device can complete per second, and is often used to evaluate the storage system's ability to handle random access requests.

[0060] Most existing distributed token buckets use the TCP / IP protocol stack for inter-node communication. Their communication latency is limited by the computing power of computing devices and the operating system, making it difficult to meet the ever-increasing demand for service processing capabilities as cloud computing services rapidly develop, thus affecting the overall service performance.

[0061] RDMA is a novel communication technology that offloads the transmission logic and protocol implementation to the RDMA network card hardware, thereby reducing the impact of the operating system and CPU on transmission and improving processing performance. Currently, RDMA mainly uses two types of communication primitives: one is similar to the SEND / RECV primitives of traditional RPC protocols, which still require the CPUs of both communicating parties to participate in the message sending and receiving process; the other is similar to memory operations, specifically One-Side RDMA operations, including READ, WRITE, CAS (Compare and Swap), and FAA (Fetch and Add). The first two are directly used for reading and writing to remote memory, while the latter two perform a set of atomic operations on a segment of remote memory. Because these One-Side RDMA operations do not require the participation of the peer's CPU and are directly performed by the DMA engine in the peer's network card, they have extremely low communication latency and good scalability.

[0062] Based on this, in specific implementations, data connections can be established using RDMA technology so that the corresponding communication process can be performed using RDMA FAA primitives, thereby reducing the latency of a single communication and improving the scalability of the system; specific application schemes will be described in subsequent embodiments.

[0063] Step 102: When the tokens in the local token bucket are exhausted, the server obtains the first remaining token quantity information of the global token bucket from the server through the data connection, and determines the first target quantity of tokens to be obtained based on the first remaining token quantity information; wherein, the server is further configured to determine the first remaining token quantity information, and send the first remaining token quantity information to the client through the data connection when the tokens in the local token bucket are exhausted.

[0064] In a practical implementation, the global token bucket's data structure can consist of two parts: one part stores the current remaining number of global tokens (tokens). g (i.e., the first remaining token quantity information), and another part is used to measure the overall stress of the system. Both parts can be stored together in a fixed-size memory block, which must be smaller than the memory size that RDMA FAA operations can operate on.

[0065] Each time a client obtains tokens from the global token bucket, it can directly use the RDMA FAA operation to subtract the number of tokens the client needs from the memory corresponding to the server node. The RDMA protocol guarantees the atomicity of the operation to prevent data inconsistency caused by concurrent modifications. After the operation is successful, the RDMA FAA will return the value of the corresponding memory before the operation, from which the client can obtain the system stress and the remaining tokens. g , token here g It will also contain a certain number of redundant bits, which are used to prevent the token from being compromised. g The value overflows after subtraction, thus affecting stress.

[0066] Based on this, when the local token bucket is exhausted, the first remaining token quantity information of the global token bucket can be obtained from the server via a data connection, and the first target number of tokens to be acquired can be determined based on the first remaining token quantity information. Specifically, in the first and subsequent cases where tokens are actively acquired due to the exhaustion of local tokens, the actual number of tokens to be acquired, i.e., the first target number of tokens to be acquired, can be determined according to the following formula:

[0067] token l =token g / client_amount×period

[0068] Among them, token l Obtain the target number of tokens for the first token. g This indicates the number of remaining tokens, where client_amount is the number of clients and period is the acquisition period.

[0069] In one example, taking the implementation of rate limiting for IOPS and bandwidth of shared cloud disks in a cloud disk service as an example, in this scenario, the tokens in this embodiment should be divided into two types, representing IOPS and bandwidth respectively. Each cloud disk IO request needs to obtain the corresponding token before it can be sent to the storage backend for execution. Assuming the maximum memory length of RDMA FAA operations is 64 bits, the data structure of the global token bucket in this embodiment is as follows: Figure 2As shown, the global token bucket data structure consists of three parts: IOPS and bandwidth tokens each occupy 20 bits to store the remaining token quantity in each round. To compress space, each IOPS token represents 100 IOs, and each bandwidth token represents 100 * 10240B (a single IO corresponds to 10240B of bandwidth). To prevent token overconsumption and interference, an additional 4 redundant bits are reserved for each token type as a buffer. These 4 bits can be set to 1 by default; if these 4 bits are not 1, it means that the tokens have been overconsumed. Therefore, the final allocation supports 2... 20 ×100 = 104,857,600 I / Os and 2 20 ×10240×100=1,000GiB bandwidth, which fully meets the specifications of existing shared disks.

[0070] Furthermore, the remaining 16 bits in the token bucket are used to represent the overall system stress. The position of 1 indicates the corresponding stress value. The higher the value, the greater the stress. The server updates this value periodically. The server will read the current number of tokens at a certain frequency, calculate the token decay rate to assess the overall system stress, and update the stress value to this position.

[0071] Furthermore, such as Figure 3 The diagram illustrates the interactive flow of distributed QoS (Quality of Service) for shared cloud disks implemented based on this embodiment. Figure 3 The server in the system is a central node responsible for handling all QoS requests for cloud disks. It initializes the corresponding global token bucket in its own memory for clients to consume. Figure 3 The client will be deployed on all nodes that have the shared cloud disk mounted. The overall process can be summarized as follows:

[0072] 1. Each time a shared cloud disk is mounted, the client will send a QoS request to the server via the RDMA SEND primitive. This request includes the IOPS and bandwidth values ​​to be set, as well as a registered address for the server to write the QoS information back.

[0073] 2. After receiving a request via RDMA and RECV, the server determines whether the disk has been mounted by another client. If not, it allocates a memory segment to store the disk's QoS information and registers the memory with the RDMA network card. If the disk is already mounted, it updates the QoS information. Then, based on the client information stored in the QoS information, the server uses the RDMAWRITE primitive to write the QoS information back to the pre-allocated memory on each client.

[0074] 3. After that, the client will periodically obtain tokens according to the QoS information. The first time and subsequent times it will actively obtain a token because its local token has been exhausted, it will obtain a token. l token l The confirmation formula is:

[0075] token1=token g / client_amount×period

[0076] Among them, token l To acquire the target number of tokens for the first token (in this embodiment, this is the number of tokens the client needs to actively acquire after exhausting its local tokens), token g The first remaining token quantity information (in this embodiment, the remaining token quantity in the global token bucket), client_amount is the number of clients, and period is the acquisition period; the client will read and reduce the token quantity in the global token bucket through the RDMA FAA primitive. Since IOPS and bandwidth are compressed into the same 64-bit memory and IOPS is stored in the 24-bit to 48-bit position, the token will eventually be subtracted from the global token bucket. l_iops <<24+token l_bw Among them, token l_iops The local quantity of IOPS tokens, token l_bw This represents the local quantity of bandwidth tokens. After a successful operation, the client will check the redundancy bit of the global token bucket. If the redundancy bit has a value of 0 or the global token bucket minus the number of tokens needed for this operation is less than 0, it means that the tokens have been exhausted. At the same time, the client will also record the global stress value.

[0077] 4. Subsequently, each time a client acquires a token, it also needs to consider the number of tokens remaining in the local token bucket (i.e., the second remaining token quantity information) and the overall pressure of the current global token bucket. The number of tokens to acquire (i.e., the second token acquisition target quantity) can be determined using the following formula:

[0078] token c =max(token) l -token r -λ×token r ,-token r )

[0079] λ=2 stress-8

[0080] token c To acquire the target number of tokens for the second token lTo acquire the target quantity of the first token, stress is the pressure information, λ is a coefficient determined based on the pressure information, and token r Information on the number of remaining tokens for the second time;

[0081] 5. The server also needs to periodically update the global token bucket and stress value. The global token bucket is generally updated once per second, while the stress value needs to be updated at a higher frequency. The stress value can be calculated and updated using the following formula:

[0082]

[0083] Where stress represents stress information, and token represents... last Obtain the target number of tokens for the first token. cur To acquire the target number of tokens for the second token g This is the information on the number of remaining tokens.

[0084] Step 103: Through the data connection, obtain the target number of tokens based on the first token, and then obtain the tokens from the global token bucket.

[0085] In practical applications, as mentioned earlier, taking the use of cloud disk services to implement rate limiting of IOPS and bandwidth of shared cloud disks as an example, each time a shared cloud disk is mounted, the client will send a QoS request to the server through the RDMASEND primitive. This request includes the IOPS and bandwidth values ​​to be set, as well as a registered address for the server to write back the QoS information.

[0086] After receiving a request via RDMA, RECV, the server checks if the disk has been mounted by another client. If not, it allocates memory to store the disk's QoS information and registers the memory with the RDMA network card. If the disk is mounted, it updates the QoS information. Then, based on the client information stored in the QoS information, the server uses the RDMAWRITE primitive to write the QoS information back to the pre-allocated memory on each client.

[0087] The client will then periodically request tokens according to QoS information. The first time it requests a token, and subsequent times when it actively requests a token because its local token has been exhausted, it will request a physical token. l token l The confirmation formula is:

[0088] token l =token g / client_amount×period

[0089] Among them, tokenl To acquire the target number of tokens for the first token (in this embodiment, this is the number of tokens the client needs to actively acquire after exhausting its local tokens), token g The first remaining token quantity information (in this embodiment, the remaining token quantity in the global token bucket), client_amount is the number of clients, and period is the acquisition period; the client will read and reduce the token quantity in the global token bucket through the RDMA FAA primitive.

[0090] In some embodiments of the present invention, the method further includes:

[0091] If the tokens in the local token bucket are not exhausted, in response to a token acquisition request, the server obtains the pressure information of the global token bucket from the server according to the data connection; wherein, the server is further configured to determine the pressure information, and if the tokens in the local token bucket are not exhausted and the client has a token acquisition request, the server sends the pressure information to the client according to the data connection.

[0092] Determine the second remaining token quantity information in the local token bucket, and based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information, determine the second token acquisition target quantity;

[0093] Based on the second token, obtain the target number and connect it to the data, and then obtain the token from the global token bucket.

[0094] In practical implementation, as mentioned earlier, taking the implementation of rate limiting for IOPS and bandwidth of shared cloud disks in cloud disk services as an example, after the client actively seeks to acquire tokens due to the depletion of local tokens for the first time, the client can record the global stress value. Subsequently, each time the client needs to acquire tokens when its local token bucket has not been depleted, it can consider the remaining token quantity in the local token bucket (i.e., the second remaining token quantity information) and the overall stress of the current global token bucket. The number of tokens to acquire (i.e., the second token acquisition target quantity) can be determined using the following formula:

[0095] token c =max(token) l -token r -λ×token r ,-token r )

[0096] λ=2 stress-8

[0097] token cTo acquire the target number of tokens for the second token l To acquire the target quantity of the first token, stress is the pressure information, λ is a coefficient determined based on the pressure information, and token r This is the information on the number of remaining tokens for the second time.

[0098] Reference Figure 4 The diagram illustrates a flowchart of a flow control method according to some embodiments of the present invention, applied to a server. The server is equipped with a global token bucket, and the method may specifically include the following steps:

[0099] Step 401: Establish a data connection between the server and the client; wherein the client has a local token bucket.

[0100] In the specific implementation, a data connection can be established between the client and the server, and a combination of a global token bucket and a local token bucket can be used. The server node can periodically generate tokens into the global token bucket, and each client node can periodically pull a certain number of tokens from the global token bucket to the local token bucket according to the data connection. After receiving a token acquisition request, each client can only consume the tokens in its own local token bucket. After consuming all the tokens, it can pull tokens from the global token bucket again.

[0101] Step 402: Determine the first remaining token quantity information of the global token bucket, and when the tokens in the local token bucket are exhausted, send the first remaining token quantity information to the client according to the data connection; wherein, the client is further configured to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server according to the data connection, and determine the first token acquisition target quantity based on the first remaining token quantity information; and acquire the tokens in the global token bucket according to the first token acquisition target quantity through the data connection.

[0102] In practical applications, the global token bucket's data structure can consist of two parts: one part stores the current remaining number of global tokens (tokens). g (i.e., the first remaining token quantity information), and another part is used to measure the overall stress of the system. Both parts can be stored together in a fixed-size memory block, which must be smaller than the memory size that RDMA FAA operations can operate on.

[0103] Each time a client obtains tokens from the global token bucket, it can directly use the RDMA FAA operation to subtract the number of tokens the client needs from the memory corresponding to the server node. The RDMA protocol guarantees the atomicity of the operation to prevent data inconsistency caused by concurrent modifications. After the operation is successful, the RDMA FAA will return the value of the corresponding memory before the operation, from which the client can obtain the system stress and the remaining tokens. g , token here g It will also contain a certain number of redundant bits, which are used to prevent the token from being compromised. g The value overflows after subtraction, thus affecting stress.

[0104] Based on this, when the local token bucket is exhausted, the first remaining token quantity information of the global token bucket can be obtained from the server via a data connection, and the first target number of tokens to be acquired can be determined based on the first remaining token quantity information. Specifically, in the first and subsequent cases where tokens are actively acquired due to the exhaustion of local tokens, the actual number of tokens to be acquired, i.e., the first target number of tokens to be acquired, can be determined according to the following formula:

[0105] token l =token g / client_amount×period

[0106] Among them, token l Obtain the target number of tokens for the first token. g This indicates the number of remaining tokens, where client_amount is the number of clients and period is the acquisition period.

[0107] In some embodiments of the present invention, the method further includes:

[0108] The system determines the pressure information of the global token bucket, and sends the pressure information to the client via the data connection when the tokens in the local token bucket are not exhausted and the client has a token acquisition requirement; wherein, the client is further configured to, in response to the token acquisition requirement when the tokens in the local token bucket are not exhausted, obtain the pressure information from the server via the data connection; determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information; and obtain the token from the global token bucket based on the second token acquisition target quantity and the data connection.

[0109] In practical applications, as mentioned earlier, taking the implementation of rate limiting for IOPS and bandwidth of shared cloud disks in cloud disk services as an example, after the client actively seeks to acquire tokens due to the depletion of its local tokens for the first time, the client can record the global stress value. Subsequently, each time the client needs to acquire tokens when its local token bucket has not been depleted, it can consider the remaining token quantity in the local token bucket (i.e., the second remaining token quantity information) and the overall stress of the current global token bucket. The number of tokens to acquire (i.e., the second target token acquisition quantity) can be determined using the following formula:

[0110] token c =max(token) l -token r -λ×token r ,-token r )

[0111] λ=2 stress-8

[0112] token c To acquire the target number of tokens for the second token l To acquire the target quantity of the first token, stress is the pressure information, λ is a coefficient determined based on the pressure information, and token r This is the information on the number of remaining tokens for the second time.

[0113] In some embodiments of the present invention, the global token bucket is provided with a redundant bit, which is used to provide additional tokens when the global token bucket is over-consumed.

[0114] In practical applications, the global token bucket's data structure can consist of two parts: one part stores the current remaining number of global tokens (tokens). g (i.e., the first remaining token quantity information), and another part is used to measure the overall stress of the system. Both parts can be stored together in a fixed-size memory block, which must be smaller than the memory size that RDMAFAA operations can operate on.

[0115] Each time a client obtains tokens from the global token bucket, it can directly use the RDMAFAA operation to subtract the number of tokens the client needs from the memory corresponding to the server node. The RDMA protocol guarantees the atomicity of the operation to prevent data inconsistency caused by concurrent modifications. After the operation is successful, RDMAFAA will return the value of the corresponding memory before the operation, from which the client can obtain the system stress and the remaining tokens. g , token here gIt also includes a certain number of redundant bits, which can be used to prevent token overconsumption by providing additional tokens when the global token bucket experiences excessive consumption. g The value overflows after subtraction, thus affecting stress.

[0116] In some embodiments of the present invention, the method further includes:

[0117] Update the first remaining token quantity information based on the target quantity obtained from the first token or the target quantity obtained from the second token.

[0118] In the specific implementation, as mentioned earlier, the server also needs to periodically update the global token bucket and pressure value. The global token bucket is generally updated once per second, but it can be dynamically updated according to the actual token acquisition operations of the client.

[0119] In some embodiments of the present invention, the method further includes:

[0120] Based on the updated first remaining token quantity information, the first token acquisition target quantity, and the second token acquisition target quantity, the pressure information is updated.

[0121] In practical applications, pressure values ​​need to be updated more frequently. The pressure value can be calculated and updated using the following formula:

[0122]

[0123] Where stress represents stress information, and token represents... last Obtain the target number of tokens for the first token. cur To acquire the target number of tokens for the second token g This is the information on the number of remaining tokens.

[0124] In this embodiment of the invention, the use of RDMA FAA primitives for communication reduces the latency of a single communication and improves the scalability of the system. The invention also features a specially designed token bucket data structure to reduce the number of communications, and introduces a pressure value metric to improve the accuracy of token allocation. These improvements further reduce token synchronization latency and enable dynamic token allocation, thereby enhancing the fairness and accuracy of overall service load control.

[0125] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0126] Reference Figure 5 The diagram illustrates a flow control device according to some embodiments of the present invention; applied to a client, the client having a local token bucket, specifically including the following modules:

[0127] The first data connection establishment module 501 is used to establish a data connection between the client and the server; wherein the server is equipped with a global token bucket.

[0128] The first token acquisition target quantity determination module 502 is used to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information of the global token bucket from the server according to the data connection, and determine the first token acquisition target quantity according to the first remaining token quantity information; wherein, the server is further used to determine the first remaining token quantity information, and when the tokens in the local token bucket are exhausted, send the first remaining token quantity information to the client according to the data connection.

[0129] The first token acquisition module 503 is used to acquire the token from the global token bucket based on the first token acquisition target quantity and the data connection.

[0130] In some embodiments of the present invention, the apparatus further includes:

[0131] The pressure information acquisition module is used to, in response to a token acquisition request, acquire pressure information of the global token bucket from the server according to the data connection when the tokens in the local token bucket have not been exhausted; wherein, the server is further used to determine the pressure information and, when the tokens in the local token bucket have not been exhausted and the client has a token acquisition request, send the pressure information to the client according to the data connection.

[0132] The second token acquisition target quantity determination module is used to determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity based on the first token acquisition target quantity, the second remaining token quantity information and the pressure information;

[0133] The second token acquisition module is used to acquire the tokens from the global token bucket based on the target number of the second token acquisition and the data connection.

[0134] Reference Figure 6 The diagram illustrates a flow control device according to some embodiments of the present invention; applied to a server, the server is equipped with a global token bucket, and may specifically include the following modules:

[0135] The second data connection establishment module 601 is used to establish a data connection between the server and the client; wherein the client is equipped with a local token bucket.

[0136] The first remaining token quantity information determination module 602 is used to determine the first remaining token quantity information of the global token bucket, and when the tokens in the local token bucket are exhausted, send the first remaining token quantity information to the client according to the data connection; wherein, the client is further used to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server according to the data connection, and determine the first token acquisition target quantity according to the first remaining token quantity information; and obtain the tokens from the global token bucket according to the first token acquisition target quantity through the data connection.

[0137] In some embodiments of the present invention, the apparatus further includes:

[0138] A pressure information sending module is used to determine the pressure information of the global token bucket, and when the tokens in the local token bucket are not exhausted and the client has a token acquisition requirement, send the pressure information to the client according to the data connection; wherein, the client is further used to, in response to the token acquisition requirement, obtain the pressure information from the server according to the data connection when the tokens in the local token bucket are not exhausted; determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information; and obtain the tokens from the global token bucket according to the second token acquisition target quantity and the data connection.

[0139] In some embodiments of the present invention, the apparatus further includes:

[0140] The first remaining token quantity information update module is used to update the first remaining token quantity information based on the target quantity obtained by the first token or the target quantity obtained by the second token.

[0141] In some embodiments of the present invention, the apparatus further includes:

[0142] The pressure information update module is used to update the pressure information based on the updated first remaining token quantity information, the first token acquisition target quantity, and the second token acquisition target quantity.

[0143] Some embodiments of the present invention also provide an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the above-described flow control method.

[0144] Some embodiments of the present invention also provide a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, it implements the above-described flow control method.

[0145] Some embodiments of the present invention also provide a computer program product, including a computer program that, when executed by a processor, implements the above-described flow control method.

[0146] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0147] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0148] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, embodiments of the present invention can take the form of entirely hardware embodiments, entirely software embodiments, or embodiments combining software and hardware aspects. Furthermore, embodiments of the present invention can take the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0149] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1A device that provides the functions specified in one or more boxes.

[0150] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0151] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal equipment, causing a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0152] Although preferred embodiments of the present invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the embodiments of the present invention.

[0153] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes the aforementioned element.

[0154] The above provides a detailed description of the flow control method, apparatus, electronic device, and storage medium. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, those skilled in the art will recognize that, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A flow control method, characterized in that, Applied to a client that has a local token bucket, the method includes: A data connection between the client and the server is established based on remote direct memory access technology; wherein, the server is equipped with a global token bucket; the data structure of the global token bucket is stored in a fixed-size memory block, and the data structure of the global token bucket includes: first remaining token quantity information for storing the current remaining number of global tokens, and pressure information for measuring the overall system pressure; wherein, the first remaining token quantity information also includes preset redundancy bits; When the tokens in the local token bucket are exhausted, the server obtains the first remaining token quantity information of the global token bucket from the server through the data connection, and determines the first target quantity of tokens to be obtained based on the first remaining token quantity information; wherein, the server is further configured to determine the first remaining token quantity information, and send the first remaining token quantity information to the client through the data connection when the tokens in the local token bucket are exhausted. Through the data connection, the target number is obtained based on the first token, and the token is retrieved from the global token bucket.

2. The method according to claim 1, characterized in that, The method further includes: If the tokens in the local token bucket are not exhausted, in response to a token acquisition request, the server obtains the pressure information of the global token bucket from the server according to the data connection; wherein, the server is further configured to determine the pressure information, and if the tokens in the local token bucket are not exhausted and the client has a token acquisition request, the server sends the pressure information to the client according to the data connection. Determine the second remaining token quantity information in the local token bucket, and based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information, determine the second token acquisition target quantity; Based on the second token, obtain the target number and connect it to the data, and then obtain the token from the global token bucket.

3. The method according to claim 1 or 2, characterized in that, The data connection is a one-sided operation mode based on remote direct memory access, which directly modifies the memory data of the remote node through atomic operations.

4. A flow control method, characterized in that, The method is applied to the server side, which is equipped with a global token bucket. The data structure of the global token bucket is stored in a fixed-size memory block. The data structure of the global token bucket includes: first remaining token quantity information for storing the current remaining number of global tokens, and pressure information for measuring the overall system pressure; wherein, the first remaining token quantity information also includes preset redundancy bits; the method includes: A data connection between the server and the client is established based on remote direct memory access technology; wherein, the client is equipped with a local token bucket; The system determines the first remaining token quantity information of the global token bucket, and sends the first remaining token quantity information to the client via the data connection when the tokens in the local token bucket are exhausted; wherein, the client is further configured to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server via the data connection, and determine the first token acquisition target quantity based on the first remaining token quantity information; and acquire the tokens from the global token bucket via the data connection based on the first token acquisition target quantity.

5. The method according to claim 4, characterized in that, The method further includes: The system determines the pressure information of the global token bucket, and sends the pressure information to the client via the data connection when the tokens in the local token bucket are not exhausted and the client has a token acquisition requirement; wherein, the client is further configured to, in response to the token acquisition requirement when the tokens in the local token bucket are not exhausted, obtain the pressure information from the server via the data connection; determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity based on the first token acquisition target quantity, the second remaining token quantity information, and the pressure information; and obtain the token from the global token bucket based on the second token acquisition target quantity and the data connection.

6. The method according to claim 5, characterized in that, The method further includes: Update the first remaining token quantity information based on the target quantity obtained from the first token or the target quantity obtained from the second token.

7. The method according to claim 6, characterized in that, The method further includes: Based on the updated first remaining token quantity information, the first token acquisition target quantity, and the second token acquisition target quantity, the pressure information is updated.

8. The method according to claim 4, characterized in that, The global token bucket is equipped with a redundancy bit, which is used to provide additional tokens when the global token bucket is over-consumed.

9. A flow control device, characterized in that, Applied to a client, the client having a local token bucket, the device includes: The first data connection establishment module is used to establish a data connection between the client and the server based on remote direct memory access technology; wherein, the server is equipped with a global token bucket; the data structure of the global token bucket is stored in a fixed-size memory block, and the data structure of the global token bucket includes: first remaining token quantity information for storing the current remaining number of global tokens, and pressure information for measuring the overall system pressure; wherein, the first remaining token quantity information also includes preset redundancy bits; The first token acquisition target quantity determination module is used to obtain the first remaining token quantity information of the global token bucket from the server according to the data connection when the tokens in the local token bucket are exhausted, and to determine the first token acquisition target quantity according to the first remaining token quantity information; wherein, the server is further used to determine the first remaining token quantity information, and when the tokens in the local token bucket are exhausted, to send the first remaining token quantity information to the client according to the data connection. The first token acquisition module is used to acquire the token from the global token bucket based on the target number of the first token acquisition and the data connection.

10. A flow control device, characterized in that, The device is applied to the server side, which is equipped with a global token bucket. The data structure of the global token bucket is stored in a fixed-size memory block. The data structure of the global token bucket includes: first remaining token quantity information for storing the current remaining number of global tokens, and pressure information for measuring the overall system pressure; wherein, the first remaining token quantity information also includes preset redundancy bits; the device includes: The second data connection establishment module is used to establish a data connection between the server and the client based on remote direct memory access technology; wherein, the client is equipped with a local token bucket; The first remaining token quantity information determination module is used to determine the first remaining token quantity information of the global token bucket, and when the tokens in the local token bucket are exhausted, send the first remaining token quantity information to the client according to the data connection; wherein, the client is further used to, when the tokens in the local token bucket are exhausted, obtain the first remaining token quantity information from the server according to the data connection, and determine the first token acquisition target quantity based on the first remaining token quantity information; and obtain the tokens from the global token bucket according to the first token acquisition target quantity through the data connection.

Citation Information

Patent Citations

  • Flow control method and device

    CN110768913A

  • Current limiting method and device and distributed current limiting system

    CN116455827A

  • Method for realizing high-availability distributed QOS (Quality of Service) of storage gateway

    CN116455830A

  • Hierarchical token buckets

    US11616725B1

  • Methods, systems, and computer readable media for using optimized token bucket algorithm for ingress message rate limiting across distributed producer network function (NF) applications

    WO2024163483A1