Flow control method and device, electronic equipment and storage medium

By establishing data connections between clients and servers in the cloud computing environment, combining global token buckets and local token buckets, the problem of high latency of distributed token bucket algorithms in the cloud computing environment is solved, and more efficient token synchronization and service performance improvement is achieved.

CN119728564AActive Publication Date: 2025-03-28CHINA TELECOM CLOUD TECH CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411696571.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-25
Publication Date
2025-03-28
Estimated Expiration
2044-11-25

AI Technical Summary

Technical Problem

The distributed token bucket algorithm requires multiple communications to synchronize token information in the cloud computing environment, resulting in high latency, making it difficult to meet the service processing capabilities of the rapidly developing cloud computing services.

Method used

By establishing a data connection between the client and the server, the combination of the global token bucket and the local token bucket is used to reduce the number of communications during token synchronization, and dynamic allocation of tokens is achieved by introducing the remaining token number information into the data structure of the global token bucket.

Benefits of technology

Reduces the delay in token synchronization, improves the performance of the overall service, and improves the fairness and accuracy of overall service volume control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119728564A_ABST
    Figure CN119728564A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a flow control method and device, electronic equipment and a storage medium, which are applied to a client side, the client side is provided with a local token bucket, and data connection between the client side and a server side provided with a global token bucket is established; then, under the condition that the tokens of the local token bucket are consumed completely, first remaining token number information of the global token bucket is obtained from the server side according to the data connection, and a first token obtaining target number is determined according to the first remaining token number information; and according to the first token, obtaining a mode of obtaining tokens in a global token bucket according to the target number and the data connection. According to the token synchronization method and device, the number of times of communication needed during token synchronization is reduced in a mode of combining the global token bucket and the local token bucket, and the mode of dynamically distributing the tokens by introducing the information of the number of the remaining tokens into the data structure of the global token bucket is realized, so that the delay of token synchronization is further reduced, and the performance of the overall service is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology, and in particular to a flow control method and device, electronic equipment, and storage medium. Background Art

[0002] Token Bucket technology is a common traffic management technology, which can be regarded as a traffic control and rate limiting algorithm, and is widely used in network transmission and service flow control. Its core idea is to control the data transmission rate by simulating a "bucket", ensuring that data is transmitted in a stable and controllable manner, while allowing a certain degree of burst data processing.

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

[0004] However, the distributed token bucket algorithm in the related technology requires multiple communications to synchronize token information, which has high latency and is difficult to meet the increasing demand for service processing capabilities as cloud computing services develop rapidly, thus affecting the performance of the overall service. Summary of the invention

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

[0006] A flow control method is applied to a client, wherein the client is provided with a local token bucket, and the method comprises:

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

[0008] When the tokens in the local token bucket are consumed, the first remaining token quantity information of the global token bucket is obtained from the server through the data connection, and the first token acquisition target quantity is determined according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and when the tokens in the local token bucket are consumed, the first remaining token quantity information is sent to the client through the data connection;

[0009] The token is obtained from the global token bucket through the data connection according to a target number of the first tokens.

[0010] Optionally, the method further includes:

[0011] When the tokens in the local token bucket have not been completely consumed, in response to a token acquisition requirement, the pressure information of the global token bucket is acquired from the server according to the data connection; wherein the server is further used to determine the pressure information, and when the tokens in the local token bucket have not been completely consumed and the client has a token acquisition requirement, the pressure information is sent to the client according to the data connection;

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

[0013] The token is obtained from the global token bucket according to the second token acquisition target quantity and the data connection.

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

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

[0016] Establishing a data connection between the server and the client; wherein the client is provided with a local token bucket;

[0017] Determine the first remaining token quantity information of the global token bucket, and send the first remaining token quantity information to the client according to the data connection when the tokens in the local token bucket are consumed; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity according to the first remaining token quantity information; obtain the token in the global token bucket through the data connection according to the first token acquisition target quantity.

[0018] Optionally, the method further includes:

[0019] Determine the pressure information of the global token bucket, and when the tokens in the local token bucket have not been consumed and the client has a token acquisition demand, send the pressure information to the client according to the data connection; wherein the client is also used to obtain the pressure information from the server according to the data connection in response to the token acquisition demand when the tokens in the local token bucket have not been consumed; 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; obtain the token in the global token bucket based on the second token acquisition target quantity and the data connection.

[0020] Optionally, the method further includes:

[0021] The first remaining token quantity information is updated according to the first token acquisition target quantity or the second token acquisition target quantity.

[0022] Optionally, the method further includes:

[0023] The pressure information is updated according to the updated first remaining token quantity information, the first token acquisition target quantity and the second token acquisition target quantity.

[0024] Optionally, a redundant bit is set in the global token bucket, and the redundant bit 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 is provided with a local token bucket, and the device comprises:

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

[0027] A first token acquisition target quantity determination module, used for obtaining first remaining token quantity information of the global token bucket from the server according to the data connection when the tokens of the local token bucket are consumed, and determining the first token acquisition target quantity according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and send the first remaining token quantity information to the client according to the data connection when the tokens of the local token bucket are consumed;

[0028] A first token acquisition module is used to connect with the data according to the first token acquisition target quantity and acquire the token in the global token bucket.

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

[0030] A second data connection establishment module, used to establish a data connection between the server and the client; wherein the client is provided with 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 consumed, send the first remaining token quantity information to the client according to the data connection; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity according to the first remaining token quantity information; through the data connection, obtain the token in the global token bucket according to the first token acquisition target quantity.

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

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

[0034] A computer program product comprises a computer program, and when the computer program is executed by a processor, the flow control method as described above is implemented.

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

[0036] The present invention provides a flow control method, which is applied to a client and the client is provided with a local token bucket. A data connection is established between the client and a server provided with a global token bucket. Then, when the tokens in the local token bucket are consumed, the first remaining token quantity information of the global token bucket is obtained from the server according to the data connection, and the first token acquisition target quantity is determined according to the first remaining token quantity information. Then, a token is acquired from the global token bucket according to the first token acquisition target quantity and the data connection. The method reduces the number of communications required for token synchronization by combining the global token bucket and the local token bucket, and introduces the remaining token quantity information in the data structure of the global token bucket to realize the method of dynamic token allocation, further reduces the delay of token synchronization, improves the performance of the overall service, and improves the fairness and accuracy of the overall service volume control. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the technical solution of the present invention, the accompanying drawings required for use in the description of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0038] Figure 1 is a flow chart of steps of a flow control method provided by some embodiments of the present invention;

[0039] Figure 2 is an example diagram of the data structure of the global token bucket of the present invention provided by some embodiments of the present invention;

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

[0041] Figure 4 is a flow chart of steps of a flow control method provided by some embodiments of the present invention;

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

[0043] Figure 6 It is a structural schematic diagram of a flow control device provided in some embodiments of the present invention. DETAILED DESCRIPTION

[0044] In order to make the above-mentioned purposes, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0045] In the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with basically the same functions and effects. This is only for the purpose of clearly describing the technical solutions of the embodiments of the present application, and shall not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features.

[0046] In the embodiments of the present application, the terms "upper", "lower", etc. indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as a limitation on the present application.

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

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

[0049] However, the distributed token bucket algorithm in the related technology requires multiple communications to synchronize token information, which has high latency and is difficult to meet the increasing demand for service processing capabilities as cloud computing services develop rapidly, thus affecting the performance of the overall service.

[0050] In order to solve the above problems, the present invention is 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, and improves the flow control method in the related art. The present invention will be described in detail in conjunction with the accompanying drawings below:

[0051] Reference Figure 1 , shows a flow chart of the steps of a flow control method provided by some embodiments of the present invention, which is applied to a client, and the client is provided with a local token bucket, and specifically may include the following steps:

[0052] Step 101, establishing a data connection between the client and the server; wherein the server is provided 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 adopted. The server node uniformly and periodically generates tokens to the global token bucket, and each client node can periodically pull a certain amount of tokens from the global token bucket to the local token bucket according to the data connection. After receiving the token acquisition request, each client can only consume the tokens in its own local token bucket. After consumption, 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 the sake of convenience, the following explains the relevant terms involved in the embodiments of the present invention:

[0056] RDMA (Remove 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-sided remote direct memory access): is a type of RDMA communication primitive that allows data to be transferred directly between computers' memories, across a network, without the need for data copying by the operating system or CPU, greatly reducing data transfer latency and improving scalability.

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

[0059] IOPS (Input / Output Operations Per Second): is an important indicator for measuring the performance of computer storage devices. IOPS represents the number of read and write operations that 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 of the existing distributed token buckets use the TCP / IP protocol stack for inter-node communication. The communication delay is limited by the computing power of the computing device and the operating system. Therefore, it is difficult to meet the increasing demand for service processing capabilities with the rapid development of cloud computing business, thus affecting the performance of the overall service.

[0061] RDMA is a new 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 its transmission and improving processing performance. Currently, RDMA mainly has two types of communication primitives. One is the SEND / RECV primitive similar to the traditional RPC protocol, which still requires the CPU of both communicating parties to participate in the message sending and receiving process; the other is the One-Side RDMA operation similar to memory operation, which includes four primitives: READ, WRITE, CAS (Compare and Swap), and FAA (Fetch and Add). The first two are directly used to read and write remote memory, and the latter two are a set of atomic operations on a section of remote memory. Since this type of One-Side RDMA operation does not require the CPU of the other end to participate, but is directly performed by the DMA engine in the network card of the other end, the communication delay is extremely low and has good scalability.

[0062] On this basis, in the specific implementation, a data connection can be established based on RDMA technology so that the RDMA FAA primitive can be used for the corresponding communication process, thereby reducing the delay of a single communication and improving the scalability of the system; the specific application scheme will be described in the subsequent embodiments.

[0063] Step 102, when the tokens in the local token bucket are consumed, obtain the first remaining token quantity information of the global token bucket from the server through the data connection, and determine the first token acquisition target quantity according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and when the tokens in the local token bucket are consumed, send the first remaining token quantity information to the client through the data connection;

[0064] In the specific implementation, the data structure of the global token bucket can be composed of two parts, one part is used to store the current remaining number of global tokens token g (i.e., the first remaining token quantity information), and the other part is used to measure the overall stress of the system. The two parts can be stored together in a fixed-size memory, and the size of this memory must be smaller than the memory size that can be operated by the RDMA FAA operation.

[0065] Each time the client obtains a token from the global token bucket, it can directly use the RDMA FAA operation to subtract the number of tokens the client wants to obtain 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, RDMA FAA will return the value before the corresponding memory operation, and the client can obtain the system stress and remaining tokens from it. g , here token g A certain number of redundant bits are also included in the token to prevent g The value overflows after subtraction, thus affecting stress;

[0066] On this basis, when the tokens in the local token bucket are consumed, the first remaining token quantity information of the global token bucket can be obtained from the server through the data connection, and the first token acquisition target quantity can be determined according to the first remaining token quantity information; specifically, when actively acquiring tokens for the first time and thereafter due to the consumption of local tokens, the actual number of tokens required to be acquired, that is, the first token acquisition target quantity can be determined according to the following formula:

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

[0068] Among them, token l Get the target number for the first token, token g is the first remaining token quantity information, client_amount is the number of clients, and period is the acquisition period.

[0069] In one example, taking the cloud hard disk service to implement rate limiting of IOPS and bandwidth of a shared cloud hard disk as an example, in such a scenario, the tokens in this embodiment should be divided into two types, representing IOPS and bandwidth respectively. Each cloud hard disk IO request needs to obtain the corresponding token before it can be sent to the storage backend for execution. Assuming that the maximum memory length of the RDMA FAA operation 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 can be composed of three parts, where IOPS and bandwidth tokens each occupy 20 bits to store the number of remaining tokens in each round. In order to compress space, each IOPS token represents 100 IOs, and each bandwidth token represents 100*10240B (a single IO corresponds to 10240B bandwidth). At the same time, in order to prevent mutual interference caused by excessive consumption of tokens, 4 redundant bits are reserved for each token as a buffer. These 4 bits can be set to 1 by default. If these 4 bits are not 1, it means that the token has been over-consumed. Therefore, the final support allocation is 2 20 ×100 = 104,857,600 IOs and 2 20 ×10240×100=1,000GiB bandwidth, which fully meets the specification requirements of existing shared disks.

[0070] Furthermore, the remaining 16 bits in the token bucket are used to represent the overall stress of the system, where the position of 1 represents the corresponding stress value. The higher the value, the greater the pressure. It is updated regularly by the server. The server will read the number of existing tokens at a certain frequency, calculate the decay rate of the token to evaluate the overall stress of the system, and update the stress value to this position.

[0071] Further, such as Figure 3 The figure shows the interactive process of the shared cloud hard disk distributed QoS (Quality of Service) implemented based on this embodiment. Figure 3 The server in is a central node responsible for processing QoS requests of all cloud disks. It will initialize the corresponding global token bucket in its own memory for client consumption. Figure 3 The client in will be deployed on all nodes that have mounted the shared cloud disk. The overall process can be summarized as follows:

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

[0073] 2. After receiving the request through RDMA,RECV, the server will determine whether the disk has been mounted by other clients. If not, a memory segment will be allocated to store the QoS information of the disk and register the memory with the RDMA network card. If it has been mounted, the QoS information will be updated. After that, the service segment will write the QoS information back to the pre-allocated memory of each client through the RDMAWRITE primitive according to the client information stored in the QoS information.

[0074] 3. After that, the client will periodically obtain the token according to the QoS information. The first time and the subsequent times when the client actively obtains the token due to the exhaustion of the local token will obtain the token. l Token l The confirmation formula is:

[0075] token1=token g / client_amount×period

[0076] Among them, token l The target number of tokens to be acquired for the first token (in this embodiment, the number of tokens that the client needs to actively acquire after the local tokens are consumed), token g is the first remaining token quantity information (in this embodiment, it is 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 number of tokens 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 24th to 48th bit position, token will eventually be subtracted from the global token bucket. l_iops <<24+token l_bw , where token l_iops The local number of IOPS tokens, token l_bw The local number of bandwidth tokens. After the operation is successful, the client will check the redundant bits of the global token bucket. If the redundant bits have a value of 0 or the global token bucket minus the number of tokens required this time 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 stress.

[0077] 4. Each subsequent time the client acquires a token, it is necessary to consider the number of tokens remaining in the local token bucket (i.e., the second remaining token number information) and the overall pressure of the current global token bucket. The number of tokens to be acquired (i.e., the second token acquisition target number) 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 Get the target number for the second token, token lGet the target number for the first token, stress is the pressure information, λ is the coefficient determined according to the pressure information, token r The second remaining token quantity information;

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

[0082]

[0083] Among them, stress is pressure information, token last Get the target number for the first token, token cur Get the target number for the second token, token g It is the first remaining token quantity information.

[0084] Step 103: Obtain the token from the global token bucket through the data connection according to the target number of the first token.

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

[0086] After receiving the request through RDMA,RECV, the server will determine whether the disk has been mounted by other clients. If not, a memory segment will be allocated to store the QoS information of the disk and register the memory with the RDMA network card. If it has been mounted, the QoS information will be updated. After that, the service segment will write the QoS information back to the pre-allocated memory of each client through the RDMAWRITE primitive according to the client information stored in the QoS information.

[0087] After that, the client will periodically obtain the token according to the QoS information. The first time and the subsequent times when the client actively obtains the token due to the exhaustion of the local token will obtain the token. l Token l The confirmation formula is:

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

[0089] Among them, tokenl The target number of tokens to be acquired for the first token (in this embodiment, the number of tokens that the client needs to actively acquire after the local tokens are consumed), token g is the first remaining token quantity information (in this embodiment, it is 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 comprises:

[0091] When the tokens in the local token bucket have not been completely consumed, in response to a token acquisition requirement, the pressure information of the global token bucket is acquired from the server according to the data connection; wherein the server is further used to determine the pressure information, and when the tokens in the local token bucket have not been completely consumed and the client has a token acquisition requirement, the pressure information is sent to the client according to the data connection;

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

[0093] The token is obtained from the global token bucket according to the second token acquisition target quantity and the data connection.

[0094] In the specific implementation, as mentioned above, taking the cloud hard disk service to implement rate limiting of IOPS and bandwidth of shared cloud hard disk as an example, after the first time the client actively obtains the token due to the exhaustion of the local token, the client can record the global stress value stress. Each subsequent time the client needs to obtain tokens when the tokens in the local token bucket have not been exhausted, the number of tokens remaining in the local token bucket (i.e., the second remaining token number information) and the overall pressure of the current global token bucket can be considered. The number of tokens to be obtained (i.e., the second token acquisition target number) can be determined using the following formula:

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

[0096] λ=2 stress-8

[0097] Among them, token cGet the target number for the second token, token l Get the target number for the first token, stress is the pressure information, λ is the coefficient determined according to the pressure information, token r It is the second remaining token quantity information.

[0098] Reference Figure 4 , shows a flow chart of the steps of a flow control method provided by some embodiments of the present invention, which is applied to a server, and the server is provided with a global token bucket, and specifically may include the following steps:

[0099] Step 401, establishing a data connection between the server and the client; wherein the client is provided with 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 adopted. The server node uniformly and periodically generates tokens to the global token bucket, and each client node can periodically pull a certain amount of tokens from the global token bucket to the local token bucket according to the data connection. After receiving the token acquisition request, each client can only consume the tokens in its own local token bucket. After consumption, 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 send the first remaining token quantity information to the client according to the data connection when the tokens in the local token bucket are consumed; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity based on the first remaining token quantity information; obtain the token in the global token bucket through the data connection according to the first token acquisition target quantity.

[0102] In practical applications, the data structure of the global token bucket can be composed of two parts. One part is used to store the current remaining number of global tokens. g (i.e., the first remaining token quantity information), and the other part is used to measure the overall stress of the system. The two parts can be stored together in a fixed-size memory, and the size of this memory must be smaller than the memory size that can be operated by the RDMA FAA operation.

[0103] Each time the client obtains a token from the global token bucket, it can directly use the RDMA FAA operation to subtract the number of tokens the client wants to obtain 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, RDMA FAA will return the value before the corresponding memory operation, and the client can obtain the system stress and remaining tokens from it. g , here token g A certain number of redundant bits are also included in the token to prevent g The value overflows after subtraction, thus affecting stress;

[0104] On this basis, when the tokens in the local token bucket are consumed, the first remaining token quantity information of the global token bucket can be obtained from the server through the data connection, and the first token acquisition target quantity can be determined according to the first remaining token quantity information; specifically, when actively acquiring tokens for the first time and thereafter due to the consumption of local tokens, the actual number of tokens required to be acquired, that is, the first token acquisition target quantity can be determined according to the following formula:

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

[0106] Among them, token l Get the target number for the first token, token g is the first remaining token quantity information, client_amount is the number of clients, and period is the acquisition period.

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

[0108] Determine the pressure information of the global token bucket, and when the tokens in the local token bucket have not been consumed and the client has a token acquisition demand, send the pressure information to the client according to the data connection; wherein the client is also used to obtain the pressure information from the server according to the data connection in response to the token acquisition demand when the tokens in the local token bucket have not been consumed; 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; obtain the token in the global token bucket based on the second token acquisition target quantity and the data connection.

[0109] In practical applications, as mentioned above, taking the cloud hard disk service to implement rate limiting of IOPS and bandwidth of shared cloud hard disks as an example, after the first time the client actively obtains tokens due to the exhaustion of local tokens, the client can record the global stress value stress. Each subsequent time the client needs to obtain tokens when the tokens in the local token bucket have not been exhausted, the number of tokens remaining in the local token bucket (i.e., the second remaining token number information) and the overall pressure of the current global token bucket can be considered. The number of tokens to be obtained (i.e., the second token acquisition target number) can be determined using the following formula:

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

[0111] λ=2 stress-8

[0112] Among them, token c Get the target number for the second token, token l Get the target number for the first token, stress is the pressure information, λ is the coefficient determined according to the pressure information, token r It is the second remaining token quantity information.

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

[0114] In practical applications, the data structure of the global token bucket can be composed of two parts. One part is used to store the current remaining number of global tokens. g (i.e., the first remaining token quantity information), and the other part is used to measure the overall stress of the system. The two parts can be stored together in a fixed-size memory, and the size of this memory must be smaller than the memory size that can be operated by the RDMAFAA operation.

[0115] Each time the client obtains a token from the global token bucket, it can directly use the RDMAFAA operation to subtract the number of tokens the client wants to obtain 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 before the corresponding memory operation, and the client can obtain the system stress and remaining tokens from it. g , here token gA certain number of redundant bits are also included in the token bucket, which can be used to prevent tokens from being used up by providing additional tokens when the global token bucket is over-consumed. g The value overflows after subtraction, thus affecting stress.

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

[0117] The first remaining token quantity information is updated according to the first token acquisition target quantity or the second token acquisition target quantity.

[0118] In the specific implementation, as mentioned above, the server also needs to periodically update the global token bucket and pressure value. The global token bucket is generally updated once per second, and can be dynamically updated according to the corresponding operation of the client to obtain the token.

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

[0120] The pressure information is updated according to the updated first remaining token quantity information, the first token acquisition target quantity and the second token acquisition target quantity.

[0121] In practical applications, the pressure value needs to be updated at a higher frequency. The calculation and update of the pressure value can be performed using the following formula:

[0122]

[0123] Among them, stress is pressure information, token last Get the target number for the first token, token cur Get the target number for the second token, token g It is the first remaining token quantity information.

[0124] In the embodiment of the present invention, the delay of a single communication is reduced and the scalability of the system is improved by using the RDMA FAA primitive for communication. The present invention also specifically designs a special token bucket data structure to reduce the number of communications. The present invention also improves the accuracy of token allocation by introducing a pressure value indicator. In this way, the delay of token synchronization is reduced and the dynamic allocation of tokens is realized, thereby improving the fairness and accuracy of overall service volume control.

[0125] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0126] Reference Figure 5 , showing a schematic diagram of the structure of a flow control device provided by some embodiments of the present invention; applied to a client, the client is provided with a local token bucket, and specifically may include 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 provided with a global token bucket;

[0128] A first token acquisition target quantity determination module 502 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 of the local token bucket are consumed, and determine the first token acquisition target quantity according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and send the first remaining token quantity information to the client according to the data connection when the tokens of the local token bucket are consumed;

[0129] The first token acquisition module 503 is used to connect with the data according to the first token acquisition target quantity and acquire the token from the global token bucket.

[0130] In some embodiments of the present invention, the device further comprises:

[0131] A pressure information acquisition module, used for obtaining the pressure information of the global token bucket from the server according to the data connection in response to a token acquisition requirement when the tokens in the local token bucket have not been completely consumed; wherein the server is also used for determining the pressure information, and sending the pressure information to the client according to the data connection when the tokens in the local token bucket have not been completely consumed and the client has a token acquisition requirement;

[0132] A second token acquisition target quantity determination module, used to determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity according to 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 connect with the data according to the second token acquisition target quantity and acquire the token in the global token bucket.

[0134] Reference Figure 6 , showing a schematic diagram of the structure of a flow control device provided by some embodiments of the present invention; applied to a server, the server is provided with a global token bucket, which 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 provided 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 consumed, send the first remaining token quantity information to the client according to the data connection; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity based on the first remaining token quantity information; through the data connection, obtain the token in the global token bucket according to the first token acquisition target quantity.

[0137] In some embodiments of the present invention, the device further comprises:

[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 have not been consumed and the client has a token acquisition demand, send the pressure information to the client according to the data connection; wherein the client is also used to obtain the pressure information from the server according to the data connection in response to the token acquisition demand when the tokens in the local token bucket have not been consumed; 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 in the global token bucket based on the second token acquisition target quantity and the data connection.

[0139] In some embodiments of the present invention, the device further comprises:

[0140] The first remaining token quantity information updating module is used to update the first remaining token quantity information according to the first token acquisition target quantity or the second token acquisition target quantity.

[0141] In some embodiments of the present invention, the device further comprises:

[0142] A pressure information updating module is used to update the pressure information according to 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 further 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, and the computer program implements the above flow control method when executed by the processor.

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

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

[0146] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

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

[0148] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product 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 codes.

[0149] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0150] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A 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 device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0152] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.

[0153] Finally, it should 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 terminal 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 terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.

[0154] The flow control method and device, electronic device, and storage medium provided are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A flow control method, characterized in that: Applied to a client, the client is provided with a local token bucket, the method comprises: Establishing a data connection between the client and the server; wherein the server is provided with a global token bucket; When the tokens in the local token bucket are consumed, the first remaining token quantity information of the global token bucket is obtained from the server through the data connection, and the first token acquisition target quantity is determined according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and when the tokens in the local token bucket are consumed, the first remaining token quantity information is sent to the client through the data connection; The token is obtained from the global token bucket through the data connection according to a target number of the first tokens.

2. The method according to claim 1, characterized in that The method further comprises: When the tokens in the local token bucket have not been completely consumed, in response to a token acquisition requirement, the pressure information of the global token bucket is acquired from the server according to the data connection; wherein the server is further used to determine the pressure information, and when the tokens in the local token bucket have not been completely consumed and the client has a token acquisition requirement, the pressure information is sent to the client according to the data connection; Determine the second remaining token quantity information in the local token bucket, and determine the second token acquisition target quantity according to the first token acquisition target quantity, the second remaining token quantity information and the pressure information; The token is obtained from the global token bucket according to the second token acquisition target quantity and the data connection.

3. The method according to claim 1 or 2, characterized in that: The data connection is a remote direct memory access data connection.

4. A flow control method, characterized in that: Applied to a server, the server is provided with a global token bucket, and the method comprises: Establishing a data connection between the server and the client; wherein the client is provided with a local token bucket; Determine the first remaining token quantity information of the global token bucket, and send the first remaining token quantity information to the client according to the data connection when the tokens in the local token bucket are consumed; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity according to the first remaining token quantity information; obtain the token in the global token bucket through the data connection according to the first token acquisition target quantity.

5. The method according to claim 4, characterized in that The method further comprises: Determine the pressure information of the global token bucket, and when the tokens in the local token bucket have not been consumed and the client has a token acquisition demand, send the pressure information to the client according to the data connection; wherein the client is also used to obtain the pressure information from the server according to the data connection in response to the token acquisition demand when the tokens in the local token bucket have not been consumed; 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; obtain the token in 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 comprises: The first remaining token quantity information is updated according to the first token acquisition target quantity or the second token acquisition target quantity.

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

8. The method according to claim 4, characterized in that The global token bucket is provided with a redundant bit, and the redundant bit 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 is provided with a local token bucket, and the device comprises: A first data connection establishment module, used to establish a data connection between the client and the server; wherein the server is provided with a global token bucket; A first token acquisition target quantity determination module, used for obtaining first remaining token quantity information of the global token bucket from the server according to the data connection when the tokens of the local token bucket are consumed, and determining the first token acquisition target quantity according to the first remaining token quantity information; wherein the server is also used to determine the first remaining token quantity information, and send the first remaining token quantity information to the client according to the data connection when the tokens of the local token bucket are consumed; A first token acquisition module is used to connect with the data according to the first token acquisition target quantity and acquire the token in the global token bucket.

10. A flow control device, characterized in that: Applied to a server, the server is provided with a global token bucket, and the device comprises: A second data connection establishment module, used to establish a data connection between the server and the client; wherein the client is provided 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 consumed, send the first remaining token quantity information to the client according to the data connection; wherein the client is also used to obtain the first remaining token quantity information from the server according to the data connection when the tokens in the local token bucket are consumed, and determine the first token acquisition target quantity according to the first remaining token quantity information; through the data connection, the token is obtained in the global token bucket according to the first token acquisition target quantity.

Citation Information

Patent Citations

  • Method, device and system for accessing memory

    CN103227778A

  • Flow control method and device

    CN110768913A

  • Flow congestion control method and device, computer readable medium and electronic equipment

    CN114884823A

  • 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