Flow control method and device, equipment, storage medium and product

By using two linked lists of different time windows to perform traffic statistics, the problems of large counting errors and calculation overhead in the prior art are solved, and more efficient and accurate flow control is achieved.

CN119155255APending Publication Date: 2024-12-17MASHANG CONSUMER FINANCE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410832385.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-25
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

The existing flow control technology has counting errors and high calculation overhead in high concurrency scenarios, resulting in poor accuracy and inefficiency.

Method used

Two linked lists of different time windows are used to store traffic count and timestamp information. Through the design that the first time window is larger than the second time window, rapid statistics are performed under a larger time window, and accurate statistics are performed under a smaller time window.

Benefits of technology

Improve the efficiency and accuracy of flow control, ensuring the accuracy of flow counting and the stability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119155255A_ABST
    Figure CN119155255A_ABST
Patent Text Reader

Abstract

The invention provides a flow control method and device, equipment, a storage medium and a product. The method comprises the steps of obtaining a first linked list and a second linked list; nodes in the first linked list comprise a flow count counted by a first time window and a first timestamp, nodes in the second linked list comprise a flow count counted by a second time window and a second timestamp, and the first time window is larger than the second time window; determining at least one first node from the first linked list, and determining at least one second node from the second linked list; a first timestamp included in the first node is in a first time period, and a second timestamp included in the second node is in a second time period; and performing flow control according to the flow count included in the first node and the flow count included in the second node. According to the method and the device, the flow count and the timestamp information can be stored through the chain table which performs statistics by using two different time windows, so that the efficiency and the accuracy of flow control can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Internet technology, and in particular to a flow control method, device, equipment, storage medium and product. Background Art

[0002] With the rapid development of the Internet, network traffic has exploded. A large number of user requests and data transmission have put the system under tremendous pressure. In this case, without an effective flow control mechanism, the system can easily crash or degrade due to overload. Therefore, the emergence of flow control technology has become a key means to solve this problem. The popularity of distributed systems has further promoted the development of flow control technology. By limiting the access rate, flow control can ensure the stability and reliability of the system and prevent a single user or source from overconsuming resources. Flow control plays an important role in protecting the system from overload and attacks and ensuring service quality, and provides effective support for distributed systems and Internet services.

[0003] The flow control methods of related technologies often have the problem of counting errors when processing high-concurrency requests. Since the division and update of time windows may not be precise, the flow limiting results are not accurate enough, which may allow too many requests to pass or mistakenly reject legitimate requests. In addition, the flow control methods of related technologies need to maintain a large amount of counters and status information, resulting in increased storage overhead. At the same time, in high-concurrency scenarios, frequent counting and status updates will also bring about large computing overheads, reducing the processing performance of the system. That is, the flow control methods in related technologies have technical problems of poor accuracy and low efficiency. Summary of the invention

[0004] The embodiments of the present application provide a flow control method, apparatus, device, storage medium and product. The embodiments of the present application can store flow count and timestamp information by using linked lists of two different time windows, thereby improving the efficiency and accuracy of flow control.

[0005] The technical solution of the embodiment of the present application is implemented as follows:

[0006] An embodiment of the present application provides a flow control method, which includes: obtaining a first linked list and a second linked list; wherein the nodes in the first linked list include flow counts and first timestamps counted in a first time window, and the nodes in the second linked list include flow counts and second timestamps counted in a second time window, and the first time window is larger than the second time window; determining at least one first node from the first linked list, and determining at least one second node from the second linked list; wherein the first timestamp included in the first node is within a first time period, and the second timestamp included in the second node is within a second time period, and the starting time point of the first time period is the same as the ending time point of the second time period; and performing flow control according to the flow count included in the first node and the flow count included in the second node.

[0007] An embodiment of the present application provides a flow control device, including: a linked list acquisition module, used to acquire a first linked list and a second linked list; wherein the nodes in the first linked list include flow counts and first timestamps counted in a first time window, and the nodes in the second linked list include flow counts and second timestamps counted in a second time window, and the first time window is larger than the second time window; a node determination module, used to determine at least one first node from the first linked list, and to determine at least one second node from the second linked list; wherein the first timestamp included in the first node is within a first time period, and the second timestamp included in the second node is within a second time period, and the starting time point of the first time period is the same as the ending time point of the second time period; a flow control module, used to perform flow control according to the flow count included in the first node and the flow count included in the second node.

[0008] An embodiment of the present application provides an electronic device, which includes: a memory for storing computer-executable instructions; and a processor for implementing the flow control method provided in the embodiment of the present application when executing the computer-executable instructions stored in the memory.

[0009] An embodiment of the present application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the flow control method provided in the embodiment of the present application when executed by a processor.

[0010] An embodiment of the present application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, the flow control method provided in the embodiment of the present application is implemented.

[0011] The embodiments of the present application have the following beneficial effects:

[0012] On the one hand, the embodiment of the present application uses linked lists of two different time windows to store traffic counts, so that traffic statistics can be performed on different time scales. Since the first time window is larger than the second time window, when performing traffic statistics, it is possible to determine a first node based on a relatively large first time window to count traffic counts, and at the same time, determine a second node based on a relatively small second time window to count traffic counts. Therefore, based on the first node and the second node, the traffic count can be accurately counted, and then based on the accurate traffic count statistical results, the traffic can be accurately controlled.

[0013] On the other hand, since the first time window is larger than the second time window, when counting the flow counts in the first time period and the second time period, a quick count is first performed in the relatively large first time window, and then the statistical accuracy is considered, and accurate flow counts are performed in the relatively small second time window, thereby improving the efficiency of flow statistics while ensuring the statistical accuracy of flow counting. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1A This is a first schematic diagram for explaining flow control through an array in the related technology provided by this application;

[0015] Figure 1B It is a second schematic diagram for explaining flow control through an array in the related technology provided by the present application;

[0016] Figure 1C It is a third schematic diagram for explaining flow control through an array in the related technology provided by this application;

[0017] Figure 1D It is a fourth schematic diagram for explaining flow control through an array in the related technology provided by this application;

[0018] Figure 1E It is a schematic diagram illustrating flow control achieved through a token bucket algorithm in the related technology provided by this application;

[0019] Figure 1F This is the first schematic diagram for explaining flow control by using a leaky bucket algorithm in the related technology provided by this application;

[0020] Figure 1G It is a second schematic diagram for explaining flow control by using a leaky bucket algorithm in the related technology provided by this application;

[0021] Figure 2A It is a first flow chart of the flow control method provided in an embodiment of the present application;

[0022] Figure 2Bis a schematic diagram of a first process for determining a first node and a second node provided in an embodiment of the present application;

[0023] Figure 2C is a second flow chart of determining a first node and a second node provided in an embodiment of the present application;

[0024] Figure 2D It is a schematic diagram of a flow chart of flow control according to flow counting provided in an embodiment of the present application;

[0025] Figure 3A It is a schematic diagram of calculating the traffic statistics value provided in the embodiment of the present application;

[0026] Figure 3B is a second flow chart of the flow control method provided in an embodiment of the present application;

[0027] Figure 3C is a schematic diagram of a process for updating a first linked list provided in an embodiment of the present application;

[0028] Figure 3D is a schematic diagram of a process for updating the second linked list provided in an embodiment of the present application;

[0029] Figure 3E is a schematic diagram illustrating a flow control method provided in an embodiment of the present application;

[0030] Figure 4 is a schematic structural diagram of a flow control device provided in an embodiment of the present application;

[0031] Figure 5 It is a schematic diagram of the composition structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0032] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of this application.

[0033] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0034] In the following description, the terms "first / second / third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0035] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0036] Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as those commonly understood by those skilled in the art. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0037] The relevant data collection and processing in the embodiments of this application should be strictly in accordance with the requirements of relevant national laws and regulations when applied in examples, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of authorization of laws and regulations and the personal information subject.

[0038] Before further describing the embodiments of the present application in detail, the nouns and terms involved in the embodiments of the present application are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations.

[0039] 1) In response, it is used to indicate the conditions or states on which the executed operations depend. When the dependent conditions or states are met, one or more operations executed may be in real time or have a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations executed are executed.

[0040] 2) Linked List is a linear data structure consisting of a series of nodes, each of which contains two parts of information: one is the data field, which is used to store element values; the other is the pointer field (or link field), which is usually used to store a pointer to the next node. The nodes in the linked list are not stored continuously in memory, but are linked together by pointers. The basic characteristic of a linked list is that the logical order between elements is achieved through pointer links, rather than continuous storage in physical locations. This makes the linked list more efficient in insertion and deletion operations because there is no need to move a large number of elements to make room or fill gaps. There are many forms of linked lists, such as one-way linked lists, two-way linked lists, and circular linked lists.

[0041] 3) Rate Limiting: Also known as flow control, it is a technique used to control the frequency or rate at which a service processes requests to prevent service overload. By limiting the number of requests processed per unit time, it can ensure that the service will not become unavailable or respond slowly due to too many requests. Rate limiting can be applied to different levels, such as HTTP request rate limiting, database operation rate limiting, etc.

[0042] 4) Queries Per Second (QPS) is a performance metric used to measure the number of queries or requests that a system, service or server can handle per unit time. It is commonly used in database management systems, search engines, web servers and other services that need to handle a large number of requests.

[0043] 5) Time Window: A time window is a specific time range used to limit the occurrence interval of a process, event, or data statistics. In the application scenario of flow control, the time window is used to count the number of requests per unit time.

[0044] 6) Timestamp is a computer term that can be expressed as a sequence of characters that uniquely identifies a moment in time. It is usually a long integer, usually representing the number of seconds or milliseconds from a fixed start time (such as January 1, 1970 00:00:00 UTC) to the occurrence of a specific event. Timestamps provide computer systems with an accurate and unified way to record, compare, and track time. The accuracy of timestamps can be adjusted according to requirements, ranging from seconds to milliseconds, microseconds, and even nanoseconds.

[0045] 7) First Element Node is the first node in a linked list that stores data, that is, the node that contains actual data. The name of the first element node is for the convenience of describing the first node in a linked list that stores data, and it has no actual functional meaning. In the case of a head node in a linked list, the head node is an empty node that does not store any data, so the first element node is the first node after the head node that stores data. Through the first element node, you can traverse the entire linked list and access and operate other nodes in the linked list.

[0046] 8) Network Request refers to the request information sent by one device (usually a client) to another device (usually a server) in the network. This request is based on network protocols (such as HTTP, FTP, SMTP, etc.) and is intended to obtain, send or modify information, or perform certain operations. In the case of current limiting, the number of network requests may be limited to prevent server overload and ensure system stability and reliability.

[0047] In the related art, there are three main methods for flow control: implementation through an array, implementation through a token bucket algorithm, and implementation through a leaky bucket algorithm. The following is a detailed description:

[0048] Method 1: Implement flow control through arrays. Implement flow statistics of sliding windows based on array data of different time periods, mainly based on determining the specific time period in which the current time is located. Figure 1A As shown in , if the standard for flow control is a preset number of visits per second, and the current time is in the fourth time period, then the flow count of the current one-second time window is the flow count of the array corresponding to the fourth time period. Figure 1B As shown, you can also increase the time period and use multiple time periods for statistics to improve the smoothness of the sliding window, thereby ensuring more accurate and detailed data analysis.

[0049] However, the method of realizing flow control through arrays is to judge flow control through array data in different time periods, and does not achieve completely smooth flow statistics. Therefore, in theory, the error of data statistics will be relatively large. Figure 1C As shown in the figure, when a large number of requests pour in near the boundary between two time periods, the first half of the requests between time point 1 and time point 2 are classified into the first time period, while the second half of the requests are classified into the second time period. This will result in the number of requests released by the system being nearly doubled within an absolute time of only 1 second, making the request statistics inaccurate and the pressure on the system correspondingly increased.

[0050] Even though the problem can be reduced by increasing the number of statistical time periods and reducing the length of the time periods, inaccurate statistics may still occur in extreme cases, such as Figure 1D As shown, according to the flow control standard of a maximum of 100 visits per second, there are 49 visits between time point 3 and time point 4, 50 visits between time point 4 and time point 5, and 49 visits between time point 5 and time point 6. In this way, 148 visits pass through in the one second between time point 3 and time point 6 without current limiting and fuse breaking, which exceeds the preset flow control standard.

[0051] If the statistical formats are increased infinitely and the statistical duration is reduced, there will be too many statistical time periods, which will cause performance problems. The usage scenario is relatively precise. If hundreds or thousands of time period arrays are calculated for statistical work every time request, it will have a greater impact on performance. Therefore, the relevant technology does not allow users to customize the parameters of the time period length, but instead gives a window of 1 second or 500 milliseconds.

[0052] In summary, in actual business scenarios, requests generally occur irregularly, and the method of implementing flow control through arrays cannot achieve a good balance between performance and accuracy.

[0053] Method 2: Traffic control implemented through token bucket algorithm. Figure 1E As shown, first, there is a token bucket with a fixed capacity, and the token bucket stores tokens. The token bucket is empty at the beginning. Step 501 is executed to put tokens at a fixed rate. The tokens will be filled into the token bucket at a fixed preset rate, and step 502 is executed to determine whether it is full, that is, tokens are put into the token bucket until the capacity threshold of the token bucket is reached. For the excess tokens, step 503 will be executed to discard the tokens. Every time a network request is received (step 504, receiving a network request), an attempt will be made to remove a token from the token bucket, and step 505 will be executed to determine whether the token is obtained. If the token is not obtained, step 507 will be executed to reject the network request. If the token is obtained, step 506 will be executed to respond to the network request.

[0054] The implementation of the token bucket algorithm in the related technology also has statistical accuracy problems. If the expected number of queries per second is 10, the token bucket algorithm does not put a token every 100 milliseconds, but is implemented by putting 10 tokens per second. There is also the same statistical error problem as method one.

[0055] Method 3: Flow control implemented through leaky bucket algorithm. Figure 1FAs shown, first, there is a leaky bucket with a fixed capacity, with water flowing in and out. For the water flowing in, it is impossible to predict how much water will flow in, nor the speed of the water flow. But for the water flowing out, this leaky bucket can fix the rate at which the water flows out. Moreover, when the leaky bucket is full, the excess water will overflow. In practical applications, the water in the leaky bucket algorithm is replaced with requests. It can be seen that the leaky bucket algorithm limits the speed of requests, which can ensure that the interface will process requests at a constant rate.

[0056] However, the leaky bucket algorithm has the problem of being too uniform. If the number of queries per second is 2, then two requests cannot be satisfied within 1 second. The leaky bucket algorithm will force the time interval between the two requests to increase to 500 milliseconds. Figure 1G As shown, the expected number of queries per second is 2, and the next request is allowed to pass every 500 milliseconds.

[0057] From the above content, it can be seen that in the related art, the methods for flow control mainly include three methods: implementation through array, implementation through token bucket algorithm and implementation through leaky bucket algorithm. However, the related art has technical problems of poor accuracy and low efficiency when performing flow control.

[0058] Based on at least one of the above problems existing in the related art, an embodiment of the present application provides a flow control method. On the one hand, the embodiment of the present application uses two linked lists of different time windows to store flow counts, and flow statistics can be performed on different time scales. Since the first time window is larger than the second time window, when performing flow statistics, it is possible to determine the first node based on the relatively large first time window to count the flow count, and also determine the second node based on the relatively small second time window to count the flow count, so that based on the first node and the second node, the flow count can be accurately counted, and then based on the accurate flow count statistical results, the flow can be accurately controlled; on the other hand, since the first time window is larger than the second time window, when counting the flow counts in the first time period and the second time period, a fast statistics is first performed under the relatively large first time window, and then the statistical accuracy is considered, and the flow count is accurately counted under the relatively small second time window, so that the efficiency of flow statistics can be improved while ensuring the statistical accuracy of flow counts. In summary, the embodiment of the present application uses two linked lists of different time windows to store flow counts and timestamp information, which can improve the efficiency and accuracy of flow control.

[0059] See also Figure 2A , Figure 2A This is an optional flow chart of the flow control method provided in the embodiment of the present application. Figure 2A The steps shown are explained as Figure 2AAs shown, the flow control method is described by taking the execution subject of the electronic device as an example, and the method includes the following steps 101 to 104:

[0060] Step 101, obtain a first linked list and a second linked list; wherein the nodes in the first linked list include traffic counts and first timestamps counted in a first time window, and the nodes in the second linked list include traffic counts and second timestamps counted in a second time window, and the first time window is larger than the second time window.

[0061] In some embodiments, the process of obtaining the first linked list and the second linked list is implemented by accessing a predefined memory or storage space. The first linked list and the second linked list are two different linked lists, which store traffic statistics information under different time windows respectively; the nodes in the first linked list include traffic counts and corresponding first timestamps counted in the first time window (relative to the longer time period of the second time window), and the nodes in the second linked list include traffic counts and corresponding second timestamps counted in the second time window (relative to the shorter time period of the first time window). The first timestamp refers to the timestamp of the node in the first linked list, and the second timestamp refers to the timestamp of the node in the second linked list; wherein the timestamp of the node is the timestamp of the starting time point of the time interval counted by the traffic count included in the node. According to the timestamp and time window of a certain node, the time interval corresponding to the node can be determined, and the traffic count included in the node is the number of all requests in the time interval. If no request is received in a certain time interval, the node corresponding to the time interval does not exist in the first linked list and the second linked list.

[0062] For example, the first linked list can be used to store traffic statistics every 20 milliseconds, while the second linked list is used to store traffic statistics every 1 millisecond; thus, the first time window (every 20 milliseconds) will be larger than the second time window (every 1 millisecond). By acquiring these two linked lists, traffic statistics for a longer time period and a shorter time period can be acquired at the same time.

[0063] Through step 101, a rich data basis can be provided for flow control, flow control can be performed on different time scales, the flexibility and accuracy of flow control are improved, and it is helpful to more accurately analyze the flow change trend, timely discover abnormal flow, and formulate effective flow control strategies accordingly.

[0064] Step 102, determine at least one first node from the first linked list, and determine at least one second node from the second linked list; wherein the first timestamp included in the first node is within the first time period, the second timestamp included in the second node is within the second time period, and the starting time point of the first time period is the same as the ending time point of the second time period.

[0065] In some embodiments, the first node is at least one node in the first linked list whose first timestamp falls within the first time period, and the second node is at least one node in the second linked list whose second timestamp falls within the second time period. The starting time point of the first time period is the same as the ending time point of the second time period, that is, the two time periods (the first time period and the second time period) are continuous on the time axis. The corresponding first node and the second node can be found by traversing the first linked list and the second linked list. The first time period is the time period from the minimum first timestamp of the first node to the ending time point of the time period for which traffic statistics need to be performed in the time period for which traffic statistics need to be performed; the second time period is the time period from the starting time point of the time period for which traffic statistics need to be performed to the minimum first timestamp of the first node in the time period for which traffic statistics need to be performed.

[0066] Through step 102, the traffic statistics information in the first time period and the second time period can be quickly located, so as to obtain the latest traffic data in time, which is not only helpful for real-time detection of changes in network traffic, but also can provide accurate data support for subsequent traffic analysis and control. In addition, since the traversal operation is performed on the linked list structure, it has a high processing efficiency, can meet the application scenarios with high real-time requirements, can achieve accurate control of network traffic, and improve the stability and reliability of network services.

[0067] In some embodiments, see Figure 2B , step 102 can be implemented through steps 1021A to 1022A, which are described in detail below.

[0068] Step 1021A, determine the fifth node from the first linked list; use the fifth node as the traversal starting point and the first pointer as the traversal direction to traverse the first linked list to obtain at least one first node; wherein the end time point of the first time period is located in the time interval corresponding to the fifth node, and the first pointer is used to point to the node in the first linked list that is located before the fifth node.

[0069] In the implementation process, the time interval corresponding to the node in the first linked list is determined by the timestamp of the node and the first time window: the time stamp T1 of a node in the first linked list can be set as the starting time point of the time interval corresponding to the node, and the time point obtained by adding the timestamp T1 to the first time window is used as the end time point of the time interval corresponding to the node, thereby determining the time interval corresponding to the node, and this time interval can be expressed as [T1, T1+first time window). Similar to determining the time interval corresponding to the node in the first linked list, the time interval corresponding to the node in the second linked list is determined by the timestamp of the node and the second time window: the timestamp T2 of a node in the second linked list can be set as the starting time point of the time interval corresponding to the node, and the timestamp T2 plus the length of the second time window is calculated as the end time point of the time interval corresponding to the node, thereby determining the time interval corresponding to the node, and this time interval can be expressed as [T2, T2+second time window). That is, the time intervals corresponding to the nodes in different linked lists are determined by the timestamps and the corresponding time windows.

[0070] The fifth node is a specific node in the first linked list that serves as the starting point of the traversal. The time interval corresponding to the fifth node contains the end time point of the first time period. That is, the fifth node can be determined by finding the node in the first linked list whose corresponding time interval contains the end time point of the first time period. The first pointer is a pointer used to indicate the traversal direction of the first linked list starting from the fifth node. During the traversal process, the first pointer points to the node before the fifth node. In this way, the traversal can start from the fifth node and check the first timestamp of each node forward along the first linked list until all first nodes whose first timestamps are after the start time point of the time period for which traffic statistics are required are found.

[0071] Step 1022A, determine the sixth node from the second linked list; use the sixth node as the traversal starting point and the second pointer as the traversal direction to traverse the second linked list to obtain at least one second node; wherein, within the second time period, the sixth node has the largest second timestamp, and the second pointer is used to point to the node in the second linked list that is located before the sixth node.

[0072] The sixth node is a specific node in the second linked list that serves as the starting point of the traversal. The second timestamp included in the sixth node is the largest among the second timestamps included in all the nodes in the second linked list within the second time period. That is, the sixth node can be determined by finding the node in the second linked list whose second timestamp is within the second time period and whose second timestamp is the largest. The second pointer is a pointer used to indicate the traversal direction of the second linked list starting from the sixth node. During the traversal process, the second pointer points to the node before the sixth node. In this way, the traversal can start from the sixth node and check the second timestamp of each node forward along the second linked list until all second nodes after the starting time point of the time period for which traffic statistics are required are found.

[0073] Through step 1021A to step 1022A, the first node in the first time period and the second node in the second time period can be efficiently and accurately located. This traversal method utilizes the characteristics of the linked list structure, reduces unnecessary search and comparison operations, and improves processing efficiency. At the same time, by comparing the timestamp information to determine the first node and the second node, the accuracy and integrity of the data are ensured.

[0074] In some embodiments, see Figure 2C , step 102 can be implemented through steps 1021B to 1022B, which are described in detail below.

[0075] Step 1021B, determine the seventh node from the first linked list; wherein the seventh node is the first node with the smallest first timestamp.

[0076] In some embodiments, after all the first nodes in the first linked list are determined, a node with the smallest first timestamp among all the first nodes can be found and the node can be determined as the seventh node.

[0077] Step 1022B, determine the eighth node from the second linked list; take the eighth node as the traversal starting point and the third pointer as the traversal direction, traverse the second linked list to obtain at least one second node; wherein the eighth node is the node pointed to by the fourth pointer, the third pointer is used to point to the node before the eighth node in the second linked list, and the fourth pointer is used to point from the seventh node to the node before the seventh node in the second linked list.

[0078] In some embodiments, the third pointer is a pointer for indicating the traversal direction of the second linked list starting from the eighth node. During the traversal process, the third pointer points to the previous node of the eighth node. In this way, the traversal can start from the eighth node and check the second timestamp of each node forward along the second linked list until all second nodes whose second timestamps are after the starting time point of the time period for which traffic statistics are required are found. The fourth pointer is a special pointer. The fourth pointer is used to point from the seventh node to the node in the second linked list that is located before the seventh node and has the shortest time interval from the seventh node. The node pointed to by the fourth pointer is the eighth node, and the eighth node is used as the starting point for traversing the second linked list. By following this fourth pointer, it is possible to jump directly from the seventh node to the corresponding eighth node, thereby avoiding traversing the entire second linked list to find the eighth node. The eighth node can be a node that is the same as the sixth node, and the third pointer can be a pointer that is the same as the second pointer.

[0079] For example, in the application scenario of network traffic control, it may be necessary to analyze the traffic data of a specific time period. Assuming that all the first nodes have been determined through the previous steps, you can first find the seventh node with the smallest first timestamp information in the first node. Then, according to the fourth pointer in the seventh node, this fourth pointer will point to the eighth node, which is located before the seventh node and is the eighth node with the shortest time interval with the seventh node. By following this fourth pointer, you can directly locate the eighth node, which is the starting point for subsequent traffic analysis, that is, the second node at the beginning of traversing the second linked list.

[0080] Through the implementation method of the above embodiment, pointer information is directly used to locate the second node starting from the traversal of the second linked list. Therefore, there is no need to traverse the entire second linked list, and the eighth node can be directly determined, which can significantly reduce the search time in the linked list and improve the processing efficiency during the flow control process.

[0081] Step 103: Perform flow control according to the flow count included in the first node and the flow count included in the second node.

[0082] In some embodiments, the traffic counts included in the first node and the second node are first extracted. These traffic counts reflect the traffic statistics of the first time period and the second time period. Then, these traffic counts can be compared and analyzed according to the predefined traffic control strategy. If the sum of the traffic count included in the first node and the traffic count included in the second node exceeds the preset threshold, the corresponding traffic control measures will be triggered. Traffic control can include limiting the access of new requests (rejecting or delaying new requests), directing requests to other servers (dynamically transferring requests from busy servers to less loaded servers), dynamically adjusting resource allocation (increasing or decreasing the bandwidth allocated to specific services or users), etc. Traffic control is intended to ensure the stability and availability of network services.

[0083] For example, in a traffic control system of an online shopping platform, assuming that the sum of the traffic count included in the first node and the traffic count included in the second node is 100001, and the corresponding preset threshold is 100000, in this case, a series of measures will be taken according to the traffic control strategy to cope with the traffic peak. These measures may include temporarily restricting the registration of new users, guiding some users to access the static pages of the platform to reduce the server load, or dynamically increasing the number of servers to enhance processing capabilities. Through these measures, the online shopping platform can effectively control traffic, avoid service crashes, and ensure the smoothness of user experience.

[0084] Through step 103, by using linked lists of two different time windows to store flow counts, flow statistics can be performed on different time scales, and because the first time window is larger than the second time window, when performing flow statistics, it is possible to determine a first node for counting flow counts based on a relatively large first time window, and at the same time, determine a second node for counting flow counts based on a relatively small second time window, so that based on the first node and the second node, the flow count can be accurately counted, and then based on the accurate flow count statistical results, the flow can be accurately controlled.

[0085] In some embodiments, see Figure 2D , step 103 can be implemented through steps 1031 to 1033, which are described in detail below.

[0086] Step 1031, determine the traffic statistics value in a third time period according to the traffic count included in the first node and the traffic count included in the second node, the starting time point of the third time period is the same as the starting time point of the second time period, and the ending time point of the third time period is the same as the ending time point of the first time period.

[0087] In some embodiments, the third period is a specific time range for counting network traffic, the start time point of the third period is the same as the start time point of the second period, and the end time point of the third period is the same as the end time point of the first period, that is, the third period is composed of the second period and the first period. The traffic counts of all first nodes and all second nodes can be summed to obtain the traffic statistics value in the third period.

[0088] Step 1032: When the traffic statistics value is greater than or equal to the traffic threshold, traffic restriction is performed on the received network request.

[0089] In some embodiments, the flow threshold is a pre-set flow limit value, which is used to determine whether the network flow exceeds an acceptable range. This flow threshold can be set according to factors such as the specific needs of the network service, system capacity, and security policies. When the flow statistics exceed this flow threshold, corresponding measures can be taken to limit the flow (such as limiting the access of new requests, guiding requests to other servers, dynamically adjusting resource allocation, etc.) to avoid network congestion, service collapse, or security risks. The flow statistics in the third time period are obtained by adding the flow counts included in all first nodes to the flow counts included in all second nodes. Since the first node represents the flow data of a larger time granularity, and the second node represents the flow data of a smaller time granularity, adding the two can obtain accurate and detailed flow statistics in the third time period. When the flow statistics are greater than or equal to the flow threshold, relevant measures for flow restriction will be taken.

[0090] Step 1033: When the traffic statistics value is less than the traffic threshold, the first linked list and the second linked list are updated according to the received network request.

[0091] In some embodiments, when the traffic statistics value is less than the traffic threshold, the request will be responded to normally. After processing the request, the first linked list and the second linked list may be updated to add new traffic data to the first linked list and the second linked list for subsequent traffic analysis and control. In the implementation process, step 1033 may be divided into the following three cases:

[0092] Case 1: There is a third node in the first linked list, and there is a fourth node in the second linked list.

[0093] When there is a third node in the first linked list and a fourth node in the second linked list, the traffic counts included in the third node and the fourth node can be updated according to the received network request; wherein the time interval corresponding to the third node and the time interval corresponding to the fourth node both include the current time.

[0094] In the implementation process, the third node is a node whose corresponding time interval in the first linked list includes the current moment, and the fourth node is a node whose corresponding time interval in the second linked list includes the current moment. When there are nodes corresponding to the current moment (the third node and the fourth node) in both the first linked list and the second linked list, the traffic counts included in these two nodes can be updated at the same time. The traffic counts included in the two nodes corresponding to the current moment (the third node and the fourth node) can be added to the number of received network requests to obtain an updated traffic count to ensure that the updated traffic count matches the status of the current network request. For example, the number of received network requests is 1, the original traffic count included in the third node is 20, and the traffic count is 21 after the update. The original traffic count included with the fourth node is 3, and the traffic count is 4 after the update.

[0095] Case 2: The third node does not exist in the first linked list, and the fourth node does not exist in the second linked list.

[0096] When the third node does not exist in the first linked list and the fourth node does not exist in the second linked list, a third node can be created in the first linked list, a fourth node can be created in the second linked list, and the traffic counts included in the third and fourth nodes can be initialized; and the traffic counts included in the third and fourth nodes can be updated according to the received network request.

[0097] During the implementation process, new nodes (the third node and the fourth node) can be created in the two linked lists respectively, and the traffic counts included in the new nodes can be initialized. Initialization can be to set the traffic count to zero or a preset starting value. After the initialization is completed, the traffic counts included in these new nodes can be updated simultaneously according to the network request. The traffic counts included in the two new nodes (the third node and the fourth node) can be added to the number of received network requests to obtain an updated traffic count to ensure that the updated traffic count matches the status of the current network request. For example, the number of received network requests is 1, the traffic count included in the new node (the third node) in the first linked list is initialized to 0, and the traffic count is updated to 1 according to the network request, and the traffic count included in the new node (the fourth node) in the second linked list is initialized to 0, and the traffic count is updated to 1 according to the network request.

[0098] Case 3: The third node exists in the first linked list and the fourth node does not exist in the second linked list.

[0099] When there is a third node in the first linked list and there is no fourth node in the second linked list, a fourth node can be created in the second linked list, and the traffic count included in the fourth node can be initialized; and the traffic counts in the third node and the fourth node can be updated according to the received network request.

[0100] In the implementation process, a fourth node can be created in the second linked list, the time interval corresponding to the fourth node includes the current time, and the traffic count included in the fourth node is initialized to zero, and then the traffic counts included in the two nodes (the third node and the fourth node) whose time intervals include the current time are added to the number of received network requests to obtain an updated traffic count, so as to ensure that the updated traffic count matches the current network request status. This update process ensures that the data in the two linked lists reflect the latest network traffic status and maintains data consistency.

[0101] Through steps 1031 to 1033, network traffic can be effectively controlled and managed. When the traffic exceeds the preset threshold, it can respond quickly and take corresponding traffic restriction measures to protect the stability and security of the service. At the same time, by updating the linked list data in real time, it can provide accurate traffic statistics and analysis results, providing strong support for network management and optimization.

[0102] The following is an explanation of an exemplary application of an embodiment of the present application in a practical application scenario.

[0103] In the embodiment of the present application, both the first linked list and the second linked list have nodes. The nodes are initialized when the system starts. The following are the attributes contained in the nodes:

[0104] 1) Timestamp (time): If the accuracy is 1 second, and the timestamp of the current time is n (accurate to milliseconds), then the timestamp of the node corresponding to the current time is int (n / 1000) * 1000, where int () indicates a rounding operation. The timestamp indicates the start time of the time period that a node is responsible for statistics, if the time period is 1 second. For example, if the current timestamp is 1710749355238, int (1710749355238 / 1000) * 1000 = 1710749355000, that is, the timestamp of the node corresponding to the traffic count between the statistical timestamp 1710749355000 and the timestamp 1710749355999 is 1710749355000.

[0105] 2) Forward pointer (preNode): A pointer pointing to the previous node, mainly a pointer pointing to an adjacent node before the current node in the current node.

[0106] 3) Cross-table pointer (minNode): Only the first node has a clear pointer, and the second node is empty.

[0107] 4) Traffic count (count): An indicator used to perform traffic statistics. The type can be AtomicInteger to ensure thread safety when performing traffic statistics.

[0108] See also Figure 3A The following points need to be explained regarding the calculation of traffic statistics:

[0109] 1. The traffic count included in each node of the first linked list is equal to the sum of the traffic counts included in all nodes of the second linked list covered by the time interval corresponding to the node of the first linked list; 2. The nodes in the first linked list and the second linked list are not necessarily continuous. If there is no traffic statistics in some time intervals, there is no need for nodes. Two connected nodes represent time continuity; 3. The nodes in the first linked list and the second linked list are linked through a reverse linked list. The reverse linked list refers to a linked list that points to the previous time window node from the current time in reverse chronological order; 4. Each node of the first linked list has a pointer pointing to the last node of the second linked list before the corresponding time interval; 5. Figure 3A The two nodes marked with shadows are the nodes corresponding to the current moment, and the remaining nodes are found through the form of linked list pointers; 6. Figure 3A In the example, a time period is determined according to the current time point and the length of time for which traffic statistics are required. The traversal order of the traffic statistics values ​​in this time period (the third time period) is 6+15+6+8+5, and the final traffic statistics value is 40.

[0110] like Figure 3B As shown, the flow control method provided in the embodiment of the present application can be started in response to a network request and implemented through steps 201 to 212, which are described in detail below.

[0111] Step 201, obtain the current node of the first linked list and obtain the corresponding traffic count.

[0112] First, the current node in the first linked list is obtained. This node corresponds to the current moment and contains the traffic count and the first timestamp calculated in the first time window. The traffic count included in the node is further obtained to provide a data basis for subsequent traffic control.

[0113] Step 202: Update traffic statistics.

[0114] After obtaining the flow count included in the current node in the first linked list, the flow statistics are updated. Step 202 is implemented by adding the flow count included in the current node in the first linked list to the existing flow statistics. The updated flow statistics reflect the flow situation in the third time period. Then, a judgment step 2021 is executed to judge whether the flow statistics is less than or equal to the flow threshold. If the judgment is no, step 203 is executed, and if the judgment is yes, step 204 is executed.

[0115] Step 203, reject the request.

[0116] If the updated traffic statistics exceed the preset traffic threshold, it means that the current traffic is too large and exceeds the system's processing capacity or security limit. In this case, the request rejection operation will be executed and the newly received network request will no longer be processed to avoid system overload or security risks. After executing step 203, the entire process ends.

[0117] Step 204, obtaining the traffic count included in the node of the previous first linked list.

[0118] If the traffic statistics value does not exceed the preset threshold, the traffic count included in the node of the previous first linked list can be obtained. Step 204 can be implemented by checking the first pointer of the node, starting from the current node of the first linked list, and traversing the first linked list forward. Then, the judgment step 2041 is executed to determine whether the node exists and is within the statistical time period. If the judgment is yes, the execution returns to step 202, and if the judgment is no, the execution of step 205 is executed.

[0119] Step 205: Set the first pointer of the node to point to null.

[0120] After obtaining the flow count included in the node of the previous first linked list, in order to release the memory space no longer needed, the first pointer of the current first node can be pointed to null. In this way, the expired node can no longer be maintained, thereby preventing memory overflow. The expired node of the first linked list can be deleted through step 205 to prevent memory overflow.

[0121] Step 206: Search for corresponding nodes in the second linked list through the nodes in the first linked list.

[0122] According to the fourth pointer of the current node of the first linked list, the second node corresponding to the current node is searched. After the corresponding second node is found, the flow count and timestamp included in the node can be obtained to perform subsequent flow control.

[0123] Step 207: Update traffic statistics.

[0124] After obtaining the flow count included in the corresponding second node, the flow statistics value can be updated again. Step 207 can be implemented by adding the flow count included in the second node to the existing flow statistics value. In this way, the flow statistics value takes into account the flow conditions of the first node and the second node at the same time, providing more comprehensive flow information. Then, the judgment step 2071 is executed to judge whether the flow statistics value is less than or equal to the flow threshold value. If the judgment is yes, step 208 is executed, and if the judgment is no, step 203 is executed.

[0125] Step 208: Obtain the traffic count included in the previous second node.

[0126] Similar to step 204, if the traffic statistics value does not exceed the preset threshold, the traffic count included in the previous second node can be obtained. This is achieved by checking the second pointer of the second node, starting from the current second node, and traversing the second linked list forward. When the timestamp of the traversed second node is earlier than the starting time point of the third time period, the traversal is stopped, and the last traversed second node is determined as the previous second node. Then, the traffic count included in the node is obtained for subsequent traffic statistics and control. Then execute step 2081 to determine whether the second node exists and is within the statistical time period. If the judgment is yes, execute step 207, and if the judgment is no, execute step 209.

[0127] Step 209: Set the second pointer of the node in the second linked list to null.

[0128] Similar to step 205, after obtaining the flow count included in the node of the previous second linked list, the second pointer of the current second node can be pointed to null, so that no longer needed memory space can be released to prevent memory overflow.

[0129] Step 210: Update the traffic count included in the current node of the first linked list.

[0130] Step 210 may be implemented by adding the traffic value of the new request to the traffic count currently included in the first node.

[0131] Step 211: Update the traffic count included in the current node of the second linked list.

[0132] Step 211 may be implemented by adding the traffic value of the new request to the traffic count currently included in the second node.

[0133] Step 212, respond to the network request.

[0134] If the traffic statistics value does not exceed the preset threshold and a new network request is received, the network request can be responded to normally and the corresponding operation can be performed. This can be processing request data, sending response messages, etc. After responding to the network request, the whole process ends and waits for the next network request or traffic statistics operation.

[0135] like Figure 3C As shown, the process of updating the first linked list in the embodiment of the present application can be implemented through steps 301 to 307, which are described in detail below.

[0136] Step 301, obtain the first node n1 of the first linked list.

[0137] In this step, first locate the starting position of the first linked list, that is, obtain the first node n1. The first node n1 is the first node in the linked list, which contains the traffic count and corresponding timestamp related to a specific time window. Next, compare the current timestamp with the time range corresponding to the n1 node. Then execute step 3011 to determine whether the current timestamp is within the n1 range. If the current timestamp falls within the time window represented by the n1 node, it means that n1 is still valid, and step 302 will be executed; if the current timestamp exceeds the time range of the n1 node, it means that the first linked list needs to be updated to reflect the new time window, and step 303 will be executed.

[0138] Step 302: The flow count of n1 is increased by 1.

[0139] The flow count included in the n1 node is updated and increased by 1 to reflect the newly added flow event.

[0140] Step 303: Create node n2 of the first linked list, with a flow count of 1.

[0141] Since the current timestamp exceeds the time range of the first node n1, a new first linked list node n2 can be created to represent the traffic situation in the current time window. When n2 is created, its traffic count is initialized to 1, indicating the first traffic count in the new time window. This step ensures the continuity and accuracy of traffic statistics.

[0142] Step 304, obtaining the first element node m1 of the second linked list.

[0143] After creating the new node n2, the node of the second linked list corresponding to n2 can be found to establish the association between them. Therefore, first obtain the first node m1 of the second linked list. The m1 node contains the traffic count and the corresponding timestamp calculated in a shorter time window. This step is the basis for establishing the association between the first linked list and the second linked list.

[0144] Step 305: The fourth pointer of n2 points to m1.

[0145] Establish an association between n2 and m1. By setting the fourth pointer of n2 to point to m1, the node m1 of the second linked list corresponding to n2 can be quickly found when needed. This pointer association mechanism helps to simplify the operation of data structures and improve query efficiency.

[0146] Step 306: The first pointer of n2 points to n1.

[0147] In order to maintain the continuity of the first linked list, the new node n2 needs to be inserted into the first linked list. By setting the first pointer of n2 to point to the original head node n1, the correct position of n2 in the first linked list is achieved. In this way, n2 becomes the new head node, and n1 becomes the node after n2.

[0148] Step 307: n2 is determined to be the head node of the first linked list.

[0149] Confirm n2 as the new head node of the first linked list. From now on, all operations on the first linked list will start from n2 instead of the original n1. This step marks the completion of the update of the first linked list and provides an updated data structure basis for subsequent traffic statistics and control.

[0150] like Figure 3D As shown, the process of updating the second linked list in the embodiment of the present application can be implemented through steps 401 to 405, which are described in detail below.

[0151] Step 401, obtain the first element node m1 of the second linked list.

[0152] Get and check whether the current timestamp falls within the time interval corresponding to the m1 node. Then execute step 4011 to determine whether the current timestamp falls within the time interval corresponding to m1. If the current timestamp is within the time interval of m1, it means that m1 is still valid, and the system will execute step 402; if the current timestamp exceeds the time interval corresponding to m1, a new node needs to be created to represent the new time window, that is, execute step 403.

[0153] Step 402, the flow count of m1 is increased by 1.

[0154] If the current timestamp is within the time range of m1, it means that a new traffic event has occurred in the time interval corresponding to m1. Therefore, the traffic count included in the m1 node can be incremented by 1 to reflect the newly added traffic, so as to track the traffic changes in a shorter time window in real time and provide accurate data support for subsequent traffic control.

[0155] Step 403: Create a second node m2 with a traffic count of 1.

[0156] If the current timestamp exceeds the time range of m1, it means that a new node needs to be created to record the traffic situation in the new time interval. Therefore, a new second node m2 can be created and its traffic count is initialized to 1. This indicates the first traffic count in the new time interval, providing a starting point for subsequent traffic statistics and control.

[0157] Step 404: The second pointer of m2 points to m1.

[0158] By setting the second pointer of m2 to point to m1, a link is constructed to the previous node of the linked list, which helps to trace back the linked list or perform other operations when needed. This pointer association mechanism is an important feature of the linked list data structure, which can simplify the access and management of nodes.

[0159] Step 405: m2 is determined as the first node of the second linked list.

[0160] The newly created node m2 is determined as the new head node of the second linked list. This means that from now on, all operations on the second linked list will start from m2 instead of the original m1. This step marks the completion of the update of the second linked list and provides an updated data structure basis for subsequent traffic statistics and control.

[0161] In some examples, taking the second linked list length as 1 millisecond and the first linked list length as 20 milliseconds as an example, assuming that the current time accurate to milliseconds is 2024-05-01 08:08:08 998, then the embodiment of the present application will count the data within the last 1 second. That is, the data from 2024-05-01 08:08:07 999 to the current time is counted. Then, the timestamp corresponding to the start time point of the third period is 1714522087999, and the timestamp corresponding to the end time point of the third period is 1714522088998.

[0162] like Figure 3EAs shown, the first 10 bits of the second linked list timestamp are omitted, and only the last three bits are written. If two adjacent nodes have pointers, the pointer arrows are omitted, and the thick arrows indicate the actual traversal route when calculating the traffic statistics. In the embodiment of the present application, the data of the time period from 2024-05-01 08:08:07 981 to 2024-05-01 08:08:08 980 (the third time period) is counted through a first linked list with a first time window of 20 milliseconds, and the number of first nodes is 49 (2024-05-01 08:08:08 000 to 2024-05-01 08:08:08 980, one first node every 20 milliseconds); the data outside the time period of the first linked list in the third time period is counted through a second linked list with a second time window of 1 millisecond, and the number of second nodes is 19 (2024-05-01 08:08:07 981 to 2024-05-01 08:08:08 000, one second node every 1 millisecond), add up the traffic counts in the first node and the second node, and you get the traffic statistics value in the last second. The maximum number of nodes that need to be counted is 68. In actual applications, the request time may be more scattered, and the actual number of nodes that need to be counted may be much less than 68.

[0163] It can be seen from the embodiments of the present application that even if the amount of traffic data is large and dispersed to every millisecond, the number of first nodes and second nodes involved is only 68 at most, which is better than the method of implementing traffic control through an array in terms of performance, and is no less accurate than the effect achieved by the method of implementing traffic control through an array (traffic statistics and control through an array of 1000 time intervals of 1 millisecond).

[0164] The embodiment of the present application makes full use of the feature of the linked list structure without fixed length restrictions to effectively deal with scattered traffic data. Compared with a fixed-length array, a linked list is more flexible and efficient in storing data, occupying only the space required for the actual data, avoiding the waste of space caused by reserving spaces in the array.

[0165] This embodiment adopts a double linked list structure, aiming to achieve a balance between the accuracy and performance of statistical data. Among them, the first linked list is mainly responsible for reducing the number of queries, optimizing the query path by rationally organizing the node order, thereby significantly improving the query efficiency. The second linked list focuses on the accuracy problem, and achieves a fine capture of traffic changes by recording the traffic data in a shorter time window. The two linked lists cooperate with each other. On the one hand, the approximate traffic range is quickly located through the first linked list, and on the other hand, the specific traffic data is accurately counted through the second linked list. This design not only ensures the accuracy of statistics, but also avoids the performance loss caused by traversing the entire data structure. In addition, according to the specific business scenario, the balance between accuracy and performance can be further optimized by adjusting the linked list parameters. This flexibility enables the embodiment of the present application to adapt to different traffic statistics requirements and achieve a better configuration effect.

[0166] The following is a description of an exemplary structure of the flow control device 455 provided in the embodiment of the present application implemented as a software module. In some embodiments, Figure 4 As shown, the software modules stored in the flow control device 455 of the memory may include: a linked list acquisition module 4551, used to acquire a first linked list and a second linked list; wherein the nodes in the first linked list include a flow count and a first timestamp counted in a first time window, and the nodes in the second linked list include a flow count and a second timestamp counted in a second time window, and the first time window is larger than the second time window; a node determination module 4552, used to determine at least one first node from the first linked list, and to determine at least one second node from the second linked list; wherein the first timestamp included in the first node is within a first time period, the second timestamp included in the second node is within a second time period, and the starting time point of the first time period is the same as the ending time point of the second time period; a flow control module 4553, used to perform flow control according to the flow count included in the first node and the flow count included in the second node.

[0167] In some embodiments, the traffic control module 4553 is also used to: determine the traffic statistics value within a third time period based on the traffic count included in the first node and the traffic count included in the second node, the starting time point of the third time period is the same as the starting time point of the second time period, and the ending time point of the third time period is the same as the ending time point of the first time period; when the traffic statistics value is greater than or equal to the traffic threshold, limit the traffic of the received network request; when the traffic statistics value is less than the traffic threshold, update the first linked list and the second linked list according to the received network request.

[0168] In some embodiments, the traffic control module 4553 is also used to: when there is a third node in the first linked list and a fourth node in the second linked list, update the traffic counts included in the third node and the fourth node according to the received network request; wherein the time interval corresponding to the third node and the time interval corresponding to the fourth node both include the current time; when there is no third node in the first linked list and there is no fourth node in the second linked list, create a third node in the first linked list and a fourth node in the second linked list, and initialize the traffic counts included in the third node and the fourth node; update the traffic counts included in the third node and the fourth node according to the received network request.

[0169] In some embodiments, the traffic control module 4553 is also used to: when there is a third node in the first linked list and there is no fourth node in the second linked list, create a fourth node in the second linked list and initialize the traffic count included in the fourth node; and update the traffic counts in the third node and the fourth node according to the received network request.

[0170] In some embodiments, the node determination module 4552 is also used to: determine the fifth node from the first linked list; use the fifth node as the traversal starting point and the first pointer as the traversal direction to traverse the first linked list to obtain at least one first node; wherein the end time point of the first time period is located in the time interval corresponding to the fifth node, and the first pointer is used to point to the node in the first linked list that is located before the fifth node; determine the sixth node from the second linked list; use the sixth node as the traversal starting point and the second pointer as the traversal direction to traverse the second linked list to obtain at least one second node; wherein, within the second time period, the sixth node has the largest second timestamp, and the second pointer is used to point to the node in the second linked list that is located before the sixth node.

[0171] In some embodiments, the node determination module 4552 is also used to: determine the seventh node from the first linked list; wherein the seventh node is the first node with the smallest first timestamp; determine the eighth node from the second linked list; use the eighth node as the traversal starting point and the third pointer as the traversal direction to traverse the second linked list to obtain at least one second node; wherein the eighth node is the node pointed to by the fourth pointer, the third pointer is used to point to the node in the second linked list that is located before the eighth node, and the fourth pointer is used to point from the seventh node to the node in the second linked list that is located before the seventh node.

[0172] It should be noted that the description of the device of the embodiment of the present application is similar to the description of the above method embodiment, and has similar beneficial effects as the method embodiment, so it is not repeated. For technical details not disclosed in the embodiment of the device, please refer to the description of the method embodiment of the present application for understanding.

[0173] Correspondingly, an embodiment of the present application provides an electronic device, Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the electronic device 1200 includes at least: a processor 1201 , a communication interface 1202 , and a storage medium 1203 configured to store executable instructions, wherein: the processor 1201 generally controls the overall operation of the electronic device 1200 .

[0174] The communication interface 1202 enables the electronic device to communicate with other terminals or servers through a network.

[0175] The storage medium 1203 is configured to store instructions and applications executable by the processor 1201, and can also cache data to be processed or processed by the processor 1201 and each module in the electronic device 1200, which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0176] The embodiment of the present application provides a computer program product, which includes a computer program or a computer executable instruction, and the computer program or the computer executable instruction is stored in a computer readable storage medium. The processor of the electronic device reads the computer executable instruction from the computer readable storage medium, and the processor executes the computer executable instruction, so that the electronic device executes the flow control method described in the embodiment of the present application.

[0177] The present application embodiment provides a computer-readable storage medium, in which computer executable instructions or computer programs are stored. When the computer executable instructions or computer programs are executed by a processor, the processor will execute the flow control method provided by the present application embodiment, for example, Figure 2A The flow control method is shown.

[0178] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or may be various devices including one or any combination of the above memories.

[0179] In some embodiments, computer executable instructions may be in the form of a program, software, software module, script or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine or other unit suitable for use in a computing environment.

[0180] As an example, computer-executable instructions may, but need not, correspond to a file in a file system, may be stored as part of a file that stores other programs or data, such as in one or more scripts in a HyperText Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files storing one or more modules, subroutines, or code portions).

[0181] As an example, computer executable instructions may be deployed to be executed on one electronic device, or on multiple electronic devices located at one site, or on multiple electronic devices distributed at multiple sites and interconnected by a communication network.

[0182] In summary, on the one hand, the embodiment of the present application uses two linked lists of different time windows to store flow counts, and flow statistics can be performed on different time scales. Since the first time window is larger than the second time window, when performing flow statistics, it is possible to determine the first node based on the relatively large first time window to count the flow count, and also determine the second node based on the relatively small second time window to count the flow count, so that based on the first node and the second node, the flow count can be accurately counted, and then based on the accurate flow count statistical results, the flow can be accurately controlled. On the other hand, since the first time window is larger than the second time window, when counting the flow counts in the first time period and the second time period, a fast statistics is first performed under the relatively large first time window, and then the statistical accuracy is considered, and the flow count is accurately counted under the relatively small second time window, so that the efficiency of flow statistics can be improved while ensuring the statistical accuracy of flow counts. In summary, the embodiment of the present application uses two linked lists of different time windows to store flow counts and timestamp information, which can improve the efficiency and accuracy of flow control.

[0183] The above is only an embodiment of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims

1. A flow control method, characterized in that: The method comprises: Obtain a first linked list and a second linked list; wherein the nodes in the first linked list include traffic counts and first timestamps calculated in a first time window, and the nodes in the second linked list include traffic counts and second timestamps calculated in a second time window, and the first time window is larger than the second time window; Determine at least one first node from the first linked list, and determine at least one second node from the second linked list; wherein a first timestamp included in the first node is within a first time period, a second timestamp included in the second node is within a second time period, and a start time point of the first time period is the same as an end time point of the second time period; Flow control is performed according to the flow count included in the first node and the flow count included in the second node.

2. The method according to claim 1, characterized in that The performing flow control according to the flow count included in the first node and the flow count included in the second node includes: Determine, according to the traffic count included in the first node and the traffic count included in the second node, a traffic statistic value in a third time period, wherein a starting time point of the third time period is the same as a starting time point of the second time period, and an ending time point of the third time period is the same as an ending time point of the first time period; When the traffic statistics value is greater than or equal to the traffic threshold, limiting the traffic of the received network request; When the traffic statistics value is less than the traffic threshold, the first linked list and the second linked list are updated according to the received network request.

3. The method according to claim 2, characterized in that The updating of the first linked list and the second linked list according to the received network request includes: When there is a third node in the first linked list and there is a fourth node in the second linked list, according to the received network request, the traffic counts included in the third node and the fourth node are updated; wherein the time interval corresponding to the third node and the time interval corresponding to the fourth node both include the current time; When the third node does not exist in the first linked list and the fourth node does not exist in the second linked list, the third node is created in the first linked list, the fourth node is created in the second linked list, and the traffic counts included in the third node and the fourth node are initialized; and the traffic counts included in the third node and the fourth node are updated according to the received network request.

4. The method according to claim 3, characterized in that The method further comprises: When the third node exists in the first linked list and the fourth node does not exist in the second linked list, the fourth node is created in the second linked list and the traffic count included in the fourth node is initialized; and according to the received network request, the traffic counts in the third node and the fourth node are updated.

5. The method according to claim 1, characterized in that The determining at least one first node from the first linked list and determining at least one second node from the second linked list comprises: Determine a fifth node from the first linked list; take the fifth node as a traversal starting point and the first pointer as a traversal direction, traverse the first linked list, and obtain at least one first node; wherein the end time point of the first time period is within the time interval corresponding to the fifth node, and the first pointer is used to point to a node in the first linked list that is located before the fifth node; Determine the sixth node from the second linked list; use the sixth node as the traversal starting point and the second pointer as the traversal direction to traverse the second linked list to obtain at least one second node; wherein, within the second time period, the sixth node has the maximum second timestamp, and the second pointer is used to point to the node in the second linked list that is located before the sixth node.

6. The method according to claim 1, characterized in that The determining at least one second node from the second linked list comprises: Determine a seventh node from the first linked list; wherein the seventh node is the first node with the smallest first timestamp; Determine an eighth node from the second linked list; use the eighth node as the traversal starting point and the third pointer as the traversal direction to traverse the second linked list to obtain at least one second node; wherein the eighth node is the node pointed to by the fourth pointer, the third pointer is used to point to the node in the second linked list that is located before the eighth node, and the fourth pointer is used to point from the seventh node to the node in the second linked list that is located before the seventh node.

7. A flow control device, characterized in that: The device comprises: A linked list acquisition module, configured to acquire a first linked list and a second linked list; wherein the nodes in the first linked list include traffic counts and first timestamps calculated in a first time window, and the nodes in the second linked list include traffic counts and second timestamps calculated in a second time window, and the first time window is larger than the second time window; A node determination module, configured to determine at least one first node from the first linked list, and to determine at least one second node from the second linked list; wherein a first timestamp included in the first node is within a first time period, a second timestamp included in the second node is within a second time period, and a starting time point of the first time period is the same as an ending time point of the second time period; A flow control module is used to perform flow control according to the flow count included in the first node and the flow count included in the second node.

8. An electronic device, characterized in that: include: A memory for storing computer executable instructions; A processor, configured to implement the flow control method according to any one of claims 1 to 6 when executing the computer executable instructions stored in the memory.

9. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that: When the computer executable instructions or computer program are executed by a processor, the flow control method according to any one of claims 1 to 6 is implemented.

10. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the flow control method according to any one of claims 1 to 6 is implemented.