WO2021197128A1 - Traffic rate-limiting method and apparatus - Google Patents

Traffic rate-limiting method and apparatus Download PDF

Info

Publication number
WO2021197128A1
WO2021197128A1 PCT/CN2021/082307 CN2021082307W WO2021197128A1 WO 2021197128 A1 WO2021197128 A1 WO 2021197128A1 CN 2021082307 W CN2021082307 W CN 2021082307W WO 2021197128 A1 WO2021197128 A1 WO 2021197128A1
Authority
WO
WIPO (PCT)
Prior art keywords
tokens
total number
global
token
sub
Prior art date
Application number
PCT/CN2021/082307
Other languages
French (fr)
Chinese (zh)
Inventor
邹勇
Original Assignee
阿里巴巴集团控股有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 阿里巴巴集团控股有限公司 filed Critical 阿里巴巴集团控股有限公司
Publication of WO2021197128A1 publication Critical patent/WO2021197128A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/215Flow control; Congestion control using token-bucket
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/21Flow control; Congestion control using leaky-bucket

Definitions

  • the present invention relates to the field of Internet technology, in particular to a flow rate limiting method and device.
  • Token bucket is a common flow measurement technology, which is often used for flow restriction and flow shaping. It can measure the rate and burst of flow.
  • Token bucket is a common flow measurement technology, which is often used for flow restriction and flow shaping. It can measure the rate and burst of flow.
  • the server With the popularization of Internet technology, the number of Internet users has greatly increased. In order to process the data sent by users in a timely manner, the server often uses a multi-core concurrent system to restrict traffic.
  • the flow rate limiting method and device provided by the present invention aims to solve the problems of low rate limiting efficiency and inaccurate rate limiting in the prior art.
  • the present invention provides a traffic rate limiting method, the method includes:
  • the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
  • the method before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further includes:
  • the determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
  • the global continuous packet loss state is the off state, it is determined whether the total number of first tokens is greater than the total number of second tokens.
  • the method further includes:
  • the global continuous packet loss state is set to an open state.
  • the method further includes:
  • the method further includes:
  • the global continuous packet loss state is set to a closed state
  • the global continuous packet loss state is set to the off state.
  • the method before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further includes:
  • the determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
  • the number of tokens is a multiple of M, it is determined whether the total number of the first tokens is greater than the total number of the second tokens.
  • the method further includes:
  • the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
  • the method further includes:
  • N tokens are added to the global token bucket, where N is the product of the committed information rate and the period.
  • the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
  • the present invention provides a flow rate limiting device, the device comprising:
  • the receiving unit is used to receive the sent data to be processed
  • the judging unit is used to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different kernels correspond to different sub-token buckets, and the global token The tokens in the bucket are periodically increased;
  • a discarding unit configured to discard the to-be-processed data if the total number of first tokens is greater than the total number of second tokens;
  • a retention unit configured to retain the to-be-processed data if the total number of the first tokens is less than or equal to the total number of the second tokens;
  • the adding unit is configured to add a token to the sub-token bucket of the current kernel if the data to be processed is retained.
  • the judging unit is further configured to judge the global continuous packet loss state before judging whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket Whether it is an open state; if the global continuous packet loss state is an off state, it is determined whether the total number of the first tokens is greater than the total number of the second tokens.
  • the device further includes:
  • the first setting unit is configured to set the global continuous packet loss state to an open state if the total number of first tokens is greater than the total number of second tokens.
  • the discarding unit is further configured to discard the to-be-processed data if the global continuous packet loss state is an open state.
  • the device further includes:
  • the second setting unit is configured to: if the global continuous packet loss status is the open state, if it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then The global continuous packet loss state is set to the off state; or, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
  • the determining unit is further configured to determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, to determine the sub-commands of the current kernel Whether the number of tokens in the bucket is a multiple of M; M is a positive integer; if the number of tokens is a multiple of M, it is determined whether the total number of first tokens is greater than the total number of second tokens.
  • the retaining unit is further configured to retain the to-be-processed data if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M.
  • the judging unit is further configured to judge whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size for each cycle;
  • the adding unit is further configured to update the global token bucket if it is greater than the committed burst size, so that the total number of second tokens of the global token bucket is the total number of the first token and the total number of tokens. If the sum of burst sizes is assumed; if it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate and the period.
  • the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
  • the present invention provides a storage medium storing a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the traffic rate limiting method as described in the first aspect.
  • the present invention provides an electronic device, the electronic device including a storage medium and a processor;
  • the processor is suitable for implementing various instructions
  • the storage medium is suitable for storing multiple instructions
  • the instructions are adapted to be loaded by the processor and execute the method according to the first aspect.
  • the traffic rate limiting method and device can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add commands to the global token bucket.
  • the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket ( The second total number of tokens) is a limiting condition to determine whether to add tokens to the sub-token bucket of the current kernel (that is, if the total number of first tokens is greater than the total number of second tokens, the data to be processed will be discarded, and the current kernel will not Add tokens in the sub-token bucket of the, and if the total number of the first token is less than or equal to the total number of the second token, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel), so that no It may happen
  • Figure 1 shows a flow chart of a flow rate limiting method provided by an embodiment of the present invention
  • Figure 2 shows a flow chart of another method for traffic rate limiting according to an embodiment of the present invention
  • FIG. 3 shows a flowchart of yet another method for traffic rate limiting according to an embodiment of the present invention
  • FIG. 4 shows a flow chart of still another method for traffic rate limiting according to an embodiment of the present invention
  • Figure 5 shows a block diagram of a flow rate limiting device provided by an embodiment of the present invention
  • Fig. 6 shows a block diagram of another flow rate limiting device provided by an embodiment of the present invention.
  • the embodiment of the present invention provides a combination of a global token bucket and each kernel sub-token bucket, and uses the global token bucket to control the flow limit of the number of tokens in the sub-token bucket.
  • Fast method the method is mainly applied to a single core side, as shown in Figure 1, the method mainly includes:
  • the embodiments of the present invention can be applied to any kind of network project.
  • a multi-core network device with a safe speed limit function can be set in the project, and the network device can perform a speed limit operation on the data to be processed from the outside.
  • the data to be processed can be a message or a data packet in the data format, and can be a request or non-request in the content.
  • the embodiment of the present invention does not deal with the specific data format and data content of the interaction. limited.
  • the embodiments of the present invention can implement restrictions on the frequency of message sending, and can also implement restrictions on the frequency of message forwarding.
  • step 102 Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 103; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 104.
  • each core corresponds to a sub-token bucket
  • different cores correspond to different sub-token buckets.
  • the tokens in the global token bucket are added periodically (one of the kernels can be designated to perform the token increase operation on the global token bucket), and the tokens in the sub-token bucket are executed by performing steps 101-104 Way to increase.
  • the bucket depth of the global token bucket and/or sub-token bucket can be infinite bucket depth, that is, the number of tokens can only increase without decreasing, and can increase indefinitely.
  • the total number of first tokens accumulated in the preset number of sub-token buckets can be combined with the total number of first tokens in the global token bucket.
  • the total number of the two tokens is compared, and the discarding and retention of the data to be processed is determined through different comparison results.
  • the preset number can be determined according to the requirements of speed limit efficiency and speed limit accuracy. The higher the speed limit accuracy requirement, the greater the preset number. For example, when the preset number is the sum of all sub-token buckets, the speed limit accuracy rate is higher than that of other numbers, but it is higher than other number limits. The speed efficiency may be lower.
  • the sub-token bucket that needs to be accumulated to obtain the first total number of tokens can be determined according to a preset condition.
  • the preset conditions include, but are not limited to, sub-token buckets with a number of tokens greater than a preset threshold, and sub-token buckets with a number of tokens in the top N (N is a positive integer).
  • a total number of first tokens can be stored in the preset storage space. If a token is added to a certain sub-token bucket, update it When the total number of first tokens stored in the preset storage space needs to be compared with the total number of second tokens, the total number of first tokens can be directly read from the preset storage space. You can also create a temporary token bucket, add a token to the sub-token bucket, add a token to the temporary token bucket, and when you need to compare with the total number of second tokens, count the temporary token bucket The number of tokens as the first total number of tokens.
  • the tokens of the sub-token bucket are increased according to the data to be processed. If there is no data to be processed for a long time, or the data to be processed is received for a long time, the tokens of the global token bucket will always be Increase periodically, which will cause the total number of second tokens in the global token bucket to be much larger than the total number of first tokens accumulated by the preset number of sub-token buckets.
  • the judgment mechanism of the embodiment of the invention allows the data to be processed to be retained, which may cause a sudden increase in the load of the kernel and cause failures such as downtime. To avoid this technical problem, the following methods can be used to periodically add tokens to the global token bucket:
  • CIR Committed Information Rate
  • the committed burst size is also called the committed burst volume, which refers to the total amount of data that the network allows to transmit on the virtual circuit in a normal state and within a certain time interval.
  • the total number of second tokens in the global token bucket not to exceed the sum of the total number of first tokens and the burst size, the total amount of data to be processed that is allowed to be retained within a period of time can be controlled. It will not exceed the amount of data represented by the burst size, so that the burst size is limited, and the sudden increase will prevent the core from being unable to withstand the failure.
  • the committed information rate is the virtual circuit information transmission rate under the normal state agreed by the user and the network. If the difference between the total number of second tokens and the total number of first tokens is less than or equal to the committed burst size, tokens can be added to the global token bucket according to the committed information rate, that is, the increase allowed in each cycle
  • the number of cards N can be the product of the committed information rate and the period.
  • the function of controlling the sub-token bucket of the global token bucket can be achieved by discarding the data to be processed, thereby realizing the speed limit of the whole machine.
  • the data to be processed is retained, and by adding a token to the sub-token bucket of the current kernel, the added token is allocated to the data to be processed.
  • the specific implementation manner of retaining the data to be processed may be to add the data to be processed into the cache queue corresponding to the current kernel, so that it can be subsequently processed.
  • the traffic rate limiting method provided by the embodiment of the present invention can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add tokens to the global token bucket, and for each sub-token bucket Token bucket, when the current kernel receives data to be processed, the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket (the total number of second tokens)
  • determine whether to add tokens to the sub-token bucket of the current kernel that is, if the total number of the first token is greater than the total number of the second token, the data to be processed will be discarded, and will not be added to the sub-token bucket of the current kernel.
  • the embodiment of the present invention provides the following three methods:
  • Method 1 As shown in Figure 2, the method mainly includes:
  • step 101 The specific implementation of this step is the same as that of step 101, and will not be repeated here.
  • the global continuous packet loss status is a parameter used to control global packet loss, that is, when it is turned on, it is used to instruct each core to discard new data to be processed after it is received, and there is no need to send it to Add tokens to the sub-token bucket.
  • the kernel Since the global continuous packet loss status is a global parameter, and when it is in the open state, no matter whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the kernel Both need to discard the newly received pending data, so after receiving the sent pending data, first judge whether the global continuous packet loss status is the open state to avoid wasting time and resources to judge the total number of tokens.
  • the global continuous packet loss state can be set to the off state.
  • a relatively good time is: if it is determined that the global token bucket enters the next cycle, and the token increase operation has been completed for the next cycle, then the global continuous packet loss state is set to the off state .
  • you can also choose another time to set the global continuous packet loss state to the off state For example, you can set the global continuous packet loss state to the on state for a preset duration. At this time, the global continuous packet loss state is set to the off state.
  • the global continuous packet loss state is the off state, determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket.
  • the global token Because when tokens are added periodically in the global token bucket, in a cycle, it may take the first part of the cycle to complete the token increase operation, and during the remaining time of the cycle, the global token The total number of second tokens in the bucket will not change, so during the remaining time, once the total number of first tokens accumulated by the preset number of sub-token buckets is greater than the total number of second tokens, then From the moment (may be called the first occurrence moment) until the next token is added to the global token bucket, no matter whether the judgment is made, the conclusion is that the total number of first tokens is greater than the total number of second tokens, and it needs to be processed The data is discarded. In order to save judgment resources and judgment time, the global continuous packet loss status can be set to the on state, so that when new data to be processed is subsequently received, the global continuous packet loss status can be directly discarded.
  • the global continuous packet loss state may be set to the on state, or it may be set to the open state at the Xth (X is greater than 1) time
  • the judgment result is that when the total number of first tokens is greater than the total number of second tokens, the global continuous packet loss status is set to the open state, as long as the global continuous packet loss status can be guaranteed to be set to the open state.
  • the timing can save judgment resources and judgment time to a certain extent from the moment of the first occurrence until the next time before adding tokens to the global token bucket, thereby improving the limited efficiency to a certain extent.
  • step 104 The specific implementation of this step is the same as that of step 104, and will not be repeated here.
  • the traffic rate limiting method provided by the embodiment of the present invention is based on the embodiment shown in FIG. , And when the global continuous packet loss status is on, the data to be processed is directly discarded, which can reduce the number of judgments for loss/retention decisions, and further improve the speed limit efficiency on the basis of improving the accuracy of the overall speed limit.
  • Method 2 As shown in Figure 3, the method mainly includes:
  • step 101 The specific implementation of this step is the same as that of step 101, and will not be repeated here.
  • M is a positive integer, and the specific value of M can be determined based on historical experience.
  • the total number of tokens in the sub-token bucket and global token bucket of each core is cumulative, the total number of tokens is judged every M pieces of data to be processed (that is, the decision to lose/leave), and the middle to be processed
  • M data is a period
  • the new arrival will be discarded due to the limit of the total number of second tokens to the total number of first tokens.
  • Data, that is, Y data will be reduced in the subsequent cycle, so for the whole machine, its speed limit accuracy rate is almost unchanged.
  • step 303 when receiving the data to be processed, you can first determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M, if not, you can directly keep it and send it to the sub-token bucket of the current kernel. Add a token (that is, step 303), if it is, then perform a judgment of the total number of tokens, and make a decision to discard/retain the data to be processed based on the result of the judgment of the total number of tokens (that is, step 304->305->303).
  • step 104 The specific implementation of this step is the same as that of step 104, and will not be repeated here.
  • step 304 Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 305; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 303.
  • a drop/leave decision is made every M pieces of to-be-processed data, and the intermediate to-be-processed data can be directly reserved. Reduce the number of times of decision-making for loss/retention, which can further improve the speed limit efficiency on the basis of improving the accuracy of the whole machine speed limit.
  • Method 3 Since the first method is to improve the rate-limiting efficiency from a global level, and the second method is to improve the rate-limiting efficiency from a single-core level, and there is no dependence and contradiction between the two, the two can be combined to form the third method to further To improve the speed limit efficiency, as shown in Figure 4, the method includes:
  • step 406. Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 407; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 405.
  • another embodiment of the present invention also provides a flow rate limiting device. As shown in Fig. 5, the device includes:
  • the receiving unit 51 is configured to receive sent data to be processed
  • the judging unit 52 is configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different kernels correspond to different sub-token buckets, and the global command The tokens in the bucket are increased periodically;
  • the discarding unit 53 is configured to discard the to-be-processed data if the total number of the first tokens is greater than the total number of the second tokens;
  • the retaining unit 54 is configured to retain the data to be processed if the total number of the first tokens is less than or equal to the total number of the second tokens;
  • the adding unit 55 is configured to add a token to the sub-token bucket of the current kernel if the data to be processed is retained.
  • the judging unit 52 is further configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, to determine the global continuous packet loss Whether the state is an open state; if the global continuous packet loss state is an off state, it is determined whether the total number of first tokens is greater than the total number of second tokens.
  • the device further includes:
  • the first setting unit 56 is configured to set the global continuous packet loss state to an open state if the total number of first tokens is greater than the total number of second tokens.
  • the discarding unit 53 is further configured to discard the to-be-processed data if the global continuous packet loss state is an open state.
  • the device further includes:
  • the second setting unit 57 is configured to, if the global continuous packet loss state is the open state, if it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then The global continuous packet loss state is set to the off state; or, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
  • the judging unit 52 is further configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, before judging the sub-tokens of the current kernel. Whether the number of tokens in the token bucket is a multiple of M; M is a positive integer; if the number of tokens is a multiple of M, it is determined whether the total number of first tokens is greater than the total number of second tokens.
  • the retaining unit 54 is further configured to retain the to-be-processed data if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M.
  • the judging unit 52 is further configured to judge whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size for each cycle;
  • the adding unit 55 is further configured to update the global token bucket if it is larger than the committed burst size, so that the total number of second tokens in the global token bucket is the total number of the first tokens and the total number of tokens. If the sum of burst sizes is assumed; if it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate and the period .
  • the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
  • the flow rate limiting device provided by the embodiment of the present invention can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add tokens to the global token bucket, and for each sub-token bucket Token bucket, when the current kernel receives the data to be processed, the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket (the total number of second tokens) It is a restriction condition to determine whether to add tokens to the sub-token bucket of the current kernel (that is, if the total number of the first token is greater than the total number of the second token, the data to be processed will be discarded, and will not be added to the sub-token bucket of the current kernel.
  • the speed limit efficiency can be further improved.
  • another embodiment of the present invention also provides a storage medium, the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned flow rate limiting method.
  • another embodiment of the present invention also provides an electronic device, the electronic device including a storage medium and a processor;
  • the processor is suitable for implementing various instructions
  • the storage medium is suitable for storing multiple instructions
  • the instructions are adapted to be loaded by the processor and execute the traffic rate limiting method as described above.
  • modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and/or processes or units are mutually exclusive, any combination can be used to compare all the features disclosed in this specification (including the accompanying claims, abstract and drawings) and any method or methods disclosed in this manner or All the processes or units of the equipment are combined. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
  • the various component embodiments of the present invention may be implemented by hardware, or by software modules running on one or more processors, or by a combination of them.
  • a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all components in the traffic rate limiting method and device according to the embodiments of the present invention.
  • DSP digital signal processor
  • the present invention can also be implemented as a device or device program (for example, a computer program and a computer program product) for executing part or all of the methods described herein.
  • Such a program for realizing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals.
  • Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present invention relates to the technical field of Internet. Disclosed are a traffic rate-limiting method and apparatus, capable of solving the problems in the prior art that the efficiency of rate-limiting is low and the rate-limiting is inaccurate. The method in the present invention mainly comprises: receiving data to be processed that is transmitted; determining whether a total number of first tokens in a preset number of sub-token buckets is greater than a total number of second tokens in a global token bucket, different cores corresponding to different sub-token buckets, and the tokens in the global token bucket being periodically increased; if the total number of the first tokens is greater than the total number of the second tokens, discarding the data to be processed; and if the total number of the first tokens is less than or equal to the total number of the second tokens, retaining the data to be processed, and adding one token to the sub-token bucket of the current core. The present invention is mainly applicable to a scenario of performing traffic control on the basis of a token bucket under a multi-core system.

Description

流量限速方法及装置Flow rate limiting method and device
本申请要求2020年03月30日递交的申请号为202010238135.7、发明名称为“流量限速方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202010238135.7 and the invention title of "Flow Rate Limiting Method and Device" filed on March 30, 2020, the entire content of which is incorporated into this application by reference.
技术领域Technical field
本发明涉及互联网技术领域,特别是涉及一种流量限速方法及装置。The present invention relates to the field of Internet technology, in particular to a flow rate limiting method and device.
背景技术Background technique
令牌桶是一种常见的流量测量技术,常用于流量的限制和流量的整形,能够对流量的速率和突发进行测量。随着互联网技术的普及,互联网用户量大大增加,为了及时对用户发送的数据进行处理,服务端常常会采用多核并发系统来对流量进行限制。Token bucket is a common flow measurement technology, which is often used for flow restriction and flow shaping. It can measure the rate and burst of flow. With the popularization of Internet technology, the number of Internet users has greatly increased. In order to process the data sent by users in a timely manner, the server often uses a multi-core concurrent system to restrict traffic.
目前在多核并发系统下,基于令牌桶进行流量限制时,通常采用如下两种方法:Currently, in a multi-core concurrent system, when traffic is restricted based on token buckets, the following two methods are usually used:
(一)建立一个全局令牌桶,并对该全局令牌桶加锁,使得同一时间只允许一个内核更新全局令牌桶,以避免多个内核并发对全局令牌桶进行更新,而导致高频的数据写覆盖,使得限速不准确。但是,因为加入了锁机制,所以这种方法存在锁等待和cache回刷等待等问题,导致限速效率降低。(1) Establish a global token bucket and lock the global token bucket so that only one kernel is allowed to update the global token bucket at the same time, so as to avoid multiple kernels from concurrently updating the global token bucket, resulting in high Frequent data write coverage makes the speed limit inaccurate. However, due to the addition of a lock mechanism, this method has problems such as lock waiting and cache flushing waiting, which leads to a decrease in the rate-limiting efficiency.
(二)分别针对每个内核建立一个令牌桶,并按特定的令牌添加速率向令牌桶投放令牌,供对应的内核使用。虽然该方法没有锁机制所存在的缺陷,但是由于待处理数据进入各个内核的速率并没有确定的规则,所以会导致待处理数据量大的内核早已经因为没有令牌而丢弃数据,而待处理数据量小的内核却还有大量令牌未使用,由此导致在整机层面限速非常不准确。(2) Establish a token bucket for each core respectively, and put tokens into the token bucket at a specific token addition rate for use by the corresponding core. Although this method does not have the flaws of the lock mechanism, there is no definite rule for the rate at which the data to be processed enters each core, so the core with a large amount of data to be processed has already discarded the data because there is no token, and it is waiting to be processed. The kernel with a small amount of data still has a large number of unused tokens, which results in very inaccurate speed limit at the whole machine level.
由此可知,如何提供一种限速效率和准确率都相对较高的限速方法是亟待解决的。It can be seen that how to provide a speed limiting method with relatively high speed limiting efficiency and accuracy is an urgent need to be solved.
发明内容Summary of the invention
有鉴于此,本发明提供的流量限速方法及装置,其目的在于解决现有技术限速效率低下和限速不准确的问题。In view of this, the flow rate limiting method and device provided by the present invention aims to solve the problems of low rate limiting efficiency and inaccurate rate limiting in the prior art.
第一方面,本发明提供了一种流量限速方法,所述方法包括:In the first aspect, the present invention provides a traffic rate limiting method, the method includes:
接收发送的待处理数据;Receive and send pending data;
判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;不同内核对应不同的子令牌桶,所述全局令牌桶内的令牌是周期性增加的;Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different cores correspond to different sub-token buckets, and the tokens in the global token bucket Is increasing periodically;
若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据;If the total number of first tokens is greater than the total number of second tokens, discarding the to-be-processed data;
若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。If the total number of first tokens is less than or equal to the total number of second tokens, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
可选的,在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,所述方法还包括:Optionally, before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further includes:
判断全局连续丢包状态是否为打开状态;Determine whether the global continuous packet loss status is open;
所述判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数包括:The determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
若所述全局连续丢包状态为关闭状态,则判断所述第一令牌总数是否大于所述第二令牌总数。If the global continuous packet loss state is the off state, it is determined whether the total number of first tokens is greater than the total number of second tokens.
可选的,若所述第一令牌总数大于所述第二令牌总数,则所述方法还包括:Optionally, if the total number of first tokens is greater than the total number of second tokens, the method further includes:
将所述全局连续丢包状态设置为打开状态。The global continuous packet loss state is set to an open state.
可选的,若所述全局连续丢包状态为打开状态,则所述方法还包括:Optionally, if the global continuous packet loss state is an on state, the method further includes:
丢弃所述待处理数据。Discard the to-be-processed data.
可选的,若所述全局连续丢包状态为打开状态,则所述方法还包括:Optionally, if the global continuous packet loss state is an on state, the method further includes:
若确定所述全局令牌桶进入下一个周期,且已针对所述下一个周期完成了令牌增加操作,则将所述全局连续丢包状态设置为关闭状态;If it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then the global continuous packet loss state is set to a closed state;
或者,当所述全局连续丢包状态为打开状态的持续时长为预设时长时,将所述全局连续丢包状态设置为关闭状态。Alternatively, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
可选的,在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,所述方法还包括:Optionally, before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further includes:
判断当前内核的子令牌桶内令牌数是否为M的倍数;M为正整数;Determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M; M is a positive integer;
所述判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数包括:The determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
若所述令牌数是M的倍数,则判断所述第一令牌总数是否大于所述第二令牌总数。If the number of tokens is a multiple of M, it is determined whether the total number of the first tokens is greater than the total number of the second tokens.
可选的,若当前内核的子令牌桶内令牌数不是M的倍数,则所述方法还包括:Optionally, if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M, the method further includes:
保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。The data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
可选的,所述方法还包括:Optionally, the method further includes:
针对每个周期,判断所述第二令牌总数与所述第一令牌总数之差是否大于承诺突发尺寸;For each cycle, determine whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size;
若大于所述承诺突发尺寸,则更新所述全局令牌桶,使得所述全局令牌桶的第二令牌总数为所述第一令牌总数和所述承若突发尺寸之和;If it is greater than the committed burst size, update the global token bucket so that the total number of second tokens in the global token bucket is the sum of the total number of first tokens and the acceptable burst size;
若小于或等于所述承诺突发尺寸,则向所述全局令牌桶内增加N个令牌,所述N为所述承诺信息速率与所述周期之积。If it is less than or equal to the committed burst size, N tokens are added to the global token bucket, where N is the product of the committed information rate and the period.
可选的,所述子令牌桶和/或所述全局令牌桶的桶深为无限桶深。Optionally, the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
第二方面,本发明提供了一种流量限速装置,所述装置包括:In the second aspect, the present invention provides a flow rate limiting device, the device comprising:
接收单元,用于接收发送的待处理数据;The receiving unit is used to receive the sent data to be processed;
判断单元,用于判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;不同内核对应不同的子令牌桶,所述全局令牌桶内的令牌是周期性增加的;The judging unit is used to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different kernels correspond to different sub-token buckets, and the global token The tokens in the bucket are periodically increased;
丢弃单元,用于若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据;A discarding unit, configured to discard the to-be-processed data if the total number of first tokens is greater than the total number of second tokens;
保留单元,用于若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据;A retention unit, configured to retain the to-be-processed data if the total number of the first tokens is less than or equal to the total number of the second tokens;
增加单元,用于若保留所述待处理数据,则向当前内核的子令牌桶内增加一个令牌。The adding unit is configured to add a token to the sub-token bucket of the current kernel if the data to be processed is retained.
可选的,所述判断单元,还用于在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,判断全局连续丢包状态是否为打开状态;若所述全局连续丢包状态为关闭状态,则判断所述第一令牌总数是否大于所述第二令牌总数。Optionally, the judging unit is further configured to judge the global continuous packet loss state before judging whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket Whether it is an open state; if the global continuous packet loss state is an off state, it is determined whether the total number of the first tokens is greater than the total number of the second tokens.
可选的,所述装置还包括:Optionally, the device further includes:
第一设置单元,用于若所述第一令牌总数大于所述第二令牌总数,则将所述全局连续丢包状态设置为打开状态。The first setting unit is configured to set the global continuous packet loss state to an open state if the total number of first tokens is greater than the total number of second tokens.
可选的,所述丢弃单元,还用于若所述全局连续丢包状态为打开状态,则丢弃所述待处理数据。Optionally, the discarding unit is further configured to discard the to-be-processed data if the global continuous packet loss state is an open state.
可选的,所述装置还包括:Optionally, the device further includes:
第二设置单元,用于若所述全局连续丢包状态为打开状态,则若确定所述全局令牌桶进入下一个周期,且已针对所述下一个周期完成了令牌增加操作,则将所述全局连续丢包状态设置为关闭状态;或者,当所述全局连续丢包状态为打开状态的持续时长为预设时长时,将所述全局连续丢包状态设置为关闭状态。The second setting unit is configured to: if the global continuous packet loss status is the open state, if it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then The global continuous packet loss state is set to the off state; or, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
可选的,所述判断单元,还用于在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,判断当前内核的子令牌桶内令牌数是否为M的 倍数;M为正整数;若所述令牌数是M的倍数,则判断所述第一令牌总数是否大于所述第二令牌总数。Optionally, the determining unit is further configured to determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, to determine the sub-commands of the current kernel Whether the number of tokens in the bucket is a multiple of M; M is a positive integer; if the number of tokens is a multiple of M, it is determined whether the total number of first tokens is greater than the total number of second tokens.
可选的,所述保留单元,还用于若当前内核的子令牌桶内令牌数不是M的倍数,则保留所述待处理数据。Optionally, the retaining unit is further configured to retain the to-be-processed data if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M.
可选的,所述判断单元,还用于针对每个周期,判断所述第二令牌总数与所述第一令牌总数之差是否大于承诺突发尺寸;Optionally, the judging unit is further configured to judge whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size for each cycle;
所述增加单元,还用于若大于所述承诺突发尺寸,则更新所述全局令牌桶,使得所述全局令牌桶的第二令牌总数为所述第一令牌总数和所述承若突发尺寸之和;若小于或等于所述承诺突发尺寸,则向所述全局令牌桶内增加N个令牌,所述N为所述承诺信息速率与所述周期之积。The adding unit is further configured to update the global token bucket if it is greater than the committed burst size, so that the total number of second tokens of the global token bucket is the total number of the first token and the total number of tokens. If the sum of burst sizes is assumed; if it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate and the period.
可选的,所述子令牌桶和/或所述全局令牌桶的桶深为无限桶深。Optionally, the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
第三方面,本发明提供了一种存储介质,所述存储介质存储有多条指令,所述指令适用于由处理器加载并执行如第一方面所述的流量限速方法。In a third aspect, the present invention provides a storage medium storing a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the traffic rate limiting method as described in the first aspect.
第四方面,本发明提供了一种电子设备,所述电子设备包括存储介质和处理器;In a fourth aspect, the present invention provides an electronic device, the electronic device including a storage medium and a processor;
所述处理器,适于实现各指令;The processor is suitable for implementing various instructions;
所述存储介质,适于存储多条指令;The storage medium is suitable for storing multiple instructions;
所述指令适于由所述处理器加载并执行如第一方面所述方法。The instructions are adapted to be loaded by the processor and execute the method according to the first aspect.
借由上述技术方案,本发明提供的流量限速方法及装置,能够先创建一个全局令牌桶以及分别为每个内核创建一个子令牌桶,然后周期性地向全局令牌桶中增加令牌,而对于每个子令牌桶,在当前内核接收待处理数据时,通过预设数量的子令牌桶的令牌总数(第一令牌总数)不能超过全局令牌桶的令牌总数(第二令牌总数)为限制条件,来确定当前内核的子令牌桶是否增加令牌(即若第一令牌总数大于第二令牌总数,则丢弃待处理数据,且不会向当前内核的子令牌桶内增加令牌,而若第一令牌总数小于或等于第二令牌总数,则保留待处理数据,并向当前内核的子令牌桶内增加一个令牌),从而不会发生某个子令牌桶内未使用令牌远多于其他子令牌桶的现象,进而实现了对整机的均衡控制,提高了整机限速的准确率。并且由于没有使用锁机制,也不会存在锁机制所造成的锁等待和cache回刷等待问题,进而相比于使用锁机制的现有技术而言,大大提高了限速的效率,提高了系统性能。With the above technical solutions, the traffic rate limiting method and device provided by the present invention can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add commands to the global token bucket. For each sub-token bucket, when the current kernel receives the data to be processed, the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket ( The second total number of tokens) is a limiting condition to determine whether to add tokens to the sub-token bucket of the current kernel (that is, if the total number of first tokens is greater than the total number of second tokens, the data to be processed will be discarded, and the current kernel will not Add tokens in the sub-token bucket of the, and if the total number of the first token is less than or equal to the total number of the second token, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel), so that no It may happen that there are far more unused tokens in a certain sub-token bucket than in other sub-token buckets, thereby achieving balanced control of the whole machine and improving the accuracy of the speed limit of the whole machine. And because the lock mechanism is not used, there will be no lock waiting and cache flush waiting problems caused by the lock mechanism. Compared with the prior art using the lock mechanism, the efficiency of the rate limit is greatly improved, and the system is improved. performance.
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够 更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solution of the present invention. In order to understand the technical means of the present invention more clearly, it can be implemented in accordance with the content of the specification, and in order to make the above and other objectives, features and advantages of the present invention more obvious and understandable. In the following, specific embodiments of the present invention are specifically cited.
附图说明Description of the drawings
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only used for the purpose of illustrating the preferred embodiments, and are not considered as a limitation to the present invention. Also, throughout the drawings, the same reference symbols are used to denote the same components. In the attached picture:
图1示出了本发明实施例提供的一种流量限速方法的流程图;Figure 1 shows a flow chart of a flow rate limiting method provided by an embodiment of the present invention;
图2示出了本发明实施例提供的另一种流量限速方法的流程图;Figure 2 shows a flow chart of another method for traffic rate limiting according to an embodiment of the present invention;
图3示出了本发明实施例提供的又一种流量限速方法的流程图;FIG. 3 shows a flowchart of yet another method for traffic rate limiting according to an embodiment of the present invention;
图4示出了本发明实施例提供的再一种流量限速方法的流程图;FIG. 4 shows a flow chart of still another method for traffic rate limiting according to an embodiment of the present invention;
图5示出了本发明实施例提供的一种流量限速装置的组成框图;Figure 5 shows a block diagram of a flow rate limiting device provided by an embodiment of the present invention;
图6示出了本发明实施例提供的另一种流量限速装置的组成框图。Fig. 6 shows a block diagram of another flow rate limiting device provided by an embodiment of the present invention.
具体实施方式Detailed ways
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Hereinafter, exemplary embodiments of the present disclosure will be described in more detail with reference to the accompanying drawings. Although the drawings show exemplary embodiments of the present disclosure, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
为了提高限速效率和限速准确率,本发明实施例提供了一种全局令牌桶和各内核子令牌桶相结合,并使用全局令牌桶控制子令牌桶令牌数的流量限速方法,所述方法主要应用于单个内核侧,如图1所示,所述方法主要包括:In order to improve the speed limit efficiency and the speed limit accuracy rate, the embodiment of the present invention provides a combination of a global token bucket and each kernel sub-token bucket, and uses the global token bucket to control the flow limit of the number of tokens in the sub-token bucket. Fast method, the method is mainly applied to a single core side, as shown in Figure 1, the method mainly includes:
101、接收发送的待处理数据。101. Receive and send data to be processed.
本发明实施例可以应用于任何一种网络项目中,该项目中可以设置具有安全限速功能的多核网络设备,并由该网络设备对外部发过来的待处理数据进行限速操作。其中,待处理数据在数据格式上可以为报文,也可以为数据包等,在内容上可以为请求,也可以为非请求,本发明实施例对交互的具体数据的格式以及数据内容不做限定。例如,在对报文进行处理领域,本发明实施例可以实现对报文发送频率进行限制,也可以实现对报文转发频率进行限制。The embodiments of the present invention can be applied to any kind of network project. A multi-core network device with a safe speed limit function can be set in the project, and the network device can perform a speed limit operation on the data to be processed from the outside. Among them, the data to be processed can be a message or a data packet in the data format, and can be a request or non-request in the content. The embodiment of the present invention does not deal with the specific data format and data content of the interaction. limited. For example, in the field of processing messages, the embodiments of the present invention can implement restrictions on the frequency of message sending, and can also implement restrictions on the frequency of message forwarding.
102、判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;若所述第一令牌总数大于所述第二令牌总数,则执行步骤103;若所述第一令牌 总数小于或等于所述第二令牌总数,则执行步骤104。102. Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 103; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 104.
其中,每个内核对应一个子令牌桶,且不同内核对应不同的子令牌桶。所述全局令牌桶内的令牌是周期性增加的(可以指定其中一个内核对全局令牌桶进行令牌增加操作),而子令牌桶内的令牌是通过执行步骤101-104的方式增加的。全局令牌桶和/或子令牌桶的桶深可以为无限桶深,即令牌数只增不减,且可以无限增加。Among them, each core corresponds to a sub-token bucket, and different cores correspond to different sub-token buckets. The tokens in the global token bucket are added periodically (one of the kernels can be designated to perform the token increase operation on the global token bucket), and the tokens in the sub-token bucket are executed by performing steps 101-104 Way to increase. The bucket depth of the global token bucket and/or sub-token bucket can be infinite bucket depth, that is, the number of tokens can only increase without decreasing, and can increase indefinitely.
为了使用全局令牌桶来控制子令牌桶的流量,从而提高限速效率和准确率,可以将预设数量的子令牌桶内累加的第一令牌总数和全局令牌桶内的第二令牌总数进行比较,并通过不同比较结果来确定待处理数据的丢弃与保留。在实际应用中,预设数量可以根据限速效率和限速准确率的需求而定。限速准确率要求越高,预设数量越多,例如当预设数量为所有子令牌桶的总和时的限速准确率比其他数量的限速准确率要高,但比其他数量的限速效率可能会低一些。在具体实施时,可以根据预设条件来确定需要进行累加得到第一令牌总数的子令牌桶。其中,预设条件包括但不限于令牌数大于预设阈值的子令牌桶、令牌数位于前N(N为正整数)名的子令牌桶。In order to use the global token bucket to control the flow of the sub-token buckets, thereby improving the rate limiting efficiency and accuracy, the total number of first tokens accumulated in the preset number of sub-token buckets can be combined with the total number of first tokens in the global token bucket. The total number of the two tokens is compared, and the discarding and retention of the data to be processed is determined through different comparison results. In practical applications, the preset number can be determined according to the requirements of speed limit efficiency and speed limit accuracy. The higher the speed limit accuracy requirement, the greater the preset number. For example, when the preset number is the sum of all sub-token buckets, the speed limit accuracy rate is higher than that of other numbers, but it is higher than other number limits. The speed efficiency may be lower. In specific implementation, the sub-token bucket that needs to be accumulated to obtain the first total number of tokens can be determined according to a preset condition. The preset conditions include, but are not limited to, sub-token buckets with a number of tokens greater than a preset threshold, and sub-token buckets with a number of tokens in the top N (N is a positive integer).
对于统计预设数量的子令牌桶累加的第一令牌总数而言,可以在预设存储空间存储一个第一令牌总数,若某一子令牌桶增加了一个令牌,就更新一下该预设存储空间存储的第一令牌总数,当需要与第二令牌总数比较时,可以直接从该预设存储空间读取第一令牌总数。也可以创建一个临时令牌桶,子令牌桶增加一个令牌,就向该临时令牌桶中增加一个令牌,当需要与第二令牌总数比较时,就统计一下临时令牌桶中的令牌数作为第一令牌总数。For the total number of first tokens accumulated by the preset number of sub-token buckets, a total number of first tokens can be stored in the preset storage space. If a token is added to a certain sub-token bucket, update it When the total number of first tokens stored in the preset storage space needs to be compared with the total number of second tokens, the total number of first tokens can be directly read from the preset storage space. You can also create a temporary token bucket, add a token to the sub-token bucket, add a token to the temporary token bucket, and when you need to compare with the total number of second tokens, count the temporary token bucket The number of tokens as the first total number of tokens.
子令牌桶的令牌是根据发过来的待处理数据情况增加的,若长期没有待处理数据发送过来,或者长期接收到的待处理数据相对较少,而全局令牌桶的令牌会一直周期性增加,从而会造成全局令牌桶内的第二令牌总数远远大于预设数量的子令牌桶累加的第一令牌总数,此时若突然来大量的待处理数据,根据本发明实施例的判断机制,是允许保留这些待处理数据的,进而会造成内核负载突增而发生宕机等故障。为了避免发生该技术问题,可以采用如下方法对全局令牌桶进行周期性增加令牌:The tokens of the sub-token bucket are increased according to the data to be processed. If there is no data to be processed for a long time, or the data to be processed is received for a long time, the tokens of the global token bucket will always be Increase periodically, which will cause the total number of second tokens in the global token bucket to be much larger than the total number of first tokens accumulated by the preset number of sub-token buckets. The judgment mechanism of the embodiment of the invention allows the data to be processed to be retained, which may cause a sudden increase in the load of the kernel and cause failures such as downtime. To avoid this technical problem, the following methods can be used to periodically add tokens to the global token bucket:
针对每个周期,判断所述第二令牌总数与所述第一令牌总数之差是否大于承诺突发尺寸(Committed Burst Size,CBS);若大于所述承诺突发尺寸,则更新所述全局令牌桶,使得所述全局令牌桶的第二令牌总数为所述第一令牌总数和所述承若突发尺寸之和;若小于或等于所述承诺突发尺寸,则向所述全局令牌桶内增加N个令牌,所述N为所述承诺信息速率(Committed Information Rate,CIR)与所述周期之积。For each cycle, determine whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size (Committed Burst Size, CBS); if it is greater than the committed burst size, update the Global token bucket, so that the total number of second tokens in the global token bucket is the sum of the total number of first tokens and the acceptable burst size; if it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate (Committed Information Rate, CIR) and the period.
其中,承诺突发尺寸也称承诺突发量,是指在正常状态下和一定时间间隔内,网络允许在虚电路上传送的数据总量。本发明实施例通过控制全局令牌桶的第二令牌总数不超过所述第一令牌总数和所述承若突发尺寸之和,可以控制一段时间间隔内允许保留的待处理数据总量不会超过承若突发尺寸所表征的数据量,使得突发量得到限制,避免突增导致内核无法承受而发生故障。Among them, the committed burst size is also called the committed burst volume, which refers to the total amount of data that the network allows to transmit on the virtual circuit in a normal state and within a certain time interval. In the embodiment of the present invention, by controlling the total number of second tokens in the global token bucket not to exceed the sum of the total number of first tokens and the burst size, the total amount of data to be processed that is allowed to be retained within a period of time can be controlled. It will not exceed the amount of data represented by the burst size, so that the burst size is limited, and the sudden increase will prevent the core from being unable to withstand the failure.
承诺信息速率是由用户与网络双方约定的正常状态下的虚电路信息传送速率。若所述第二令牌总数与所述第一令牌总数之差小于或等于承诺突发尺寸,则可以按照承诺信息速率向全局令牌桶中增加令牌,即每个周期允许增加的令牌数N可以为承诺信息速率与周期之积。当承诺信息速率用CIR表示,周期用T表示时,N=CIR*T。The committed information rate is the virtual circuit information transmission rate under the normal state agreed by the user and the network. If the difference between the total number of second tokens and the total number of first tokens is less than or equal to the committed burst size, tokens can be added to the global token bucket according to the committed information rate, that is, the increase allowed in each cycle The number of cards N can be the product of the committed information rate and the period. When the committed information rate is represented by CIR and the period is represented by T, N=CIR*T.
需要补充的是,在为各内核的子令牌桶分配内存时,可以尽量隔开并解耦,以尽可能减少cache占用的冲突。What needs to be added is that when allocating memory for the sub-token buckets of each kernel, it can be separated and decoupled as much as possible to minimize conflicts occupied by the cache.
103、丢弃所述待处理数据。103. Discard the to-be-processed data.
若所述第一令牌总数大于所述第二令牌总数,则可以通过丢弃所述待处理数据,达到全局令牌桶控制子令牌桶的功能,从而实现对整机的限速。If the total number of first tokens is greater than the total number of second tokens, the function of controlling the sub-token bucket of the global token bucket can be achieved by discarding the data to be processed, thereby realizing the speed limit of the whole machine.
104、保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。104. Keep the data to be processed, and add a token to the sub-token bucket of the current kernel.
若所述第一令牌总数小于或者等于所述第二令牌总数,则此时预设数量的子令牌桶的令牌累加还未达到整机允许的上线,故可以将本次接收到的待处理数据保留下来,并通过向当前内核的子令牌桶内增加一个令牌,将增加的令牌分配给该待处理数据使用。其中,保留待处理数据的具体实现方式可以为将该待处理数据加入到当前内核所对应的缓存队列中,以便后续对其进行处理。If the total number of first tokens is less than or equal to the total number of second tokens, the total number of tokens in the preset number of sub-token buckets has not yet reached the online allowed by the whole machine, so the received tokens this time can be received The data to be processed is retained, and by adding a token to the sub-token bucket of the current kernel, the added token is allocated to the data to be processed. Wherein, the specific implementation manner of retaining the data to be processed may be to add the data to be processed into the cache queue corresponding to the current kernel, so that it can be subsequently processed.
本发明实施例提供的流量限速方法,能够先创建一个全局令牌桶以及分别为每个内核创建一个子令牌桶,然后周期性地向全局令牌桶中增加令牌,而对于每个子令牌桶,在当前内核接收待处理数据时,通过预设数量的子令牌桶的令牌总数(第一令牌总数)不能超过全局令牌桶的令牌总数(第二令牌总数)为限制条件,来确定当前内核的子令牌桶是否增加令牌(即若第一令牌总数大于第二令牌总数,则丢弃待处理数据,且不会向当前内核的子令牌桶内增加令牌,而若第一令牌总数小于或等于第二令牌总数,则保留待处理数据,并向当前内核的子令牌桶内增加一个令牌),从而不会发生某个子令牌桶内未使用令牌远多于其他子令牌桶的现象,进而实现了对整机的均衡控制,提高了整机限速的准确率。并且由于没有使用锁机制,也不会存在锁机制所造成的锁等待和cache回刷等待问题,进而相比于使用锁机制的现有技术而言,大大提高了限速的效率,提高 了系统性能。The traffic rate limiting method provided by the embodiment of the present invention can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add tokens to the global token bucket, and for each sub-token bucket Token bucket, when the current kernel receives data to be processed, the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket (the total number of second tokens) As a restriction, determine whether to add tokens to the sub-token bucket of the current kernel (that is, if the total number of the first token is greater than the total number of the second token, the data to be processed will be discarded, and will not be added to the sub-token bucket of the current kernel. Add tokens, and if the total number of first tokens is less than or equal to the total number of second tokens, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel, so that a certain sub-token will not occur The phenomenon that there are far more unused tokens in the bucket than other sub-token buckets, thereby realizing the balanced control of the whole machine, and improving the accuracy of the speed limit of the whole machine. And because the lock mechanism is not used, there will be no lock waiting and cache flush waiting problems caused by the lock mechanism. Compared with the prior art using the lock mechanism, the efficiency of the rate limit is greatly improved, and the system is improved. performance.
可选的,为了进一步提高限速效率,本发明实施例提供了如下三种方法:Optionally, in order to further improve the rate limiting efficiency, the embodiment of the present invention provides the following three methods:
方法一:如图2所示,所述方法主要包括:Method 1: As shown in Figure 2, the method mainly includes:
201、接收发送的待处理数据。201. Receive and send data to be processed.
本步骤的具体实现方式与上述步骤101相同,在此不再赘述。The specific implementation of this step is the same as that of step 101, and will not be repeated here.
202、判断全局连续丢包状态是否为打开状态。202. Determine whether the global continuous packet loss state is an open state.
其中,全局连续丢包状态是一种用于控制全局进行丢包的参数,即在被打开时,用于指示每个内核收到新的待处理数据后,都必须将其丢弃,也不用向子令牌桶中增加令牌。Among them, the global continuous packet loss status is a parameter used to control global packet loss, that is, when it is turned on, it is used to instruct each core to discard new data to be processed after it is received, and there is no need to send it to Add tokens to the sub-token bucket.
由于全局连续丢包状态是全局参数,且当其为打开状态时,无论判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数,内核均需要丢弃新接收到的待处理数据,所以在接收到发送的待处理数据后,通过先判断全局连续丢包状态是否为打开状态,来避免浪费时间和资源进行令牌总数判断。Since the global continuous packet loss status is a global parameter, and when it is in the open state, no matter whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the kernel Both need to discard the newly received pending data, so after receiving the sent pending data, first judge whether the global continuous packet loss status is the open state to avoid wasting time and resources to judge the total number of tokens.
203、若所述全局连续丢包状态为打开状态,则丢弃所述待处理数据。203. If the global continuous packet loss state is an open state, discard the to-be-processed data.
在全局连续丢包状态被打开状态后,新接收的待处理数据均会被丢弃,故子令牌桶也会停止增加令牌,但是全局令牌桶还会周期性地增加令牌,所以若全局连续丢包状态一直处于被打开状态,则会出现全局令牌桶内的第二令牌总数远远大于预设数量的子令牌桶累加的第一令牌总数的情况,由此会出现无法及时应对新数据突增的现象。为了解决问题,可以在特定条件下,再将全局连续丢包状态设置为关闭状态。其中,相对较佳的时机是:若确定所述全局令牌桶进入下一个周期,且已针对所述下一个周期完成了令牌增加操作,则将所述全局连续丢包状态设置为关闭状态。在对整机限速准确率影响不大的情况下,也可以选择其他时机将全局连续丢包状态设置为关闭状态,例如,可以在全局连续丢包状态为打开状态的持续时长达到预设时长时,就将所述全局连续丢包状态设置为关闭状态。After the global continuous packet loss status is turned on, the newly received pending data will be discarded, so the sub-token bucket will also stop adding tokens, but the global token bucket will also periodically add tokens, so if If the global continuous packet loss status is always turned on, the total number of second tokens in the global token bucket is much larger than the total number of first tokens accumulated by the preset number of sub-token buckets, which will happen Unable to respond to the sudden increase in new data in a timely manner. In order to solve the problem, under certain conditions, the global continuous packet loss state can be set to the off state. Among them, a relatively good time is: if it is determined that the global token bucket enters the next cycle, and the token increase operation has been completed for the next cycle, then the global continuous packet loss state is set to the off state . In the case of little impact on the accuracy of the overall speed limit, you can also choose another time to set the global continuous packet loss state to the off state. For example, you can set the global continuous packet loss state to the on state for a preset duration. At this time, the global continuous packet loss state is set to the off state.
204、若所述全局连续丢包状态为关闭状态,则判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数。204. If the global continuous packet loss state is the off state, determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket.
若所述全局连续丢包状态为关闭状态,则全局没有对丢包进行强制控制,所以需要通过判断第一令牌总数与第二令牌总数的大小来确定是丢弃待处理数据,还是保留待处理数据。If the global continuous packet loss status is off, there is no mandatory control on packet loss globally. Therefore, it is necessary to determine whether to discard the data to be processed or keep the data to be processed by judging the total number of the first token and the total number of the second token. Data processing.
205、若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据,将所述 全局连续丢包状态设置为打开状态。205. If the total number of first tokens is greater than the total number of second tokens, discard the to-be-processed data, and set the global continuous packet loss state to an open state.
由于在全局令牌桶进行周期性增加令牌时,在一个周期内,可能是需要花费该周期的前一部分时间就可以完成本次令牌增加操作,而在该周期剩余时间内,全局令牌桶的第二令牌总数不会发生变化,所以在这段剩余时间内,一旦发生预设数量的子令牌桶累加的第一令牌总数大于所述第二令牌总数,则从该发生时刻(可称为第一发生时刻)起直至下次向全局令牌桶增加令牌之前,无论是否进行判断,得到的结论均是第一令牌总数大于第二令牌总数,均需要对待处理数据进行丢弃处理。为了节省判断资源和判断时间,可以将全局连续丢包状态设置为打开状态,以便后续接收到新的待处理数据时,可以直接根据全局连续丢包状态来进行丢弃处理。Because when tokens are added periodically in the global token bucket, in a cycle, it may take the first part of the cycle to complete the token increase operation, and during the remaining time of the cycle, the global token The total number of second tokens in the bucket will not change, so during the remaining time, once the total number of first tokens accumulated by the preset number of sub-token buckets is greater than the total number of second tokens, then From the moment (may be called the first occurrence moment) until the next token is added to the global token bucket, no matter whether the judgment is made, the conclusion is that the total number of first tokens is greater than the total number of second tokens, and it needs to be processed The data is discarded. In order to save judgment resources and judgment time, the global continuous packet loss status can be set to the on state, so that when new data to be processed is subsequently received, the global continuous packet loss status can be directly discarded.
其中,可以在首次判断结果为所述第一令牌总数大于所述第二令牌总数时,就将所述全局连续丢包状态设置为打开状态,也可以在第X(X大于1)次判断结果为所述第一令牌总数大于所述第二令牌总数时,才将所述全局连续丢包状态设置为打开状态,只要能够保证将所述全局连续丢包状态设置为打开状态的时机在所述第一发生时刻起直至下次向全局令牌桶增加令牌之前就可以在一定程度上节省判断资源和判断时间,进而在一定程度上提高限度效率。Wherein, when the first judgment result is that the total number of first tokens is greater than the total number of second tokens, the global continuous packet loss state may be set to the on state, or it may be set to the open state at the Xth (X is greater than 1) time The judgment result is that when the total number of first tokens is greater than the total number of second tokens, the global continuous packet loss status is set to the open state, as long as the global continuous packet loss status can be guaranteed to be set to the open state. The timing can save judgment resources and judgment time to a certain extent from the moment of the first occurrence until the next time before adding tokens to the global token bucket, thereby improving the limited efficiency to a certain extent.
206、若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。206. If the total number of first tokens is less than or equal to the total number of second tokens, retain the data to be processed, and add a token to the sub-token bucket of the current kernel.
本步骤的具体实现方式与上述步骤104相同,在此不再赘述。The specific implementation of this step is the same as that of step 104, and will not be repeated here.
本发明实施例提供的流量限速方法,在图1所示的实施例的基础上,通过启用全局连续丢包状态,并且只有在全局连续丢包状态为关闭状态时,才进行丢/留决策,而在全局连续丢包状态为打开状态时,直接丢弃待处理数据,从而可以减少丢/留决策的判断次数,进而可以在提高整机限速的准确率基础上,进一步提高限速效率。The traffic rate limiting method provided by the embodiment of the present invention is based on the embodiment shown in FIG. , And when the global continuous packet loss status is on, the data to be processed is directly discarded, which can reduce the number of judgments for loss/retention decisions, and further improve the speed limit efficiency on the basis of improving the accuracy of the overall speed limit.
方法二:如图3所示,所述方法主要包括:Method 2: As shown in Figure 3, the method mainly includes:
301、接收发送的待处理数据。301. Receive and send data to be processed.
本步骤的具体实现方式与上述步骤101相同,在此不再赘述。The specific implementation of this step is the same as that of step 101, and will not be repeated here.
302、判断当前内核的子令牌桶内令牌数是否为M的倍数;若所述令牌数不是M的倍数,则执行步骤303;若所述令牌数是M的倍数,则执行步骤304。302. Determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M; if the number of tokens is not a multiple of M, perform step 303; if the number of tokens is a multiple of M, perform step 304.
其中,M为正整数,M的具体取值可以根据历史经验而定。Among them, M is a positive integer, and the specific value of M can be determined based on historical experience.
由于各内核的子令牌桶和全局令牌桶中的令牌数都是累加的,所以每隔M个待处理数据进行一次令牌总数判断(即丢/留决策),而中间的待处理数据直接保留时,即使某 个周期(M个数据为一个周期)多收了Y个数据,在之后的周期中也会因为第二令牌总数对第一令牌总数的限制,丢弃新来的数据,即之后的周期中也会减少Y个数据,所以对于整机来说,其限速准确率是几乎不变的。因此,在接收到待处理数据时,可以先判断当前内核的子令牌桶内令牌数是否为M的倍数,若不是,则可以直接将其保留,并向当前内核的子令牌桶内增加一个令牌(即步骤303),若是,则再进行令牌总数判断,基于令牌总数判断结果对该待处理数据进行丢/留决策(即步骤304->305->303)。Since the number of tokens in the sub-token bucket and global token bucket of each core is cumulative, the total number of tokens is judged every M pieces of data to be processed (that is, the decision to lose/leave), and the middle to be processed When the data is directly retained, even if Y data is received in a certain period (M data is a period), in the following periods, the new arrival will be discarded due to the limit of the total number of second tokens to the total number of first tokens. Data, that is, Y data will be reduced in the subsequent cycle, so for the whole machine, its speed limit accuracy rate is almost unchanged. Therefore, when receiving the data to be processed, you can first determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M, if not, you can directly keep it and send it to the sub-token bucket of the current kernel. Add a token (that is, step 303), if it is, then perform a judgment of the total number of tokens, and make a decision to discard/retain the data to be processed based on the result of the judgment of the total number of tokens (that is, step 304->305->303).
303、保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。303. Keep the data to be processed, and add a token to the sub-token bucket of the current kernel.
本步骤的具体实现方式与上述步骤104相同,在此不再赘述。The specific implementation of this step is the same as that of step 104, and will not be repeated here.
304、判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;若所述第一令牌总数大于所述第二令牌总数,则执行步骤305;若所述第一令牌总数小于或等于所述第二令牌总数,则执行步骤303。304. Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 305; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 303.
305、丢弃所述待处理数据。305. Discard the to-be-processed data.
本发明实施例提供的流量限速方法,在图1所示的实施例的基础上,每隔M个待处理数据,进行一次丢/留决策,而对中间的待处理数据直接进行保留,可以减少丢/留决策的判断次数,从而可以在提高整机限速的准确率基础上,进一步提高限速效率。According to the flow rate limiting method provided by the embodiment of the present invention, on the basis of the embodiment shown in FIG. 1, a drop/leave decision is made every M pieces of to-be-processed data, and the intermediate to-be-processed data can be directly reserved. Reduce the number of times of decision-making for loss/retention, which can further improve the speed limit efficiency on the basis of improving the accuracy of the whole machine speed limit.
方法三:由于方法一是从全局层面来提高限速效率,方法二是从单核层面来提高限速效率,且两者没有依赖和矛盾,所以可以将两者相结合形成方法三,来进一步提高限速效率,如图4所示,所述方法包括:Method 3: Since the first method is to improve the rate-limiting efficiency from a global level, and the second method is to improve the rate-limiting efficiency from a single-core level, and there is no dependence and contradiction between the two, the two can be combined to form the third method to further To improve the speed limit efficiency, as shown in Figure 4, the method includes:
401、接收发送的待处理数据。401. Receive sent data to be processed.
402、判断全局连续丢包状态是否为打开状态;若所述全局连续丢包状态为打开状态,则执行步骤403;若所述全局连续丢包状态为关闭状态,则执行步骤404。402. Determine whether the global continuous packet loss state is an open state; if the global continuous packet loss state is an open state, perform step 403; if the global continuous packet loss state is an off state, perform step 404.
403、丢弃所述待处理数据。403. Discard the to-be-processed data.
404、判断当前内核的子令牌桶内令牌数是否为M的倍数;若所述令牌数不是M的倍数,则执行步骤405;若所述令牌数是M的倍数,则执行步骤406。404. Determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M; if the number of tokens is not a multiple of M, perform step 405; if the number of tokens is a multiple of M, perform step 406.
405、保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。405. Keep the data to be processed, and add a token to the sub-token bucket of the current kernel.
406、判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;若所述第一令牌总数大于所述第二令牌总数,则执行步骤407;若所述第一令牌总数小于或等于所述第二令牌总数,则执行步骤405。406. Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; if the total number of first tokens is greater than the total number of second tokens, then Go to step 407; if the total number of first tokens is less than or equal to the total number of second tokens, go to step 405.
407、丢弃所述待处理数据,将所述全局连续丢包状态设置为打开状态。407. Discard the to-be-processed data, and set the global continuous packet loss state to an open state.
进一步的,依据上述方法实施例,本发明的另一个实施例还提供了一种流量限速装 置,如图5所示,所述装置包括:Further, according to the above method embodiment, another embodiment of the present invention also provides a flow rate limiting device. As shown in Fig. 5, the device includes:
接收单元51,用于接收发送的待处理数据;The receiving unit 51 is configured to receive sent data to be processed;
判断单元52,用于判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;不同内核对应不同的子令牌桶,所述全局令牌桶内的令牌是周期性增加的;The judging unit 52 is configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different kernels correspond to different sub-token buckets, and the global command The tokens in the bucket are increased periodically;
丢弃单元53,用于若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据;The discarding unit 53 is configured to discard the to-be-processed data if the total number of the first tokens is greater than the total number of the second tokens;
保留单元54,用于若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据;The retaining unit 54 is configured to retain the data to be processed if the total number of the first tokens is less than or equal to the total number of the second tokens;
增加单元55,用于若保留所述待处理数据,则向当前内核的子令牌桶内增加一个令牌。The adding unit 55 is configured to add a token to the sub-token bucket of the current kernel if the data to be processed is retained.
可选的,所述判断单元52,还用于在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,判断全局连续丢包状态是否为打开状态;若所述全局连续丢包状态为关闭状态,则判断所述第一令牌总数是否大于所述第二令牌总数。Optionally, the judging unit 52 is further configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, to determine the global continuous packet loss Whether the state is an open state; if the global continuous packet loss state is an off state, it is determined whether the total number of first tokens is greater than the total number of second tokens.
可选的,如图6所示,所述装置还包括:Optionally, as shown in FIG. 6, the device further includes:
第一设置单元56,用于若所述第一令牌总数大于所述第二令牌总数,则将所述全局连续丢包状态设置为打开状态。The first setting unit 56 is configured to set the global continuous packet loss state to an open state if the total number of first tokens is greater than the total number of second tokens.
可选的,所述丢弃单元53,还用于若所述全局连续丢包状态为打开状态,则丢弃所述待处理数据。Optionally, the discarding unit 53 is further configured to discard the to-be-processed data if the global continuous packet loss state is an open state.
可选的,如图6所示,所述装置还包括:Optionally, as shown in FIG. 6, the device further includes:
第二设置单元57,用于若所述全局连续丢包状态为打开状态,则若确定所述全局令牌桶进入下一个周期,且已针对所述下一个周期完成了令牌增加操作,则将所述全局连续丢包状态设置为关闭状态;或者,当所述全局连续丢包状态为打开状态的持续时长为预设时长时,将所述全局连续丢包状态设置为关闭状态。The second setting unit 57 is configured to, if the global continuous packet loss state is the open state, if it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then The global continuous packet loss state is set to the off state; or, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
可选的,所述判断单元52,还用于在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,判断当前内核的子令牌桶内令牌数是否为M的倍数;M为正整数;若所述令牌数是M的倍数,则判断所述第一令牌总数是否大于所述第二令牌总数。Optionally, the judging unit 52 is further configured to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, before judging the sub-tokens of the current kernel. Whether the number of tokens in the token bucket is a multiple of M; M is a positive integer; if the number of tokens is a multiple of M, it is determined whether the total number of first tokens is greater than the total number of second tokens.
可选的,所述保留单元54,还用于若当前内核的子令牌桶内令牌数不是M的倍数, 则保留所述待处理数据。Optionally, the retaining unit 54 is further configured to retain the to-be-processed data if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M.
可选的,所述判断单元52,还用于针对每个周期,判断所述第二令牌总数与所述第一令牌总数之差是否大于承诺突发尺寸;Optionally, the judging unit 52 is further configured to judge whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size for each cycle;
所述增加单元55,还用于若大于所述承诺突发尺寸,则更新所述全局令牌桶,使得所述全局令牌桶的第二令牌总数为所述第一令牌总数和所述承若突发尺寸之和;若小于或等于所述承诺突发尺寸,则向所述全局令牌桶内增加N个令牌,所述N为所述承诺信息速率与所述周期之积。The adding unit 55 is further configured to update the global token bucket if it is larger than the committed burst size, so that the total number of second tokens in the global token bucket is the total number of the first tokens and the total number of tokens. If the sum of burst sizes is assumed; if it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate and the period .
可选的,所述子令牌桶和/或所述全局令牌桶的桶深为无限桶深。Optionally, the bucket depth of the sub-token bucket and/or the global token bucket is infinite bucket depth.
本发明实施例提供的流量限速装置,能够先创建一个全局令牌桶以及分别为每个内核创建一个子令牌桶,然后周期性地向全局令牌桶中增加令牌,而对于每个子令牌桶,在当前内核接收待处理数据时,通过预设数量的子令牌桶的令牌总数(第一令牌总数)不能超过全局令牌桶的令牌总数(第二令牌总数)为限制条件,来确定当前内核的子令牌桶是否增加令牌(即若第一令牌总数大于第二令牌总数,则丢弃待处理数据,且不会向当前内核的子令牌桶内增加令牌,而若第一令牌总数小于或等于第二令牌总数,则保留待处理数据,并向当前内核的子令牌桶内增加一个令牌),从而不会发生某个子令牌桶内未使用令牌远多于其他子令牌桶的现象,进而实现了对整机的均衡控制,提高了整机限速的准确率。并且由于没有使用锁机制,也不会存在锁机制所造成的锁等待和cache回刷等待问题,进而相比于使用锁机制的现有技术而言,大大提高了限速的效率,提高了系统性能。在此基础上,通过启用全局连续丢包状态,并且只有在全局连续丢包状态为关闭状态时,才进行丢/留决策,而在全局连续丢包状态为打开状态时,直接丢弃待处理数据,从而可以减少丢/留决策的判断次数,若每隔M个待处理数据,进行一次丢/留决策,而对中间的待处理数据直接进行保留,也可以减少丢/留决策的判断次数,进而可以在提高整机限速的准确率基础上,进一步提高限速效率。The flow rate limiting device provided by the embodiment of the present invention can first create a global token bucket and create a sub-token bucket for each core respectively, and then periodically add tokens to the global token bucket, and for each sub-token bucket Token bucket, when the current kernel receives the data to be processed, the total number of tokens passing through the preset number of sub-token buckets (the total number of first tokens) cannot exceed the total number of tokens in the global token bucket (the total number of second tokens) It is a restriction condition to determine whether to add tokens to the sub-token bucket of the current kernel (that is, if the total number of the first token is greater than the total number of the second token, the data to be processed will be discarded, and will not be added to the sub-token bucket of the current kernel. Add tokens, and if the total number of first tokens is less than or equal to the total number of second tokens, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel, so that a certain sub-token will not occur The phenomenon that there are far more unused tokens in the bucket than other sub-token buckets, thereby realizing the balanced control of the whole machine, and improving the accuracy of the speed limit of the whole machine. And because the lock mechanism is not used, there will be no lock waiting and cache flush waiting problems caused by the lock mechanism. Compared with the prior art using the lock mechanism, the efficiency of the rate limit is greatly improved, and the system is improved. performance. On this basis, by enabling the global continuous packet loss state, and only when the global continuous packet loss state is off, the loss/retention decision is made, and when the global continuous packet loss state is on, the pending data is directly discarded , Which can reduce the number of judgments of the loss/retention decision. If every M pieces of data to be processed, a loss/retention decision is made, and the intermediate data to be processed is directly retained, which can also reduce the number of judgments of the loss/retention decision. Furthermore, on the basis of improving the accuracy of the speed limit of the whole machine, the speed limit efficiency can be further improved.
进一步的,本发明的另一个实施例还提供了一种存储介质,所述存储介质存储有多条指令,所述指令适用于由处理器加载并执行如上所述的流量限速方法。Further, another embodiment of the present invention also provides a storage medium, the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the above-mentioned flow rate limiting method.
进一步的,本发明的另一个实施例还提供了一种电子设备,所述电子设备包括存储介质和处理器;Further, another embodiment of the present invention also provides an electronic device, the electronic device including a storage medium and a processor;
所述处理器,适于实现各指令;The processor is suitable for implementing various instructions;
所述存储介质,适于存储多条指令;The storage medium is suitable for storing multiple instructions;
所述指令适于由所述处理器加载并执行如上所述的流量限速方法。The instructions are adapted to be loaded by the processor and execute the traffic rate limiting method as described above.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in an embodiment, reference may be made to related descriptions of other embodiments.
可以理解的是,上述方法及装置中的相关特征可以相互参考。另外,上述实施例中的“第一”、“第二”等是用于区分各实施例,而并不代表各实施例的优劣。It can be understood that the relevant features in the above method and device can be referred to each other. In addition, the “first”, “second”, etc. in the foregoing embodiments are used to distinguish the embodiments, and do not represent the advantages and disadvantages of the embodiments.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of the description, the specific working process of the above-described system, device, and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的一个实施方式。The algorithms and displays provided here are not inherently related to any particular computer, virtual system or other equipment. Various general-purpose systems can also be used with the teaching based on this. Based on the above description, the structure required to construct this type of system is obvious. In addition, the present invention is not directed to any specific programming language. It should be understood that various programming languages can be used to implement the content of the present invention described herein, and the above description of a specific language is for the purpose of disclosing an embodiment of the present invention.
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the instructions provided here, a lot of specific details are explained. However, it can be understood that the embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures, and technologies are not shown in detail, so as not to obscure the understanding of this specification.
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it should be understood that in order to simplify the present disclosure and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, Figure, or its description. However, the disclosed method should not be interpreted as reflecting the intention that the claimed invention requires more features than those explicitly stated in each claim. More precisely, as reflected in the following claims, the inventive aspect lies in less than all the features of a single embodiment disclosed previously. Therefore, the claims following the specific embodiment are thus explicitly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present invention.
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art can understand that it is possible to adaptively change the modules in the device in the embodiment and set them in one or more devices different from the embodiment. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and/or processes or units are mutually exclusive, any combination can be used to compare all the features disclosed in this specification (including the accompanying claims, abstract and drawings) and any method or methods disclosed in this manner or All the processes or units of the equipment are combined. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中 所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。In addition, those skilled in the art can understand that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features of different embodiments means that they are within the scope of the present invention. Within and form different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的流量限速方法及装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。The various component embodiments of the present invention may be implemented by hardware, or by software modules running on one or more processors, or by a combination of them. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all components in the traffic rate limiting method and device according to the embodiments of the present invention. The present invention can also be implemented as a device or device program (for example, a computer program and a computer program product) for executing part or all of the methods described herein. Such a program for realizing the present invention may be stored on a computer-readable medium, or may have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-mentioned embodiments illustrate rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be constructed as a limitation to the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of multiple such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims listing several devices, several of these devices may be embodied in the same hardware item. The use of the words first, second, and third, etc. do not indicate any order. These words can be interpreted as names.

Claims (12)

  1. 一种流量限速方法,其特征在于,所述方法包括:A flow rate limiting method, characterized in that the method includes:
    接收发送的待处理数据;Receive and send pending data;
    判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;不同内核对应不同的子令牌桶,所述全局令牌桶内的令牌是周期性增加的;Determine whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different cores correspond to different sub-token buckets, and the tokens in the global token bucket Is increasing periodically;
    若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据;If the total number of first tokens is greater than the total number of second tokens, discarding the to-be-processed data;
    若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。If the total number of first tokens is less than or equal to the total number of second tokens, the data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
  2. 根据权利要求1所述的方法,其特征在于,在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,所述方法还包括:The method according to claim 1, wherein before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further comprises :
    判断全局连续丢包状态是否为打开状态;Determine whether the global continuous packet loss status is open;
    所述判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数包括:The determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
    若所述全局连续丢包状态为关闭状态,则判断所述第一令牌总数是否大于所述第二令牌总数。If the global continuous packet loss state is the off state, it is determined whether the total number of first tokens is greater than the total number of second tokens.
  3. 根据权利要求2所述的方法,其特征在于,若所述第一令牌总数大于所述第二令牌总数,则所述方法还包括:The method according to claim 2, wherein if the total number of the first tokens is greater than the total number of the second tokens, the method further comprises:
    将所述全局连续丢包状态设置为打开状态。The global continuous packet loss state is set to an open state.
  4. 根据权利要求2所述的方法,其特征在于,若所述全局连续丢包状态为打开状态,则所述方法还包括:The method according to claim 2, wherein if the global continuous packet loss state is an open state, the method further comprises:
    丢弃所述待处理数据。Discard the to-be-processed data.
  5. 根据权利要求2所述的方法,其特征在于,若所述全局连续丢包状态为打开状态,则所述方法还包括:The method according to claim 2, wherein if the global continuous packet loss state is an open state, the method further comprises:
    若确定所述全局令牌桶进入下一个周期,且已针对所述下一个周期完成了令牌增加操作,则将所述全局连续丢包状态设置为关闭状态;If it is determined that the global token bucket enters the next cycle and the token increase operation has been completed for the next cycle, then the global continuous packet loss state is set to a closed state;
    或者,当所述全局连续丢包状态为打开状态的持续时长为预设时长时,将所述全局连续丢包状态设置为关闭状态。Alternatively, when the duration of the global continuous packet loss state being the on state is a preset duration, the global continuous packet loss state is set to the off state.
  6. 根据权利要求1所述的方法,其特征在于,在判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数之前,所述方法还包括:The method according to claim 1, wherein before determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket, the method further comprises :
    判断当前内核的子令牌桶内令牌数是否为M的倍数;M为正整数;Determine whether the number of tokens in the sub-token bucket of the current kernel is a multiple of M; M is a positive integer;
    所述判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数包括:The determining whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket includes:
    若所述令牌数是M的倍数,则判断所述第一令牌总数是否大于所述第二令牌总数。If the number of tokens is a multiple of M, it is determined whether the total number of the first tokens is greater than the total number of the second tokens.
  7. 根据权利要求6所述的方法,其特征在于,若当前内核的子令牌桶内令牌数不是M的倍数,则所述方法还包括:The method according to claim 6, wherein if the number of tokens in the sub-token bucket of the current kernel is not a multiple of M, the method further comprises:
    保留所述待处理数据,并向当前内核的子令牌桶内增加一个令牌。The data to be processed is retained, and a token is added to the sub-token bucket of the current kernel.
  8. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    针对每个周期,判断所述第二令牌总数与所述第一令牌总数之差是否大于承诺突发尺寸;For each cycle, determine whether the difference between the total number of second tokens and the total number of first tokens is greater than the committed burst size;
    若大于所述承诺突发尺寸,则更新所述全局令牌桶,使得所述全局令牌桶的第二令牌总数为所述第一令牌总数和承若突发尺寸之和;If it is greater than the committed burst size, update the global token bucket so that the total number of second tokens in the global token bucket is the sum of the total number of first tokens and the supported burst size;
    若小于或等于所述承诺突发尺寸,则向所述全局令牌桶内增加N个令牌,N为承诺信息速率与所述周期之积。If it is less than or equal to the committed burst size, then N tokens are added to the global token bucket, where N is the product of the committed information rate and the period.
  9. 根据权利要求1-8中任一项所述的方法,其特征在于,所述子令牌桶和/或所述全局令牌桶的桶深为无限桶深。The method according to any one of claims 1-8, wherein the bucket depth of the sub-token bucket and/or the global token bucket is an infinite bucket depth.
  10. 一种流量限速装置,其特征在于,所述装置包括:A flow rate limiting device, characterized in that the device includes:
    接收单元,用于接收发送的待处理数据;The receiving unit is used to receive the sent data to be processed;
    判断单元,用于判断预设数量的子令牌桶内的第一令牌总数是否大于全局令牌桶内的第二令牌总数;不同内核对应不同的子令牌桶,所述全局令牌桶内的令牌是周期性增加的;The judging unit is used to judge whether the total number of first tokens in the preset number of sub-token buckets is greater than the total number of second tokens in the global token bucket; different kernels correspond to different sub-token buckets, and the global token The tokens in the bucket are periodically increased;
    丢弃单元,用于若所述第一令牌总数大于所述第二令牌总数,则丢弃所述待处理数据;A discarding unit, configured to discard the to-be-processed data if the total number of first tokens is greater than the total number of second tokens;
    保留单元,用于若所述第一令牌总数小于或等于所述第二令牌总数,则保留所述待处理数据;A retention unit, configured to retain the to-be-processed data if the total number of the first tokens is less than or equal to the total number of the second tokens;
    增加单元,用于若保留所述待处理数据,则向当前内核的子令牌桶内增加一个令牌。The adding unit is configured to add a token to the sub-token bucket of the current kernel if the data to be processed is retained.
  11. 一种存储介质,其特征在于,所述存储介质存储有多条指令,所述指令适用于由处理器加载并执行如权利要求1至9中任一项所述的流量限速方法。A storage medium, characterized in that the storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor and executing the flow rate limiting method according to any one of claims 1 to 9.
  12. 一种电子设备,其特征在于,所述电子设备包括存储介质和处理器;An electronic device, characterized in that, the electronic device includes a storage medium and a processor;
    所述处理器,适于实现各指令;The processor is suitable for implementing various instructions;
    所述存储介质,适于存储多条指令;The storage medium is suitable for storing multiple instructions;
    所述指令适于由所述处理器加载并执行如权利要求1至9中任意一项所述的方法。The instructions are adapted to be loaded by the processor and execute the method according to any one of claims 1-9.
PCT/CN2021/082307 2020-03-30 2021-03-23 Traffic rate-limiting method and apparatus WO2021197128A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010238135.7A CN113472681A (en) 2020-03-30 2020-03-30 Flow rate limiting method and device
CN202010238135.7 2020-03-30

Publications (1)

Publication Number Publication Date
WO2021197128A1 true WO2021197128A1 (en) 2021-10-07

Family

ID=77864944

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/082307 WO2021197128A1 (en) 2020-03-30 2021-03-23 Traffic rate-limiting method and apparatus

Country Status (2)

Country Link
CN (1) CN113472681A (en)
WO (1) WO2021197128A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114793216A (en) * 2022-06-22 2022-07-26 北京轻网科技有限公司 Token management and information sending method and device, electronic equipment and storage medium
CN116708310A (en) * 2023-08-08 2023-09-05 北京傲星科技有限公司 Flow control method and device, storage medium and electronic equipment
WO2024108328A1 (en) * 2022-11-21 2024-05-30 Telefonaktiebolaget Lm Ericsson (Publ) Methods and devices for allocating transmission resources using an extended token bucket algorithm

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101674247A (en) * 2009-10-21 2010-03-17 中兴通讯股份有限公司 Method for supervising traffic flow and apparatus thereof
CN102238078A (en) * 2010-05-07 2011-11-09 杭州华三通信技术有限公司 Flow monitoring method and flow monitoring device
US20160142323A1 (en) * 2014-11-17 2016-05-19 Software Ag Systems and/or methods for resource use limitation in a cloud environment
CN109936511A (en) * 2017-12-19 2019-06-25 北京金山云网络技术有限公司 A kind of token acquisition methods, device, server, terminal device and medium
US20190324812A1 (en) * 2015-03-31 2019-10-24 Amazon Technologies, Inc. Burst throttling for multi-tenant storage services

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101227410A (en) * 2008-02-03 2008-07-23 杭州华三通信技术有限公司 Flow monitoring method and flow monitoring equipment
CN101834790B (en) * 2010-04-22 2012-12-19 上海华为技术有限公司 Multicore processor based flow control method and multicore processor
CN102238068B (en) * 2010-05-04 2015-01-28 中兴通讯股份有限公司 Message transmitting method and system
CN104518987A (en) * 2013-09-30 2015-04-15 华为技术有限公司 Method and device for processing parallel multithreading messages
US9639397B1 (en) * 2015-03-31 2017-05-02 Amazon Technologies, Inc. Dynamic burst throttling for multi-tenant storage
US9639398B1 (en) * 2015-03-31 2017-05-02 Amazon Technologies, Inc. Burst throttling with sequential operation detection
CN107579926B (en) * 2017-10-20 2021-02-09 南京易捷思达软件科技有限公司 QoS setting method of Ceph cloud storage system based on token bucket algorithm
FR3078462B1 (en) * 2018-02-23 2020-02-28 Orange METHOD AND DEVICE FOR CONTROLLING ACCESS TO A RESOURCE OF A COMPUTER SYSTEM BY SOFTWARE APPLICATIONS

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101674247A (en) * 2009-10-21 2010-03-17 中兴通讯股份有限公司 Method for supervising traffic flow and apparatus thereof
CN102238078A (en) * 2010-05-07 2011-11-09 杭州华三通信技术有限公司 Flow monitoring method and flow monitoring device
US20160142323A1 (en) * 2014-11-17 2016-05-19 Software Ag Systems and/or methods for resource use limitation in a cloud environment
US20190324812A1 (en) * 2015-03-31 2019-10-24 Amazon Technologies, Inc. Burst throttling for multi-tenant storage services
CN109936511A (en) * 2017-12-19 2019-06-25 北京金山云网络技术有限公司 A kind of token acquisition methods, device, server, terminal device and medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114793216A (en) * 2022-06-22 2022-07-26 北京轻网科技有限公司 Token management and information sending method and device, electronic equipment and storage medium
WO2024108328A1 (en) * 2022-11-21 2024-05-30 Telefonaktiebolaget Lm Ericsson (Publ) Methods and devices for allocating transmission resources using an extended token bucket algorithm
CN116708310A (en) * 2023-08-08 2023-09-05 北京傲星科技有限公司 Flow control method and device, storage medium and electronic equipment
CN116708310B (en) * 2023-08-08 2023-09-26 北京傲星科技有限公司 Flow control method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN113472681A (en) 2021-10-01

Similar Documents

Publication Publication Date Title
WO2021197128A1 (en) Traffic rate-limiting method and apparatus
US8601181B2 (en) System and method for read data buffering wherein an arbitration policy determines whether internal or external buffers are given preference
EP2466824B1 (en) Service scheduling method and device
US7836195B2 (en) Preserving packet order when migrating network flows between cores
US7712103B2 (en) Method and system for managing load balancing in data processing system
US11025745B2 (en) Technologies for end-to-end quality of service deadline-aware I/O scheduling
US10078543B2 (en) Correctable error filtering for input/output subsystem
US20170364266A1 (en) Method and device for managing input/output (i/o) of storage device
JP6580307B2 (en) Multi-core apparatus and job scheduling method for multi-core apparatus
US9632958B2 (en) System for migrating stash transactions
WO2020100581A1 (en) Evaluation device, evaluation method and evaluation program
CN115934625B (en) Doorbell knocking method, equipment and medium for remote direct memory access
WO2021174382A1 (en) Message pulling method and device, and computer storage medium
US11016829B2 (en) Two-layered deterministic interprocess communication scheduler for input output determinism in solid state drives
WO2021046932A1 (en) Message drive method and device based on real-time operating system
US11243603B2 (en) Power management of an event-based processing system
US11228668B2 (en) Efficient packet processing for express data paths
WO2024124737A1 (en) Process switching management method in heterogeneous computing, and computing apparatus
CN114500544A (en) Method, system, equipment and medium for load balancing among nodes
WO2020248857A1 (en) Data congestion control and bandwidth prediction method
WO2017016300A1 (en) Method and apparatus for processing token application, computer storage medium
US7729259B1 (en) Reducing latency jitter in a store-and-forward buffer for mixed-priority traffic
CN106506074A (en) A kind of method and apparatus of detection optical port state
TWI831159B (en) Storage expansion method, apparatus, storage media and electronic device
US20220239767A1 (en) Efficient packet re-transmission for express data paths

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21779539

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21779539

Country of ref document: EP

Kind code of ref document: A1