A time-sharing multi-dimension flow control method based on sliding time stamp
By adopting a time-sharing multi-dimensional flow control method based on sliding timestamps, and utilizing access interval and number control units, combined with timestamp queues and sharding, the contradiction between smoothness and suddenness in flow control is resolved, achieving high-precision flow management, supporting time-sharing switching, and improving system availability and performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI FINANCIAL FUTURES INFORMATION TECH CO LTD
- Filing Date
- 2022-12-20
- Publication Date
- 2026-06-19
AI Technical Summary
Existing flow control algorithms struggle to balance flow smoothness and burstiness, and also suffer from low flow control accuracy.
A time-sharing multi-dimensional flow control method based on sliding timestamps is adopted. By combining the access interval control unit and access count control unit in the time-sharing flow control chain with timestamp queues and time slicing, precise flow control is achieved.
It improves the accuracy of flow control, balances the smoothness and burstiness of flow, supports automatic switching in different time periods, and takes into account both system performance and throughput.
Smart Images

Figure CN116167062B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a flow control method, specifically a time-division multi-dimensional flow control method based on sliding timestamps. Background Technology
[0002] In the computer field, flow control is known as overload protection. "Overload" means that demand exceeds the system's capacity; "protection" refers to taking necessary measures to prevent damage when overload occurs. In the computer field, "overload protection" is a crucial concept. A system lacking overload protection is extremely dangerous and vulnerable, and a sudden surge in pressure could trigger an "avalanche effect," causing all parts of the system to crash simultaneously and cease operation.
[0003] Currently, the mainstream flow control algorithms in the industry can be roughly divided into the following categories:
[0004] A fixed window approach involves maintaining a counter to count accesses within a given time window, then comparing the access count to a threshold; if the threshold is exceeded, access is restricted. This algorithm is very simple and high-performing, but it suffers from a critical surge problem, meaning it may experience a traffic surge of double the threshold at the window's critical point.
[0005] The sliding window algorithm, developed to address the critical abrupt change problem of the fixed window algorithm, divides large time slices and moves them over time, cleverly avoiding the critical point problem of the counter. In other words, a fixed number of movable cells are used to count and determine the threshold; therefore, the number of cells affects the accuracy of the sliding window algorithm. More cells result in higher smoothness but also higher memory and performance consumption; conversely, fewer cells reduce smoothness and can lead to bandwidth spikes.
[0006] The leaky bucket algorithm, inspired by the principle of a bucket where water is poured in at the top and leaks out at the bottom, creates a container to hold all access requests. The backend service processes these requests at a constant rate, discarding or rejecting requests when the number exceeds the container's capacity. This algorithm effectively controls traffic bursts, but it is relatively inefficient and cannot fully utilize the performance of the business system.
[0007] The token bucket algorithm, unlike the leaky bucket algorithm, generates tokens at a constant rate and puts them into a token bucket. When the bucket is full, excess tokens are discarded. To process a request, a token is taken from the bucket; if there are no tokens in the bucket, the request is rejected. This design makes the token bucket algorithm more efficient than the leaky bucket algorithm, but it still suffers from traffic surges, requiring the business system to withstand traffic surges of up to one times the threshold.
[0008] Although the aforementioned traffic algorithms have been applied to most internet services, they still have some drawbacks, such as low flow control accuracy, inability to balance smooth traffic flow and traffic bursts, and the need for users to make trade-offs. Summary of the Invention
[0009] The following provides a brief overview of one or more aspects to offer a basic understanding of them. This overview is not an exhaustive summary of all conceived aspects, nor is it intended to identify key or decisive elements of all aspects, nor to define the scope of any or all aspects. Its sole purpose is to present some concepts of one or more aspects in a simplified form to prepare for the more detailed descriptions that follow.
[0010] The purpose of this invention is to solve the above problems and provide a time-division multi-dimensional flow control method based on sliding timestamps, which can improve the accuracy of flow control, balance the contradiction between smooth and sudden flow, and also support automatic switching of flow control function in different time periods.
[0011] The technical solution of this invention is as follows: This invention discloses a time-division multi-dimensional flow control method based on sliding timestamps, the method comprising:
[0012] Step 1: When an access request occurs, the request first enters the first time-sharing flow control unit in the flow control chain for access interval control and is processed.
[0013] Step 2: The first time-sharing selector in the first time-sharing flow control unit selects the corresponding access interval control unit for processing based on the current timestamp;
[0014] Step 3: The request, after being processed by the time-sharing flow control unit used for access interval control, enters the second time-sharing flow control unit in the flow control chain for access count control.
[0015] Step 4: The second time-sharing selector in the second time-sharing flow control unit selects the corresponding access count control unit for processing based on the current timestamp;
[0016] Step 5: Process the requests that pass through the entire flow control chain, including the first time-sharing flow control unit and the second time-sharing flow control unit, and terminate a complete request after processing is completed.
[0017] According to an embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention, different access interval control units correspond to their respective effective times.
[0018] According to an embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention, different access count control units correspond to their respective effective times.
[0019] According to an embodiment of the time-sharing multi-dimensional flow control method based on sliding timestamps of the present invention, a time-sharing flow control unit for access interval control can be formed by setting the effective time of the access interval control unit and combining it with a first time-sharing selector; a time-sharing flow control unit for access count control can be formed by setting the effective time of the access count control unit and combining it with a second time-sharing selector.
[0020] According to an embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention, both the access interval control unit and the access count control unit are basic flow control units. The basic flow control unit controls the access interval or the access count by adjusting the timestamp queue size and the time slice size.
[0021] According to an embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention, the steps of the timestamp flow control algorithm set in the basic flow control unit include:
[0022] Step 11: When a request for access occurs, obtain the current access timestamp;
[0023] Step 12: Determine if the timestamp queue is full. If it is full, proceed to step 13; otherwise, proceed to step 16.
[0024] Step 13: Clean up timestamps that have exceeded the time limit;
[0025] Step 14: After the cleanup is complete, check again whether the timestamp queue is full. If it is full, proceed to step 15; otherwise, proceed to step 16.
[0026] Step 15: Flow control overflows and request rejection is performed, process ends;
[0027] Step 16: Add the current timestamp to the timestamp queue and process the request. The process ends.
[0028] Compared with existing technologies, this invention has the following advantages: It improves upon the sliding window model by replacing the counter with a timestamp queue and designing a sliding timestamp algorithm. This allows for more precise flow control within the same time slice, resulting in high flow control accuracy. Simultaneously, it controls both time slices (access intervals) and access monitoring (access counts) by adjusting parameter sizes. These parameters are then combined with the effective time and time-sharing selector to form a flow control chain. This chain enables a multi-dimensional time-sharing flow control algorithm, effectively addressing the conflict between smooth and sudden traffic spikes. It ensures both the smoothness of flow control and system availability while also considering the performance and throughput of the business system. Furthermore, to meet varying market demands for the same interface at different times, this invention also supports automatic time-sharing flow control switching. Attached Figure Description
[0029] The above-described features and advantages of the present invention will be better understood after reading the following detailed description of embodiments of the present disclosure in conjunction with the accompanying drawings. In the drawings, components are not necessarily drawn to scale, and components having similar related characteristics or features may have the same or similar reference numerals.
[0030] Figure 1 A flowchart is shown in one embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention.
[0031] Figure 2 The present invention is shown Figure 1 The flowchart inside the basic flow control unit in the method shown. Detailed Implementation
[0032] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. It should be noted that the aspects described below with reference to the accompanying drawings and specific embodiments are merely exemplary and should not be construed as limiting the scope of protection of the present invention in any way.
[0033] Figure 1 The processing flow of one embodiment of the time-division multi-dimensional flow control method based on sliding timestamps of the present invention is shown. Please refer to... Figure 1 The processing steps of the method in this embodiment are as follows.
[0034] Step 1: When an access request occurs, the request first enters the first time-sharing flow control unit in the flow control chain for access interval control and is processed.
[0035] Step 2: The first time-sharing selector in the first time-sharing flow control unit selects the corresponding access interval control unit for processing based on the current timestamp. Different access interval control units correspond to their respective effective times.
[0036] By setting the effective time of the access interval control unit and combining it with the first time-sharing selector, a time-sharing flow control unit for access interval control can be formed. The first time-sharing selector supports the function of automatically switching flow control according to time periods.
[0037] Step 3: The request, after being processed by the time-sharing flow control unit used for access interval control, enters the second time-sharing flow control unit in the flow control chain used for access count control for further processing.
[0038] Step 4: The second time-sharing selector in the second time-sharing flow control unit selects the corresponding access count control unit for processing based on the current timestamp. Different access count control units correspond to their respective effective times.
[0039] By setting the effective time of the access count control unit and combining it with a second time-sharing selector, a time-sharing flow control unit for access count control can be formed. The second time-sharing selector supports the function of automatically switching flow control according to time periods.
[0040] Step 5: Process the requests that pass through the entire flow control chain, including the first time-sharing flow control unit and the second time-sharing flow control unit, and terminate a complete request after processing is completed.
[0041] In this embodiment, two (or more) time-sharing flow control units are combined together to form a flow control chain, so as to achieve the purpose of time-sharing multi-dimensional flow control.
[0042] The access interval control unit and access count control unit mentioned above are both basic flow control units with identical internal processing. Their functional difference lies in adjusting the timestamp queue size (queueSize) and time slice size (timeRange). For example, setting queueSize to 1 and timeRange to 2ms achieves access interval control, meaning the time interval between two requests is at least 2ms. Setting queueSize to 50 and timeRange to 1min achieves access count control, allowing a maximum of 50 accesses per minute.
[0043] Figure 2 It shows Figure 1 The method shown illustrates the internal processing flow of the basic flow control unit (i.e., the access interval control unit or the access count control unit). Please refer to [link to relevant documentation]. Figure 2 The processing steps of the sliding timestamp flow control algorithm set in the basic flow control unit are as follows.
[0044] Step 11: When a request for access occurs, obtain the current access timestamp.
[0045] Step 12: Determine if the timestamp queue is full. If it is full, proceed to Step 13; otherwise, proceed to Step 16. The timestamp queue size (queueSize) and the time slice size (timeRange) are two completely separate variables with no logical data relationship. However, adjusting these two variables can satisfy various performance control requirements. During initialization, the time slice size and timestamp queue size are defined, and the time queue is created based on the timestamp queue size.
[0046] In this step, reducing the time-slice size (timeRange) ensures that flow control accesses data evenly across each small time slice, improving the smoothness of flow control. Conversely, increasing the timestamp queue size (queueSize) allows for bursts of traffic at a single point in time. By analyzing online access patterns and local business system performance test data, these two variables can be optimized to balance the smoothness of flow control and system availability with the performance and throughput of the business system.
[0047] Step 13: Clean up timestamps that have exceeded the time limit.
[0048] In this step, timestamps exceeding a time slice are cleared when the timestamp queue is full, achieving smooth movement of time slices. That is, the flow control threshold remains unchanged across any time slice within natural time. Similarly, because it involves timestamp calculation, the control is more precise, down to the nanosecond.
[0049] Step 14: After the cleanup is complete, check again whether the timestamp queue is full. If it is full, proceed to step 15; otherwise, proceed to step 16.
[0050] Step 15: Flow control overflows and request rejection is performed, the process ends.
[0051] Step 16: Add the current timestamp to the timestamp queue and process the request. The process ends.
[0052] Although the methods described above are illustrated and depicted as a series of actions for the sake of simplicity, it should be understood and appreciated that these methods are not limited by the order of the actions, as some actions may occur in a different order and / or concurrently with other actions from the illustrations and descriptions herein or not illustrated and described herein but which may be understood by those skilled in the art, according to one or more embodiments.
[0053] Those skilled in the art will further appreciate that the various illustrative logic blocks, modules, circuits, and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented as electronic hardware, computer software, or a combination of both. To clearly illustrate this interchangeability between hardware and software, the various illustrative components, blocks, modules, circuits, and steps are described above in a generalized manner in terms of their functionality. Whether such functionality is implemented as hardware or software depends on the specific application and the design constraints imposed on the overall system. Those skilled in the art may implement the described functionality in different ways for each specific application, but such implementation decisions should not be construed as departing from the scope of the invention.
[0054] The various illustrative logic blocks, modules, and circuits described in conjunction with the embodiments disclosed herein can be implemented or performed using a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. The general-purpose processor may be a microprocessor, but in alternatives, it may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors cooperating with a DSP core, or any other such configuration.
[0055] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of both. The software module may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor such that the processor can read and write information to / from the storage medium. In an alternative, the storage medium may be integrated into the processor. The processor and storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and storage medium may reside as discrete components in the user terminal.
[0056] In one or more exemplary embodiments, the described functionality may be implemented in hardware, software, firmware, or any combination thereof. If implemented in software as a computer program product, the functionality may be stored or transmitted as one or more instructions or code on or through a computer-readable medium. A computer-readable medium includes both computer storage media and communication media, encompassing any medium that facilitates the transfer of a computer program from one location to another. A storage medium may be any available medium accessible to a computer. By way of example and not limitation, such a computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disc storage, disk storage or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and is accessible to a computer. Any connection is also legitimately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server, or other remote source using coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL), or wireless technologies such as infrared, radio, and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL, or wireless technologies such as infrared, radio, and microwave are included in the definition of a medium. As used in this article, disk and disc include compact discs (CDs), laser discs, optical discs, digital multi-purpose discs (DVDs), floppy disks, and Blu-ray discs. Disks typically reproduce data magnetically, while discs reproduce data optically using lasers. Combinations of these should also be included within the scope of computer-readable media.
[0057] The prior description of this disclosure is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to this disclosure will be apparent to those skilled in the art, and the general principles defined herein may be applied to other variations without departing from the spirit or scope of this disclosure. Therefore, this disclosure is not intended to be limited to the examples and designs described herein, but should be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A time-division multi-dimensional flow control method based on sliding timestamps, characterized in that, The methods include: Step 1: When an access request occurs, the request first enters the first time-sharing flow control unit in the flow control chain for access interval control and is processed. Step 2: The first time-sharing selector in the first time-sharing flow control unit selects the corresponding access interval control unit for processing based on the current timestamp; Step 3: The request, after being processed by the time-sharing flow control unit used for access interval control, enters the second time-sharing flow control unit in the flow control chain for access count control. Step 4: The second time-sharing selector in the second time-sharing flow control unit selects the corresponding access count control unit for processing based on the current timestamp; Step 5: Process the requests that pass through the entire flow control chain, including the first time-sharing flow control unit and the second time-sharing flow control unit, and terminate a complete request after processing is completed; Specifically, by setting the effective time of the access interval control unit and combining it with the first time-sharing selector, a time-sharing flow control unit for access interval control can be formed; by setting the effective time of the access count control unit and combining it with the second time-sharing selector, a time-sharing flow control unit for access count control can be formed. Among them, the access interval control unit and the access count control unit are both basic flow control units. The basic flow control unit controls the access interval or the access count by adjusting the timestamp queue size and the time slice size. The steps of the timestamp-based flow control algorithm set in the basic flow control unit include: Step 11: When a request for access occurs, obtain the current access timestamp; Step 12: Determine if the timestamp queue is full. If it is full, proceed to step 13; otherwise, proceed to step 16. Step 13: Clean up timestamps that have exceeded the time limit; Step 14: After the cleanup is complete, check again whether the timestamp queue is full. If it is full, proceed to step 15; otherwise, proceed to step 16. Step 15: Flow control overflows and request rejection is performed, process ends; Step 16: Add the current timestamp to the timestamp queue and process the request. The process ends.
2. The time-division multi-dimensional flow control method based on sliding timestamps according to claim 1, characterized in that, Different access interval control units have their own effective times.
3. The time-division multi-dimensional flow control method based on sliding timestamps according to claim 1, characterized in that, Different access count control units have their own corresponding effective times.