Traffic control method and device, electronic equipment, storage medium and program product

CN116996440BActive Publication Date: 2026-11-03TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210451724.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-26
Publication Date
2026-11-03
Estimated Expiration
2042-04-26

AI Technical Summary

Technical Problem

Existing technologies cannot effectively control traffic when faced with sudden surges in traffic, leading to resource waste and system performance bottlenecks, especially in microservice systems where there are issues with traffic change sensitivity and inconsistent performance.

Method used

By acquiring the traffic threshold and historical traffic values ​​of the target process, and employing quota pre-allocation, cyclic elimination, and comparative statistical processing, precise traffic control is achieved, including the determination of instantaneous traffic thresholds and the identification management of access data.

Benefits of technology

It achieves high-performance load protection for large traffic volumes and precise control for small traffic volumes, reducing resource waste and improving system availability and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116996440B_ABST
    Figure CN116996440B_ABST
Patent Text Reader

Abstract

The application provides a flow control method and device, electronic equipment, computer readable storage medium and computer program product; the method comprises the following steps: in response to the flow threshold reaching the second flow control threshold, performing quota pre-allocation processing based on the historical flow value of the target process to obtain an instantaneous flow threshold; when the instantaneous flow value of the target process is less than the instantaneous flow threshold, executing an access operation corresponding to the access data; in response to the flow threshold not reaching the second flow control threshold and reaching the first flow control threshold, performing cyclic elimination processing on the identifier of the access data; when the to-be-eliminated quota identifier corresponding to the access data is eliminated, executing the access operation corresponding to the access data; in response to the flow threshold not reaching the first flow control threshold, performing comparative statistical processing on the identifier of the access data; when the result of the comparative statistical processing represents that the sum of the historical flow values of the plurality of processes is less than the flow threshold, executing the access operation corresponding to the access data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to computer data processing technology, and more particularly to a flow control method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology

[0002] In some data access and processing processes, data access is instantaneous. For example, in scenarios like game marketing or e-commerce shopping festivals, there may be a massive surge of traffic to the system in an instant. This instantaneous traffic is often an order of magnitude larger than the estimated peak traffic, and in abnormal cases, it can be tens of times larger. Therefore, it is unlikely that the data processing system will request and reserve such a large amount of resources in advance. Even if such a large amount of resources are reserved, the utilization rate of system resources will be relatively low after the peak, resulting in waste. Secondly, some accessed data is redundant or invalid traffic.

[0003] In related technologies, as the business logic of data processing becomes increasingly complex, more and more systems are adopting microservice design. However, the performance and robustness of various systems within a microservice system vary greatly. Some services have low performance and are sensitive to changes in traffic, making it impossible to control both large and small traffic volumes with fine-grained control. Summary of the Invention

[0004] This application provides a flow control method, apparatus, electronic device, computer-readable storage medium, and computer program product for precise flow control.

[0005] The technical solution of this application embodiment is implemented as follows: This application provides a flow control method, including: Obtain access data and traffic thresholds for the target process; In response to the traffic threshold reaching the second flow control threshold, quota pre-allocation is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed. In response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold, the identifier of the access data is cyclically eliminated. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed. The first flow control threshold is less than the second flow control threshold. In response to the traffic threshold not reaching the first flow control threshold, the identifier of the access data is compared and statistically processed. When the result of the comparison and statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed. Among them, the multiple processes include the target process.

[0006] This application provides a flow control device, including: The traffic threshold determination module is used to obtain the access data in the target process and the traffic threshold of the target process; The quota pre-allocation processing module is used to pre-allocate quotas based on the historical traffic value of the target process in response to the traffic threshold reaching the second flow control threshold, and obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed. The loop elimination processing module is used to perform loop elimination processing on the identifier of the access data in response to the traffic threshold not reaching the second flow control threshold and reaching the first flow control threshold. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed. The first flow control threshold is less than the second flow control threshold. The comparison and statistics processing module is used to perform comparison and statistics processing on the identifier of the access data in response to the traffic threshold not reaching the first flow control threshold. When the result of the comparison and statistics processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed. Among them, the multiple processes include the target process.

[0007] In the above technical solution, the quota pre-allocation processing module is also used to obtain the historical traffic value of the target process within a period of time; The historical flow value of a portion of the periodic time is used as the first flow value; The sum of the historical traffic values ​​of processes other than the target process within the specified time period is used as the second traffic value. The instantaneous flow threshold is the product of the ratio of the first flow value to the second flow value and the flow threshold.

[0008] In the above technical solution, the quota pre-allocation processing module is also used to obtain the historical access data of the target process within the period before obtaining the historical traffic value of the target process within the period. Based on the identifiers of the target process's historical access data within a period of time, storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; Read the timestamp of the target process within the periodic time from the plurality of memory units; Based on the timestamp, the number of requests made by the target process within the period is determined, and the sum of the number of requests is used as the historical traffic value of the target process within the period.

[0009] In the above technical solution, the quota pre-allocation processing module is also used to use the identifier of the target process's historical access data within the period as the timestamp of the target process's historical access data within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0010] In the above technical solution, the quota pre-allocation processing module is also used to use the remainder between the timestamp of the target process within the periodic time and the number of the multiple memory units as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

[0011] In the above technical solution, the loop elimination processing module is also used to perform quota pre-allocation processing based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the access data is compared with multiple sets of quota identifiers to be eliminated in a loop. When the cyclic comparison result indicates that the identifier of the access data is the same as any group of the quota identifier to be eliminated, the quota identifier to be eliminated is eliminated.

[0012] In the above technical solution, the loop elimination processing module is further used to group the quota identifiers to be eliminated based on the traffic threshold before comparing the identifier of the access data with multiple groups of quota identifiers to be eliminated in a loop, so as to obtain the multiple groups of quota identifiers to be eliminated, wherein each group includes the same number of quota identifiers to be eliminated. The quota identifiers to be eliminated in any group are arranged in chronological order.

[0013] In the above technical solution, the comparison and statistical processing module is also used to perform quota pre-allocation processing based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous flow value of the target process is less than the instantaneous flow threshold, the historical flow values ​​of the multiple processes within the period are statistically analyzed to obtain the sum of the historical flow values ​​of the multiple processes; The sum of the historical traffic values ​​of the multiple processes is compared with the traffic threshold to obtain the result of the comparison and statistical processing.

[0014] In the above technical solution, the comparison and statistical processing module is also used to obtain historical access data of the multiple processes within a period of time; Based on the identifiers of the historical access data of the multiple processes within a period of time, the storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; In the above technical solution, the comparison and statistics processing module is also used to read the timestamps of the multiple processes within the periodic time from the multiple memory units; Based on the timestamp, the number of requests made by the plurality of processes within the periodic time is determined, and the sum of the number of requests is taken as the sum of the historical traffic values ​​of the plurality of processes within the periodic time.

[0015] In the above technical solution, the comparison and statistical processing module is also used to use the identifier of the historical access data of the multiple processes within the period as the timestamp for determining the historical access data of the multiple processes within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0016] In the above technical solution, the comparison and statistical processing module is also used to use the remainder between the timestamps of the multiple processes within the periodic time and the number of the multiple memory units as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

[0017] This application provides an electronic device for flow control, the electronic device comprising: Memory, used to store executable instructions; The processor, when executing executable instructions stored in the memory, implements the flow control method provided in the embodiments of this application.

[0018] This application provides a computer-readable storage medium storing executable instructions for inducing a processor to execute and implement the flow control method provided in this application.

[0019] This application provides a computer program product, including a computer program or instructions, characterized in that the computer program or instructions, when executed by a processor, implement the flow control method provided in this application.

[0020] The embodiments of this application have the following beneficial effects: By comparing the traffic threshold of the target process with the first flow control threshold and the second flow control threshold, the access operations of the target process are restricted in a hierarchical manner by determining the quota pre-allocation processing, loop elimination processing, and comparative statistical processing methods. This achieves high-performance load protection for large traffic volumes and precise traffic control for small traffic volumes while providing system security. Attached Figure Description

[0021] Figure 1 This is a schematic diagram illustrating the principle of load protection in the prior art provided in this application embodiment; Figure 2 This is a schematic diagram illustrating the application scenario of flow control provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of an electronic device for flow control provided in an embodiment of this application; Figure 4 This is a flowchart illustrating the flow control method provided in an embodiment of this application; Figure 5 This is a schematic flowchart of determining an instantaneous flow threshold provided in an embodiment of this application; Figure 6 This is a schematic diagram of the first process for determining the historical traffic value of a target process within a period of time, provided in an embodiment of this application. Figure 7 This is a flowchart illustrating the determination of storage parameters within a specific time period, as provided in an embodiment of this application. Figure 8 This is a schematic diagram of a process for storing parameters in a memory structure, provided in an embodiment of this application; Figure 9 This is a schematic diagram of a process for cyclically eliminating the identifier of accessed data provided in an embodiment of this application; Figure 10 This is a schematic diagram of the second process for determining the historical traffic value of a target process within a period of time, provided in an embodiment of this application. Figure 11 This is a flowchart illustrating the comparative statistical processing of access data identifiers provided in an embodiment of this application; Figure 12 This is a flowchart illustrating the process of determining the sum of historical traffic values ​​for multiple processes, as provided in an embodiment of this application. Figure 13 This is a flowchart illustrating the determination of storage parameters within a multi-threaded cycle time, as provided in an embodiment of this application. Figure 14This is a flowchart illustrating the storage of parameters for accessing data in multiple processes in a memory structure, as provided in an embodiment of this application. Figure 15 This is a schematic diagram illustrating the principle of load protection provided in an embodiment of this application; Figure 16 This is a schematic diagram illustrating the principle of the flow control method provided in the embodiments of this application; Figure 17 This is a schematic diagram of the single-key control technology solution for flow control provided in the embodiments of this application; Figure 18 This is a schematic diagram of the hotkey splitting technology solution for flow control provided in the embodiments of this application; Figure 19 This is a schematic diagram of the quota pre-allocation technology solution for flow control provided in the embodiments of this application; Figure 20 This is a schematic diagram illustrating the storage principle of the storage parameters provided in the embodiments of this application; Figure 21 This is a schematic diagram of the flow control storage strategy provided in an embodiment of this application; Figure 22 This is a schematic diagram of the flow control scheme provided in the embodiments of this application. Detailed Implementation

[0022] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

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

[0024] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0025] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0026] 1) Client: This refers to a program that provides local services to a client, corresponding to a server. Aside from some applications that run only locally, these are typically installed on ordinary client machines and require interaction with the server to function. With the development of the Internet, common clients include web browsers used on the World Wide Web, email clients for sending and receiving emails, and instant messaging client software. For these types of applications, corresponding servers and service programs on the network are needed to provide the necessary services, such as database services and email services. Therefore, a specific communication connection needs to be established between the client and server to ensure the normal operation of the application.

[0027] 2) Microservices: A software development technique, a variant of the Service Oriented Architecture (SOA) architectural style, which constructs an application as a set of loosely coupled services.

[0028] 3) Load protection: A protection mechanism for the normal operation of a (microservice) system, preventing the entire (microservice) marketing system from crashing due to external environment (such as inbound traffic) or internal service (or module) abnormalities or failures.

[0029] 4) Hotspots: In a distributed environment, the server that receives the most data uploaded by clients is the one that is accessed most frequently.

[0030] 5) Application Programming Interface (API): Some predefined interfaces (such as functions, Hypertext Transfer Protocol (HTTP)), or the conventions for connecting different components of a software system.

[0031] During the implementation of the embodiments of this application, the applicant discovered the following problems with the related technology: In related technologies, a server cluster responds to access requests sent by a sending client by forwarding the request over the network to the receiving client. For example, in a load protection scheme for controlling system ingress traffic in a game marketing scenario, see [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram illustrating the principle of load protection in the prior art provided in the embodiments of this application.

[0032] In scenarios where traffic is limited, ingress traffic control is typically achieved through a service cluster consisting of distributed service servers (S). Each service server (S) generates a unified key identifier for the traffic objects that need to be restricted; in a game marketing scenario, the traffic object could be an activity or an activity process. Traffic from each individual service server is aggregated and summarized. When ingress traffic for activity A arrives, the service server uses the flow control interface (API, Application Programming Interface) and the storage service R's atomic counting mechanism to count the requests. When the flow control API returns an Akey count for the current time exceeding a (pre-set) threshold T, service S restricts the current request, i.e., it does not provide service to the current request and directly returns a traffic overload warning. When the flow control API returns an Akey count for the current time less than the threshold T, service S provides normal service to the current request.

[0033] The following problems exist in the relevant existing technologies: 1. Each business request to the flow control API requires interaction with the storage service, which greatly increases business overhead.

[0034] 2. When business traffic surges, storage services can easily become access hotspots, slowing down or even overwhelming the storage via flow control API access, rendering it unusable. The maximum hotspot performance of storage is the maximum service capacity of a single key per unit time, which cannot be improved through horizontal scaling (adding new resources) but only through vertical scaling (increasing CPU frequency and accelerating storage access speed). Vertical scaling in production environments is relatively limited, meaning that hotspot access performance is relatively constant and difficult to improve rapidly in a short period. Therefore, a surge in traffic can easily trigger system performance bottlenecks, affecting external services or at least disabling flow control functionality.

[0035] 3. Flow control and disaster recovery are limited by access to the storage service (network). Even a short period of network unavailability of the storage service will affect the flow control function.

[0036] To address the aforementioned issues, embodiments of this application provide a flow control method, apparatus, device, and computer-readable storage medium, which can alleviate server load pressure and ensure the availability of flow access. The following describes exemplary applications of the flow control device provided in this application. The device provided in this application can be implemented as various types of user terminals such as laptops, tablets, desktop computers, set-top boxes, and mobile devices (e.g., mobile phones, portable music players, personal digital assistants, dedicated messaging devices, portable gaming devices), or as a server.

[0037] In some embodiments, the traffic control method can be applied to various traffic access control scenarios, such as game marketing scenarios and web survey scenarios.

[0038] In some embodiments, server 100 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminal 200 may be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, in-vehicle terminal, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment.

[0039] See Figure 2 , Figure 2 This is a schematic diagram of the application scenario of the flow control system 10 provided in the embodiment of this application. The terminal 200 is connected to the server 100 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0040] Terminal 200 has a data retrieval client installed and running, which provides an operation interface for users to input operation data or access data for game marketing scenarios or page survey scenarios through the operation interface, and receive relevant operation data or access data, and send access requests carrying access data to server 100.

[0041] Server 100 is used to obtain access data in the target process and the traffic threshold of the target process; in response to the traffic threshold reaching the second flow control threshold, quota pre-allocation processing is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed; in response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold, the identifier of the access data is cyclically eliminated. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed, wherein the first flow control threshold is less than the second flow control threshold; in response to the traffic threshold not reaching the first flow control threshold, the identifier of the access data is compared and statistically processed. When the result of the comparison and statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed.

[0042] In some embodiments, the server 100 can implement the traffic control method provided in this application embodiment by running a computer program. For example, the computer program can be a native program or software module in an operating system; it can be a native application (APP), that is, a program that needs to be installed in the operating system to run, such as a game APP (i.e., the terminal 200 mentioned above); it can also be a mini-program, that is, a program that only needs to be downloaded into a browser environment to run; or it can be a game mini-program that can be embedded in any APP. In short, the above-mentioned computer program can be any form of application, module or plugin.

[0043] Taking a computer program as an example, in actual implementation, terminal 200 has an application that supports virtual scenarios installed and running. This application can be any of the following: a questionnaire survey, a game entry point, a game marketing application, or an event entry point.

[0044] In some embodiments, the embodiments of this application can also be implemented with the aid of cloud technology, which refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize the computation, storage, processing, and sharing of data.

[0045] Cloud technology is a general term encompassing network technology, information technology, integration technology, management platform technology, and application technology based on the cloud computing business model. It can form resource pools, allowing for on-demand use with flexibility and convenience. Cloud computing technology will become a crucial support. The backend services of cloud computing systems require substantial computing and storage resources.

[0046] Figure 3 This is a schematic diagram of the structure of an electronic device 500 for flow control provided in an embodiment of this application. The example given is a server. Figure 3 The illustrated electronic device 500 for flow control includes at least one processor 510, a memory 550, and at least one network interface 520. The various components in the electronic device 500 are coupled together via a bus system 530. It is understood that the bus system 530 is used to implement communication between these components. In addition to a data bus, the bus system 530 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 3 The general labeled all buses as Bus System 530.

[0047] The processor 510 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0048] Memory 550 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 550 described in this application embodiment is intended to include any suitable type of memory. Memory 550 may optionally include one or more storage devices physically located away from processor 510.

[0049] In some embodiments, memory 550 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0050] Operating system 551 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks; The network communication module 553 is used to reach other computing devices via one or more (wired or wireless) network interfaces 520, exemplary network interfaces 520 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc. In some embodiments, the flow control device provided in this application can be implemented in software. Figure 3 A flow control device 555 stored in memory 550 is shown. It can be software in the form of programs and plug-ins, including the following software modules: flow threshold determination module 5551, quota pre-allocation processing module 5552, loop elimination processing module 5553, and comparison statistics processing module 5554. These modules are logical and can therefore be arbitrarily combined or further split according to the functions implemented.

[0051] The traffic threshold determination module 5551 is used to obtain the access data in the target process and the traffic threshold of the target process; The quota pre-allocation processing module 5552 is used to perform quota pre-allocation processing based on the historical traffic value of the target process in response to the traffic threshold reaching the second flow control threshold, to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed. The loop elimination processing module 5553 is used to perform loop elimination processing on the identifier of access data in response to the traffic threshold not reaching the second flow control threshold and reaching the first flow control threshold. When the quota identifier to be eliminated corresponding to the identifier of access data is eliminated, it is determined that the access operation corresponding to the access data will be executed, wherein the first flow control threshold is less than the second flow control threshold. The comparison and statistical processing module 5554 is used to perform comparison and statistical processing on the identifier of the access data in response to the traffic threshold not reaching the first flow control threshold. When the result of the comparison and statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed.

[0052] In other embodiments, the flow control device provided in this application can be implemented in hardware. As an example, the flow control device provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the flow control method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), digital signal processing (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0053] As mentioned above, the flow control method provided in this application can be implemented by various types of electronic devices, such as servers. See also Figure 4 , Figure 4 This is a flowchart illustrating a flow control method provided in an embodiment of this application, combined with... Figure 4 The steps shown are explained.

[0054] In step 201, the access data in the target process and the traffic threshold of the target process are obtained.

[0055] Here, a target process is a running activity of a program on a certain data set in a computer. It is the basic unit for system resource allocation and scheduling. Each target process has its own address space, typically including a text region, a data region, and a stack region. The text region stores the code executed by the processor; the data region stores variables and dynamically allocated memory used during process execution; the stack region stores instructions for process calls and local variables. In an online promotional scenario, a target process could be a running activity of an information form submitted to the server by an object's login or purchase interface. Accessed data includes the source and destination Internet Protocol (IP) addresses of the data stream, as well as the timestamp of the submitted form.

[0056] It should be noted that the access data in the target process is received and processed by the server, and the traffic threshold for the target process is determined based on the server's hardware and software performance. Furthermore, the traffic threshold includes a first flow control threshold and a second flow control threshold, where the second flow control threshold is greater than the first flow control threshold. For example, if the first flow control threshold is limited to 1000 requests per second, then the second flow control threshold is also 1000. N requests per second, where N is a multiple of 10.

[0057] In step 202, in response to the traffic threshold reaching the second flow control threshold, quota pre-allocation processing is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed.

[0058] Here, the quota pre-allocation process for access data is controlled by the server. Based on the relationship between the traffic threshold and the second flow control threshold, the instantaneous traffic threshold is determined based on the historical traffic of the target process. Then, based on the relationship between the instantaneous traffic value of the target process and the instantaneous traffic threshold, it is determined whether to execute the access operation corresponding to the access data.

[0059] In some embodiments, see Figure 5 , Figure 5 This is a schematic diagram of a process for determining an instantaneous flow threshold provided in an embodiment of this application. Figure 4 In step 202 shown, quota pre-allocation is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold, which can be obtained through... Figure 5 Steps 2021A-2023A are implemented.

[0060] In step 2021A, the historical traffic value of the target process within the period is obtained; the historical traffic value of a portion of the period is used as the first traffic value.

[0061] For example, if the period is 60 seconds and a portion of the period is half of the period, then the portion of the period is 31 to 60 seconds. The flow value recorded in the 30 seconds before the current moment in the target process is taken as the first flow value of the target process in the portion of the period, and is denoted as A1.

[0062] In step 2022A, the sum of the historical traffic values ​​of processes other than the target process within a certain time period is used as the second traffic value.

[0063] Continuing with the previous example, when the period is 60 seconds, a portion of the period is half of the period, which is 31 to 60 seconds. The sum of the traffic values ​​recorded by processes other than the target process in the 30 seconds before the current time is taken as the second traffic value, denoted as B1. For example, processes other than the target process include process 1 and process 2. The traffic value recorded by process 1 in the 30 seconds before the current time is D1, and the traffic value recorded by process 2 in the 30 seconds before the current time is D2. That is, the sum of the traffic values ​​recorded by processes other than the target process in the 30 seconds before the current time is B1 = D1 + D2.

[0064] In step 2023A, the product of the ratio of the first flow value to the second flow value and the flow threshold is used as the instantaneous flow threshold.

[0065] Continuing the previous example, the ratio of the flow value A1 of the target process recorded during a portion of the period to the flow value B1 of other processes recorded during a portion of the period is taken as C3 = A1 / B1. Since A1 represents the flow value recorded by a single target process during a portion of the period, while B1 represents the flow value recorded by multiple processes other than the target process during a portion of the period, it can be understood that B1 is much larger than A1. That is, the instantaneous flow threshold is obtained by multiplying the proportion of A1 to B1 by the set flow threshold. Thus, the instantaneous threshold in the target process can be accurately determined, thereby achieving precise control over the instantaneous flow passing through the target process.

[0066] In some embodiments, see Figure 6 , Figure 6 This is a schematic diagram of the first process for determining the historical traffic value of a target process within a periodic time, provided in an embodiment of this application. Figure 5 Before step 2021A, steps 2021B-2023B are also included.

[0067] In step 2021B, the historical access data of the target process within the periodic time is obtained.

[0068] For example, historical access data includes timestamps recorded by the target process within a period of time. This can be understood as obtaining the timestamps of all access data that have ever been accessed by the target process within the period of time (60s).

[0069] In step 2022B, the storage parameters for the period are determined based on the identifiers of the target process's historical access data within the period.

[0070] Continuing from the previous example, based on the identifiers of the target process's historical access data within a period of 60 seconds, the storage parameters within the period of 60 seconds are determined. The storage parameters can represent the timestamps corresponding to all access data of the target process within the period of 60 seconds, as well as the number of requests corresponding to the timestamps.

[0071] In step 2023B, the storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end.

[0072] In some embodiments, the timestamps of the target process within a period are read from multiple memory units; based on the timestamps, the number of requests made by the target process within the period is determined, and the sum of the number of requests is used as the historical traffic value of the target process within the period.

[0073] For example, multiple memory units in the memory structure store storage parameters corresponding to the accessed data. These storage parameters include the request time of the target process at a certain moment within a period, and the number of requests corresponding to the access time. The number of requests corresponding to all moments within a period is summed, and the total number of requests is used as the historical traffic value of the target process within the period.

[0074] In some embodiments, see Figure 7 , Figure 7 This is a flowchart illustrating the process of determining storage parameters within a specific time period, as provided in an embodiment of this application. Figure 6 The step 2022B shown can also be achieved through Figure 7 Steps 2021C-2023C are implemented.

[0075] In step 2021C, the identifier of the target process's historical access data within the period is used as the timestamp of the target process's historical access data within the period.

[0076] For example, the time identifiers of the target process's historical access data within a period of time include A1-A N(Time identifier is unique, therefore A1-A) N (All values ​​are distinct), the time stamps include A1-A N The numerical value serves as the timestamp of the target process's historical access data within a given period: timekey1-timekey N .

[0077] In step 2022C, when there is a correlation between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1.

[0078] Continuing the previous example, if the target process accesses data A within a period of time and the time identifier is A1, then the timestamp (timekey) is stored in the memory unit corresponding to the time identifier A1 and the current index X. x And after index X satisfies the equation under specific rules, the timestamp (timekey) of the memory unit corresponding to the current index X is stored. x The corresponding sum1 request count is incremented by 1.

[0079] In step 2023C, when there is no association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0080] Continuing the previous example, if the target process accesses data A at time A1 within a period, and the timestamp (timekeyx) stored in the memory unit corresponding to the current index X, and index X cannot satisfy the equation under specific rules, then the timestamp (timekeyx) stored in the memory unit corresponding to the current index X will be used. x After the corresponding sum1 request count is cleared to zero, it is reset to 1.

[0081] In some embodiments, see Figure 8 , Figure 8 This is a schematic diagram of a process for storing parameters in a memory structure, provided in an embodiment of this application. Figure 6 The step 2023B shown can also be achieved through Figure 8 Steps 2021D-2022D are implemented.

[0082] In step 2021D, the remainder between the timestamp of the target process within the period and the number of multiple memory units is used as the index of the memory unit.

[0083] For example, if there are N memory units, and the remainder of the timestamp of the target process within the period is 1 when divided by N, then the remainder of 1 when divided by the number of memory units is used as the index of the memory unit. Similarly, if the remainder of the timestamp of the target process within the period is 2 when divided by N, then the remainder of 2 when divided by the number of memory units is used as the index of the memory unit.

[0084] In step 2022D, the timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

[0085] Continuing the previous example, since the timestamp is determined by the timestamp of historical access data, within a given period, multiple access data may access the target process at the same time. The request count corresponding to the timestamp represents the number of times multiple access data accessed the target process at the same time.

[0086] In step 203, in response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold, the identifier of the access data is cyclically eliminated. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed, wherein the first flow control threshold is less than the second flow control threshold.

[0087] Here, the process of cyclically eliminating the identifiers of access data is controlled by the server. Based on the relationship between the traffic threshold and the first flow control threshold, the identifiers of access data are cyclically eliminated. Whether the access operation corresponding to the access data should be executed depends on whether the quota identifier to be eliminated can be eliminated.

[0088] In some embodiments, see Figure 9 , Figure 9 This is a flowchart illustrating a process for cyclically eliminating the identifier of accessed data, as provided in an embodiment of this application. Figure 4 The step 203 shown illustrates the cyclic elimination process for the identifier of the accessed data, which can be achieved through... Figure 9 Steps 2031A-2033A are implemented.

[0089] In step 2031A, quota pre-allocation is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold.

[0090] In step 2032A, when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the accessed data is compared with multiple sets of quota identifiers to be eliminated in a loop.

[0091] Continuing the previous example, when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the accessed data is compared cyclically with multiple preset sets of quota identifiers to be eliminated. For example, when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the current accessed data is A1. Among the multiple preset sets of quota identifiers to be eliminated, there is a quota identifier to be eliminated that matches the identifier A1 of the current accessed data. It is also possible that there was a quota identifier to be eliminated that matches the identifier A1 of the current accessed data before, but because there is too much accessed data at the same time, all the quota identifiers to be eliminated that match the identifier A1 of the current accessed data in the multiple sets of quota identifiers to be eliminated have been eliminated. Therefore, there is no quota identifier to be eliminated that matches the identifier A1 of the current accessed data in the multiple sets of quota identifiers to be eliminated.

[0092] In step 2033A, when the identifier of the accessed data represented by the cyclic comparison result is the same as the identifier of the quota to be eliminated in any group, the identifier of the quota to be eliminated is eliminated.

[0093] Continuing from the previous example, the current access data identifier A1 is compared with multiple sets of quota identifiers to be eliminated in a loop. When any one of the multiple sets of quota identifiers to be eliminated matches the current access data identifier A1, the quota identifier to be eliminated is eliminated.

[0094] In some embodiments, see Figure 10 , Figure 10 This is a schematic diagram of the second process for determining the historical traffic value of a target process within a period of time, provided in an embodiment of this application. Figure 9 Before step 2032A shown, it can be done through Figure 10 Steps 2031B-2032B in the process yield multiple sets of quota identifiers to be eliminated.

[0095] In step 2031B, the quota identifiers to be eliminated are grouped based on the traffic threshold to obtain multiple groups of quota identifiers to be eliminated, wherein each group includes the same number of quota identifiers to be eliminated.

[0096] For example, the quota identifiers to be eliminated are grouped based on the traffic threshold to obtain multiple groups of quota identifiers to be eliminated, and the multiple groups of quota identifiers to be eliminated are sorted in ascending order by group number.

[0097] In step 2032B, the quota identifiers to be eliminated in any group are arranged in chronological order.

[0098] It should be noted that the quota identifiers to be eliminated in any given group are arranged in chronological order, while the order between groups is determined only by the group number. Therefore, during the process of cyclically comparing and eliminating the identifiers of the currently accessed data with multiple groups of quota identifiers to be eliminated, if a server suddenly disconnects, its reconnection will ensure that the set quotas are eliminated evenly, resulting in more precise traffic control.

[0099] In step 204, in response to the traffic threshold not reaching the first flow control threshold, the identifier of the access data is compared and statistically processed. When the result of the comparison and statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed.

[0100] Here, the method of comparing and statistically processing the identifiers of the access data is controlled by the server. When the result of the comparison and statistical processing represents the sum of the historical traffic values ​​of multiple processes, it is determined that the access operation corresponding to the access data will be executed.

[0101] In some embodiments, see Figure 11 , Figure 11 This is a flowchart illustrating the comparative statistical processing of access data identifiers provided in an embodiment of this application. Figure 4 Step 204, as shown, involves comparative statistical processing of the identifiers of the accessed data, which can be achieved through... Figure 11 Steps 2041A-2043A are implemented.

[0102] In step 2041A, quota pre-allocation is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold.

[0103] In step 2042A, when the instantaneous flow value of the target process is less than the instantaneous flow threshold, the historical flow values ​​of multiple processes within the period are statistically analyzed to obtain the sum of the historical flow values ​​of multiple processes.

[0104] Continuing from the previous example, when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the historical traffic A-historical traffic E of all processes, such as process A-process E, received within the period (60S) is summed to obtain the sum of the historical traffic values ​​of multiple processes.

[0105] In step 2043A, the sum of the historical traffic values ​​of multiple processes is compared with the traffic threshold to obtain the result of comparative statistical processing.

[0106] In some embodiments, see Figure 12 , Figure 12This is a flowchart illustrating a process for determining the sum of historical traffic values ​​for multiple processes, as provided in an embodiment of this application. Figure 11 Step 2042A shown can be achieved through Figure 12 Steps 2041B-2043B are implemented.

[0107] In step 2041B, historical access data of multiple processes within a period of time is obtained.

[0108] For example, historical access data includes time stamps recorded by multiple processes within a period of time. This can be understood as obtaining the time stamps of all access data that have been accessed in multiple processes within a period of time (60s).

[0109] In step 2042B, storage parameters for the period of time are determined based on the identifiers of historical access data of multiple processes within the period.

[0110] For example, based on the identifiers of historical access data of multiple processes within a period of time (60s), storage parameters within the period of time are determined. The storage parameters can represent the timestamps corresponding to all access data of multiple processes within the period of time, as well as the number of requests corresponding to the timestamps.

[0111] In step 2043B, the storage parameters are stored in a memory structure, wherein the memory structure comprises multiple memory units connected end to end.

[0112] In some embodiments, timestamps of multiple processes within a period of time are read from multiple memory units; based on the timestamps, the number of requests made by the multiple processes within the period of time is determined, and the sum of the number of requests is used as the sum of the historical traffic values ​​of the multiple processes within the period of time.

[0113] For example, multiple memory units in the memory structure store storage parameters corresponding to accessed data. These storage parameters include the request time of multiple processes at a certain moment within a period, and the number of requests corresponding to each access time. The total number of requests at all moments within a period is summed, and this sum is used as the sum of the historical traffic values ​​of multiple processes within the period.

[0114] In some embodiments, see Figure 13 , Figure 13 This is a flowchart illustrating the determination of storage parameters within a multi-threaded cycle time, as provided in an embodiment of this application. Figure 12 The step 2042B shown can be achieved through Figure 13 Steps 2041C-2043C are implemented.

[0115] In step 2041C, the identifiers of the historical access data of multiple processes within the period are used as timestamps to determine the historical access data of multiple processes within the period.

[0116] For example, the time identifiers of historical access data of multiple processes within a period of time include A1-A N (Time identifier is unique, therefore A1-A) N (All values ​​are distinct), the time stamps include A1-A N The numerical value serves as a timestamp for historical access data of multiple processes within a given period: timekey1-timekey N .

[0117] In step 2042C, when there is an association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1.

[0118] For example, when one of multiple processes accesses data A within a period of time and the time identifier is A1, the timestamp (timekey) stored in the memory unit corresponding to the time identifier A1 and the current index X is used. x And after index X satisfies the equality relationship under specific rules, the number of sum1 requests corresponding to the timestamp timekeyx stored in the memory unit corresponding to the current index X is incremented by 1.

[0119] In step 2043C, when there is no association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0120] For example, when one of the multiple processes accesses data A within a period of time and the time identifier is A1, after determining that the time identifier A1 and the timestamp timekeyx stored in the memory unit corresponding to the current index X, and the index X cannot satisfy the equation relationship under the specific rule calculation, the sum1 request count corresponding to the timestamp timekeyx stored in the memory unit corresponding to the current index X is cleared to zero and reset to 1.

[0121] In some embodiments, see Figure 14 , Figure 14 This is a flowchart illustrating the storage of parameters for accessing data in multiple processes within a memory structure, as provided in an embodiment of this application. Figure 12 Step 2043B shown can be achieved through Figure 14 Steps 2041D-2042D are implemented.

[0122] In step 2041D, the remainder between the timestamps of multiple processes within the period and the number of multiple memory units is used as the index of the memory unit.

[0123] For example, if there are N memory units, and the remainder of the timestamps of multiple processes within a period of time is 1 when divided by N, then the remainder of 1 when divided by the number of memory units is used as the index of the memory unit. Similarly, if the remainder of the timestamps of multiple processes within a period of time is 2 when divided by N, then the remainder of 2 when divided by the number of memory units is used as the index of the memory unit.

[0124] In step 2042D, the timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

[0125] For example, since the timestamp is determined by the timestamp of historical access data, multiple processes within a period may access the target process at the same time. The request count corresponding to the timestamp represents the number of times multiple access data accessed the target process at the same time.

[0126] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.

[0127] This application's embodiments can be applied to various traffic access restriction scenarios, such as game marketing scenarios and web-based survey scenarios. The following explanation uses a game marketing scenario as an example: To address the aforementioned problems, this application proposes a flow control scheme that enables precise flow control. See also... Figure 15 , Figure 15 This is a schematic diagram illustrating the principle of load protection provided in an embodiment of this application, as shown below. Figure 15 The diagram shows how access traffic is managed through downstream service clusters, flow control services, and the management terminal.

[0128] Step 401: Allocate and configure the traffic threshold for each game marketing campaign based on the user's software and hardware performance.

[0129] For each game marketing campaign, the management system (management terminal M) allocates and configures the traffic threshold (Quota) based on the user's hardware and software performance (including computing efficiency and storage resources).

[0130] Step 402: Generate flow control method based on object configuration flow threshold and system's own flow control service capacity.

[0131] The management system generates a flow control method (Type) based on the object configuration flow threshold (Quota) and the system's own flow control service capacity. The management system distributes the (Type, Quota) information to each active service (S) in the cluster, and the system's own flow control service capacity determines the first flow control threshold and the second flow control threshold.

[0132] Step 403: The flow control API in each active service (S) implements the flow control function together with the flow control service (Q) based on the (Type, Quota) information.

[0133] refer to Figure 16 , Figure 16 which is a schematic diagram of the principle of the traffic control method provided by the embodiments of the present application, and specifically illustrates the traffic control implementation solution of the embodiments of the present application: On the basis of the prior art solution, this solution introduces a key flow control service module to implement three flow control modes: A: Single-key control; B: Hot key splitting; C: Quota pre-allocation.

[0134] When providing external services, flow control services are provided in a combined three-level manner based on the size and accuracy requirements of external traffic. Two thresholds, Q1 (i.e., the first flow control threshold) and Q2 (i.e., the second flow control threshold), are set (Q1<<Q2).

[0135] Step 501: When Quota>Q2, quota pre-allocation is used to perform restriction judgment on the current traffic.

[0136] When Quota (the object configuration traffic threshold) > Q2, quota pre-allocation is adopted. Each time external traffic enters, the flow control API checks whether the total requests per unit time (second) reach the memory quota (MQ) according to the process memory quota (MQ) calculated in real time by the flow control service. If the total requests reach the memory quota, the current traffic is restricted; otherwise, normal service logic is performed (the quota pre-allocation processing includes quota pre-allocation).

[0137] Step 502: When Q1<Quota<Q2, quota pre-allocation and hot key splitting are used to perform restriction judgment on the current traffic.

[0138] When Q1<Quota<Q2, quota pre-allocation and hot key splitting are adopted. Each time external traffic enters, the flow control API first checks whether the current pre-allocated quota (the total quota is usually set as N Quota, N>=5) is reached. If reached, the current traffic is restricted; if not, the flow control API requests the flow control service to judge whether the current traffic needs to be restricted, and the flow control service judges whether the current traffic is restricted according to the hot key splitting mode (the flow control mode of loop elimination processing includes quota pre-allocation and hot key splitting).

[0139] Step 503: When Quota<Q1, quota pre-allocation and single-key control are used to perform restriction judgment on the current traffic.

[0140] When Quota<Q1, quota pre-allocation and single-key control are adopted. Each time external traffic enters, the flow control API first checks whether the current pre-allocated quota (the total quota is usually set as N If the quota (N>=5) has been reached, the current traffic will be restricted; otherwise, the flow control API will request the flow control service to determine whether the current traffic needs to be restricted. The flow control service will determine whether the current traffic should be restricted based on the single-key control method (the flow control methods for comparative statistical processing include quota pre-allocation and single-key control).

[0141] It should be noted that the process memory quota (MQ) in step 501 and the current pre-allocated quota in steps 502-503 are only different in name and value, but the steps involved in the quota pre-allocation technical solution are the same. The Quota set in steps 501-503 are different because, in order to avoid directly breaking down the service, the Quota is expanded in the form of N. That is, the technical steps involved in quota pre-allocation in the above embodiments are consistent, which is equivalent to the first layer (larger scope) of traffic control.

[0142] Below, regarding single-key control technology solutions, please refer to... Figure 17 , Figure 17 This is a schematic diagram of a single-key control technology solution for flow control provided in an embodiment of this application. Figure 17 The single-key control technology solution is explained.

[0143] The single-key control method involved in this application optimizes key storage based on existing flow control. In the existing scheme, each flow control object requires 1 key per second, which puts a significant burden on the storage service. The new method uses a fixed number (N) keys, with the key / value format as follows: Key: Index_Flow Control Object Identifier (Index = Reporting Timestamp % N), Value: Reporting Timestamp_Quantity. The single-key control method optimizes the storage format of traffic objects, thereby avoiding frequent key / value creation and saving storage resources, thus achieving precise traffic control.

[0144] See below Figure 18 , Figure 18 This is a schematic diagram of the hotkey splitting technology solution for flow control provided in the embodiments of this application. Regarding the hotkey splitting technology solution, the following is based on... Figure 18 The hotkey splitting technology solution is explained.

[0145] The management system, based on the traffic quota (Q), splits the quota to be eliminated, akey, into N keys: akey1, akey2, ..., akeyn. Each key corresponds to multiple sets of quotas to be eliminated (the number of sets is Q / N). The active service request (identified by akey) is sent to the flow control service. Then, the flow control service, according to the configured sets of quotas to be eliminated, iteratively determines which akey is selected from a single group based on its time identifier within that group, and matches it with the current service request. When the current service request matches an akey within a group, that akey is removed from the current single group, thus allowing the current service request to access the active service.

[0146] It's important to note that "sequential looping" means that when a server receives 1000 access requests per second, these requests are processed sequentially from akey1 to N, for each of the N keys: akey1, akey2, ..., akeyn. The quota is then cyclically eliminated within the group based on the current timestamp. Furthermore, if a server suddenly goes offline, there will be no uneven elimination of quotas, preventing resource waste. (In other words, the set quota can be eliminated evenly.)

[0147] See below Figure 19 , Figure 19 This is a schematic diagram of the quota pre-allocation technology solution for flow control provided in the embodiments of this application. Regarding the quota pre-allocation technology solution, the following is based on... Figure 19 The technical scheme for quota pre-allocation is explained.

[0148] The flow control service calculates the current activity service's unit time (second) quota based on the data reported by the activity service. The specific method is as follows: Step 601: Determine whether to limit the traffic based on the process memory quota (MQ) and the number of requests in the process memory in the last second.

[0149] When external traffic enters the activity service, the activity service counts the number of requests and checks the number of requests in the process memory within the last second. If the number of requests exceeds the process memory quota (MQ), the traffic is throttled. If the number of requests is less than the process memory quota or the process memory quota is zero (the initial quota is zero), the traffic is unrestricted.

[0150] Step 602: Store the number of requests in the memory structure.

[0151] See Figure 20 , Figure 20 This is a schematic diagram illustrating the storage principle of the storage parameters provided in this application embodiment. The memory structure for the activity service to store the request volume of this process is as follows: Figure 20As shown, the memory cell (i.e., memory unit) where the request falls is calculated based on the request time, and then the count of that memory cell is incremented by one. These six cells are connected end to end to form a loop for use. As the time window moves, the cell at index 5 is used up, and then the cell at index 0 is used. The specific implementation is as follows: Each service process allocates an array Arr[6] of length 6 for each type of request that requires quota limits. Each item in the array is a structure, which mainly contains two members: time_t timekey; / / Time key (timestamp) int64_t sum; / / Request count (number of requests corresponding to the timestamp) For each request, obtain the number of seconds A (where A represents the complete number of seconds), then use A / 10 (between [0, 5]) as the array index to calculate timekey = A - A%60 + index 10. If timekey equals Arr[index].timekey, then increment Arr[index].sum by 1. If timekey does not equal Arr[index].timekey, it indicates a loop has occurred (i.e., Arr[index] is already full), so directly set Arr[index].sum to 1 (i.e., clear it and then increment sum by 1), and reset Arr[index].timekey to the calculated timekey. See also Figure 21 , Figure 21 This is a schematic diagram of the flow control storage strategy provided in the embodiments of this application.

[0152] Step 603: Periodically return the quota of the current process (target process).

[0153] Each time traffic enters the activity service, it checks whether the time interval between the last request to the configuration service has reached 5 seconds. If it has reached 5 seconds, it reports the current process's activity request volume information (i.e., the array Arr mentioned above) and the current process's process count to the flow control service, and the flow control service returns the current process's quota.

[0154] Step 604: Determine the current process quota based on the data reported by each process.

[0155] The flow control service receives the reported quantity from each process, similar to how the activity service stores data from each reporting process over several time slices. It then uses data from 30 seconds prior (ensuring complete data reporting from all services within this calculation period) to calculate the quota for each process based on the normal traffic allocation ratio. The specific calculation method for the quota of a single request process is as follows: Step 604a: Calculate the total number of time slice requests made by all reporting processes 30 seconds ago.

[0156] Step 604b: Calculate the total number of time slice requests (self) made by the process 30 seconds ago.

[0157] Step 604c: The current quota for this process is: Quota (total quota) self / total.

[0158] Step 605: Determine the average quota based on the current quota of the process, and determine whether to limit the traffic for this operation.

[0159] The flow control service returns the quota for a single process along with the number of all reported processes. In some exceptional cases, the activity service uses the average quota (total quota / total number of reported processes) to limit traffic.

[0160] This application embodiment can deploy multiple active servers on the same machine or in a container scenario, deploy an agent service, and access the flow control service through the agent to achieve flow control. See [link to relevant documentation]. Figure 22 , Figure 22 This is a schematic diagram of the flow control scheme provided in the embodiments of this application.

[0161] In this embodiment of the application, by deploying an agent between the activity server and the flow control service, the agent controls part of the flow control logic. For example, at least one or more of the three flow control methods, namely quota pre-allocation processing, loop elimination processing, and comparative statistics processing, are controlled by the agent, thereby sharing a portion of the flow control logic.

[0162] The advantages of this technical solution are: 1. The Agent handles part of the flow control logic, and the API accessed by the activity service is relatively simple, less prone to errors (bugs), and does not require frequent upgrades. 2. If the flow control logic needs to be adjusted, only the Agent needs to be upgraded, without adjusting the flow control API, thus not affecting existing network services. 3. Multiple services can be deployed on a single machine or container. In the quota allocation method, the local Agent can aggregate the data before requesting the remote flow control service, reducing the computational and bandwidth pressure on the flow control service.

[0163] It is understood that, in the embodiments of this application, the data related to instant messaging messages, etc., need to obtain user permission or consent when the embodiments of this application are applied to specific products and technologies, and the collection, use and processing of related data need to comply with the relevant laws, regulations and standards of relevant countries and regions.

[0164] The following description continues to illustrate the exemplary structure of the flow control device 555 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 3As shown, the software module stored in the flow control device 555 in the memory 550 may include: The traffic threshold determination module 5551 is used to obtain the access data in the target process and the traffic threshold of the target process; the quota pre-allocation processing module 5552 is used to perform quota pre-allocation processing based on the historical traffic value of the target process in response to the traffic threshold reaching the second flow control threshold, to obtain the instantaneous traffic threshold, and to determine that the access operation corresponding to the access data will be executed when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold; the loop elimination processing module 5553 is used to perform loop elimination processing on the identifier of the access data in response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold, and to determine that the access operation corresponding to the access data will be executed when the quota identifier to be eliminated corresponding to the access data is eliminated, wherein the first flow control threshold is less than the second flow control threshold; the comparison and statistics processing module 5554 is used to perform comparison and statistics processing on the identifier of the access data in response to the traffic threshold not reaching the first flow control threshold, and to determine that the access operation corresponding to the access data will be executed when the result of the comparison and statistics processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, wherein the multiple processes include the target process.

[0165] In some embodiments, the quota pre-allocation processing module is further configured to obtain the historical traffic value of the target process within a period; take the historical traffic value of a portion of the period as the first traffic value; take the sum of the historical traffic values ​​of processes other than the target process within the portion of the period as the second traffic value; and take the product of the ratio of the first traffic value to the second traffic value and the traffic threshold as the instantaneous traffic threshold.

[0166] In some embodiments, before obtaining the historical traffic value of the target process within a period, the quota pre-allocation processing module is further configured to obtain the historical access data of the target process within a period; determine the storage parameters within the period based on the identifier of the historical access data of the target process within a period, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; and store the storage parameters in a memory structure, wherein the memory structure includes multiple memory units connected end to end.

[0167] In some embodiments, the timestamps of the target process within a period are read from multiple memory units; based on the timestamps, the number of requests made by the target process within the period is determined, and the sum of the number of requests is used as the historical traffic value of the target process within the period.

[0168] In some embodiments, the quota pre-allocation processing module is further configured to use the identifier of the target process's historical access data within a period as the timestamp of the target process's historical access data within a period; when there is an association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; when there is no association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0169] In some embodiments, the quota pre-allocation processing module is further configured to use the remainder between the timestamp of the target process within a period and the number of multiple memory units as an index of the memory unit; and store the timestamp and the number of requests corresponding to the timestamp into the memory unit corresponding to the index.

[0170] In some embodiments, the cyclic elimination processing module is further configured to perform quota pre-allocation processing based on the historical traffic value of the target process to obtain an instantaneous traffic threshold; when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the access data is compared cyclically with multiple sets of quota identifiers to be eliminated; when the cyclic comparison result indicates that the identifier of the access data is the same as any set of quota identifiers to be eliminated, the quota identifier to be eliminated is eliminated.

[0171] In some embodiments, the cyclic elimination processing module is further configured to group the quota identifiers to be eliminated based on a traffic threshold before cyclically comparing the identifier of the access data with multiple groups of quota identifiers to be eliminated, thereby obtaining multiple groups of quota identifiers to be eliminated, wherein each group includes the same number of quota identifiers to be eliminated; and the quota identifiers to be eliminated in any group are arranged in chronological order.

[0172] In some embodiments, the comparison and statistical processing module is further configured to perform quota pre-allocation processing based on the historical traffic value of the target process to obtain an instantaneous traffic threshold; when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the historical traffic values ​​of multiple processes within a period of time are statistically analyzed to obtain the sum of the historical traffic values ​​of multiple processes; the sum of the historical traffic values ​​of multiple processes is compared with the traffic threshold to obtain the result of the comparison and statistical processing.

[0173] In some embodiments, the comparison and statistics processing module is further configured to obtain historical access data of multiple processes within a period of time; determine storage parameters within the period of time based on the identifiers of the historical access data of multiple processes within the period of time, wherein the storage parameters include timestamps and the number of requests corresponding to the timestamps; and store the storage parameters in a memory structure, wherein the memory structure includes multiple memory units connected end to end. In some embodiments, the comparison statistics processing module is further configured to read the timestamps of multiple processes within a period from multiple memory units; based on the timestamps, determine the number of requests made by the multiple processes within the period, and use the sum of the number of requests as the sum of the historical traffic values ​​of the multiple processes within the period.

[0174] In some embodiments, the comparison and statistics processing module is further configured to use the identifier of the historical access data of multiple processes within a period of time as the timestamp for determining the historical access data of multiple processes within a period of time; when there is an association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; when there is no association between the identifier and the timestamp and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

[0175] In some embodiments, the comparison and statistics processing module is further configured to use the remainder of the timestamps of multiple processes within a period of time and the number of multiple memory units as the index of the memory unit; and store the timestamp and the number of requests corresponding to the timestamp into the memory unit corresponding to the index.

[0176] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the flow control method described above in this application.

[0177] This application provides a computer-readable storage medium storing executable instructions, wherein the executable instructions, when executed by a processor, will cause the processor to execute the flow control method provided in this application.

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

[0179] In some embodiments, executable instructions may take 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 standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.

[0180] As an example, executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborating files (e.g., a file that stores one or more modules, subroutines, or code sections).

[0181] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.

[0182] In summary, the embodiments of this application have the following beneficial effects: Each of the three flow control methods has its advantages and disadvantages: quota pre-allocation offers high performance and robustness, and the flow control service is insensitive to drastic traffic changes. However, it cannot accurately control small traffic volumes. Single-key control provides precise flow control, but it incurs performance overhead and is prone to generating hotkeys, thus becoming a system bottleneck. Hotkey splitting alleviates the hotkey generation problem while maintaining control precision and expands the application scope of single-key control, but it cannot fundamentally solve some inherent problems of single-key control. This application's embodiment adopts a technical solution that combines multiple individual flow control methods to control the traffic in the current thread, systematically solving flow control problems in various scenarios.

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

Claims

1. A flow control method, characterized in that, The method includes: Obtain access data in the target process and the traffic threshold of the target process; In response to the traffic threshold reaching the second flow control threshold, a quota pre-allocation process is performed based on the historical traffic value of the target process to obtain an instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed. The quota pre-allocation process based on the historical traffic value of the target process to obtain the instantaneous traffic threshold includes: obtaining the historical traffic value of the target process within a period; using the historical traffic value of a portion of the period as a first traffic value; using the sum of the historical traffic values ​​of processes other than the target process within the portion of the period as a second traffic value; and using the product of the ratio of the first traffic value to the second traffic value and the traffic threshold as the instantaneous traffic threshold. In response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold, the identifier of the access data is cyclically eliminated. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed, wherein the first flow control threshold is less than the second flow control threshold. The cyclic elimination process of the identifier of the access data includes: performing quota pre-allocation processing based on the historical traffic value of the target process to obtain the instantaneous traffic threshold; when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the access data is cyclically compared with multiple sets of quota identifiers to be eliminated; when the cyclic comparison result indicates that the identifier of the access data is the same as any set of quota identifiers to be eliminated, the quota identifier to be eliminated is eliminated. In response to the traffic threshold not reaching the first flow control threshold, the identifier of the access data is subjected to comparative statistical processing. When the result of the comparative statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed, wherein the multiple processes include the target process. The comparative statistical processing of the identifier of the access data includes: performing quota pre-allocation processing based on the historical traffic value of the target process to obtain the instantaneous traffic threshold; when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, statistically analyzing the historical traffic values ​​of the multiple processes within a period of time to obtain the sum of the historical traffic values ​​of the multiple processes; comparing the sum of the historical traffic values ​​of the multiple processes with the traffic threshold to obtain the result of the comparative statistical processing.

2. The method according to claim 1, characterized in that, Before obtaining the historical traffic values ​​of the target process within the periodic time, the method further includes: Obtain the historical access data of the target process within the specified period; Based on the identifiers of the target process's historical access data within a period of time, storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; The step of obtaining the historical traffic value of the target process within a period of time includes: Read the timestamp of the target process within the periodic time from the plurality of memory units; Based on the timestamp, the number of requests made by the target process within the period is determined, and the sum of the number of requests is used as the historical traffic value of the target process within the period.

3. The method according to claim 2, characterized in that, The step of determining the storage parameters within the period based on the identifiers of the target process's historical access data within the period includes: The identifier of the target process's historical access data within the period is used as the timestamp of the target process's historical access data within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

4. The method according to claim 2, characterized in that, The step of storing the storage parameters in a memory structure includes: The remainder between the timestamp of the target process within the period and the number of the plurality of memory units is used as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

5. The method according to claim 1, characterized in that, Before cyclically comparing the identifier of the access data with multiple sets of quota identifiers to be eliminated, the method further includes: The quota identifiers to be eliminated are grouped based on the traffic threshold to obtain multiple groups of quota identifiers to be eliminated, wherein each group includes the same number of quota identifiers to be eliminated. The quota identifiers to be eliminated in any group are arranged in chronological order.

6. The method according to claim 1, characterized in that, The step of statistically analyzing the historical traffic values ​​of the multiple processes within a period of time to obtain the sum of the historical traffic values ​​of the multiple processes includes: Obtain historical access data of the multiple processes within a periodic time; Based on the identifiers of the historical access data of the multiple processes within a period of time, the storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; Obtaining the sum of the historical traffic values ​​of the multiple processes includes: Read the timestamps of the multiple processes within the periodic time from the multiple memory units; Based on the timestamp, the number of requests made by the plurality of processes within the periodic time is determined, and the sum of the number of requests is taken as the sum of the historical traffic values ​​of the plurality of processes within the periodic time.

7. The method according to claim 6, characterized in that, The step of determining the storage parameters within the period based on the identifiers of the historical access data of the multiple processes within the period includes: The identifiers of the historical access data of the multiple processes within the period are used as the timestamps for determining the historical access data of the multiple processes within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

8. The method according to claim 6, characterized in that, The step of storing the storage parameters in a memory structure includes: The remainder between the timestamps of the multiple processes within the period and the number of the multiple memory units is used as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

9. A flow control device, characterized in that, The device includes: A traffic threshold determination module is used to obtain access data in the target process and the traffic threshold of the target process; The quota pre-allocation processing module is used to respond to the traffic threshold reaching the second flow control threshold by performing quota pre-allocation processing based on the historical traffic value of the target process to obtain an instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, it is determined that the access operation corresponding to the access data will be executed. Specifically, the module obtains the historical traffic value of the target process within a period; uses the historical traffic value of a portion of the period as a first traffic value; uses the sum of the historical traffic values ​​of processes other than the target process within the portion of the period as a second traffic value; and uses the product of the ratio of the first traffic value to the second traffic value and the traffic threshold as the instantaneous traffic threshold. A cyclic elimination processing module is used to perform cyclic elimination processing on the identifier of the access data in response to the traffic threshold not reaching the second flow control threshold but reaching the first flow control threshold. When the quota identifier to be eliminated corresponding to the access data is eliminated, it is determined that the access operation corresponding to the access data will be executed, wherein the first flow control threshold is less than the second flow control threshold; wherein the quota pre-allocation processing is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold, and when the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the identifier of the access data is cyclically compared with multiple sets of quota identifiers to be eliminated, and when the cyclic comparison result indicates that the identifier of the access data is the same as any set of quota identifiers to be eliminated, the quota identifier to be eliminated is eliminated; The comparison and statistical processing module is used to perform comparison and statistical processing on the identifier of the access data in response to the traffic threshold not reaching the first flow control threshold. When the result of the comparison and statistical processing indicates that the sum of the historical traffic values ​​of multiple processes is less than the traffic threshold, it is determined that the access operation corresponding to the access data will be executed. The multiple processes include the target process. The quota pre-allocation processing is performed based on the historical traffic value of the target process to obtain the instantaneous traffic threshold. When the instantaneous traffic value of the target process is less than the instantaneous traffic threshold, the historical traffic values ​​of the multiple processes within a period of time are statistically analyzed to obtain the sum of the historical traffic values ​​of the multiple processes. The sum of the historical traffic values ​​of the multiple processes is compared with the traffic threshold to obtain the result of the comparison and statistical processing.

10. The apparatus according to claim 9, characterized in that, The quota pre-allocation processing module is also used to obtain the historical access data of the target process within the period before obtaining the historical traffic value of the target process within the period. Based on the identifiers of the target process's historical access data within a period of time, storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; Read the timestamp of the target process within the periodic time from the plurality of memory units; Based on the timestamp, the number of requests made by the target process within the period is determined, and the sum of the number of requests is used as the historical traffic value of the target process within the period.

11. The apparatus according to claim 10, characterized in that, The quota pre-allocation processing module is also used to use the identifier of the target process's historical access data within the period as the timestamp of the target process's historical access data within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

12. The apparatus according to claim 10, characterized in that, The quota pre-allocation processing module is further configured to use the remainder between the timestamp of the target process within the period and the number of the plurality of memory units as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

13. The apparatus according to claim 9, characterized in that, The loop elimination processing module is further configured to group the quota identifiers to be eliminated based on the traffic threshold before comparing the identifier of the access data with the multiple groups of quota identifiers to be eliminated in a loop, thereby obtaining the multiple groups of quota identifiers to be eliminated, wherein each group includes the same number of quota identifiers to be eliminated. The quota identifiers to be eliminated in any group are arranged in chronological order.

14. The apparatus according to claim 9, characterized in that, The comparison and statistics processing module is also used to obtain historical access data of the multiple processes within a period of time; Based on the identifiers of the historical access data of the multiple processes within a period of time, the storage parameters within the period of time are determined, wherein the storage parameters include a timestamp and the number of requests corresponding to the timestamp; The storage parameters are stored in a memory structure, wherein the memory structure includes multiple memory units connected end to end; Read the timestamps of the multiple processes within the periodic time from the multiple memory units; Based on the timestamp, the number of requests made by the plurality of processes within the periodic time is determined, and the sum of the number of requests is taken as the sum of the historical traffic values ​​of the plurality of processes within the periodic time.

15. The apparatus according to claim 14, characterized in that, The comparison and statistics processing module is also used to use the identifier of the historical access data of the multiple processes within the period as the timestamp for determining the historical access data of the multiple processes within the period. When there is an association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is incremented by 1; When there is no association between the identifier, the timestamp, and the index of the memory unit, the request count corresponding to the timestamp is reset to 1.

16. The apparatus according to claim 14, characterized in that, The comparison and statistics processing module is also used to use the remainder between the timestamps of the multiple processes within the period and the number of the multiple memory units as the index of the memory unit; The timestamp and the number of requests corresponding to the timestamp are stored in the memory unit corresponding to the index.

17. A flow control device, characterized in that, The flow control device includes: Memory, used to store executable instructions; A processor, when executing executable instructions stored in the memory, implements the method according to any one of claims 1 to 8.

18. A computer-readable storage medium storing executable instructions, characterized in that, When the executable instructions are executed by the processor, they implement the flow control method according to any one of claims 1 to 8.

19. A computer program product comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by the processor, they implement the flow control method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Data flow control method and device, computer equipment and storage medium

    CN110891286A

  • Access request processing method and device, storage medium and electronic equipment

    CN111866101A