Service flow limiting method and device based on request header, equipment and storage medium
By analyzing historical request data and dynamic parameters in request headers, dynamically adjusting the current limiting strategy to realize service current limiting based on request headers, solving the problems of large resource consumption and performance degradation of existing current limiting solutions, and improving the current limiting efficiency and resource utilization.
Patent Information
- Application Number
- CN202411791549.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2025-04-15
AI Technical Summary
The existing service flow limiting solution requires unpacking HTTP request packets, resulting in large server resource consumption, large computing volume, and degradation of system performance.
By analyzing the historical request data and dynamic parameters in the request header, determining the size distribution and resource consumption of the requested data packet, dynamically adjusting the current limiting strategy, and realizing service current limiting based on the request header.
Service flow limit can be achieved without unpacking, save server resources, improve flow limit efficiency, optimize resource allocation, and avoid service crashes or user experience declines caused by high traffic.
Smart Images

Figure CN119835230A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer network technology, and in particular to a service flow limiting method, device, equipment and storage medium based on a request header. Background Art
[0002] With the diversified development of network services, especially the rapid popularization of the Internet and mobile Internet, the number of requests received by the system has increased significantly. Traditional flow limiting methods are based on fixed thresholds or rules, which are difficult to adapt to the complexity of different business request characteristics, especially the dynamically changing request traffic. For example, the current business flow limiting scheme usually requires unpacking HTTP request data packets to achieve specific business flow limiting. This method not only consumes a lot of server resources, but also has a very large amount of calculation when multiple parameters are passed in, resulting in a decrease in system performance.
[0003] The present invention aims to provide a solution for realizing service flow limiting without unpacking, thereby saving server resources and improving flow limiting efficiency. Summary of the invention
[0004] The present application provides a request header-based service flow limiting method, device and storage medium to solve the problem that the current service flow limiting scheme requires unpacking the request data packet to implement specific service flow limiting, which not only consumes a large amount of server resources, but also has a very large amount of calculation when multiple parameters are passed in, resulting in a decrease in system performance.
[0005] In a first aspect, the present application provides a service flow limiting method based on a request header, the method comprising:
[0006] Performing data packet parameter analysis based on historical request data to determine data analysis results; wherein the data analysis results include size distribution of request data packets;
[0007] Performing dynamic parameter analysis based on the data analysis results to determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption;
[0008] Determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption;
[0009] Based on the size distribution of the request data packets of different data interfaces, estimating the number of request data parameters of different interfaces;
[0010] Determine the size of the service parameter data packet corresponding to each request based on the number of the different interface request data parameters;
[0011] Upon receiving a service request, determining a minimum unit service parameter data packet size corresponding to the service request based on a service parameter data packet size corresponding to each request;
[0012] Determine whether to limit the flow of the service request according to a preset flow limiting strategy and the minimum unit service parameter data packet size.
[0013] In some embodiments, determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption includes:
[0014] Get the number of threads of the device;
[0015] Determining a request response time of a minimum unit data packet based on the number of threads, the estimated number of dynamic parameters, and the estimated dynamic parameter resource consumption;
[0016] The single minimum unit parameter data length is determined based on the request response time and resource consumption of the minimum unit data packet.
[0017] In some embodiments, determining the single minimum unit parameter data length based on the request response time and resource consumption of the minimum unit data packet includes:
[0018] Get the response time coefficient of dynamic parameters;
[0019] The single minimum unit parameter data length is determined based on the response time coefficient of the dynamic parameter, the request response time and resource consumption of the minimum unit data packet.
[0020] In some embodiments, determining the single minimum unit parameter data length based on the response time coefficient of the dynamic parameter, the request response time of the minimum unit data packet, and the resource consumption includes:
[0021] Multiplying the request response time of the minimum unit data packet by the response time coefficient to obtain a target response time;
[0022] The single minimum unit parameter data length is determined based on the target response time and the resource consumption.
[0023] In some embodiments, the step of obtaining a response time coefficient of a dynamic parameter includes:
[0024] Clustering is performed based on the size distribution of the request data packets to obtain a plurality of data packet groups; wherein the size difference of the data packets in each of the data packet groups does not exceed a preset value;
[0025] For adjacent data packets in the data packet group, the average value is calculated by the following formula:
[0026]
[0027] Where a is the average value of the solution, t2 and t1 represent the response time of adjacent data packets, s2 and s1 represent the packet size of adjacent data packets;
[0028] The average values corresponding to a plurality of adjacent data packets in the data packet group are averaged to obtain a response time coefficient of the dynamic parameter.
[0029] In some embodiments, the preset current limiting strategy includes:
[0030] Get the current device load;
[0031] Determining whether the current device load exceeds a dynamic load threshold;
[0032] If yes, set a first current limiting threshold for the number of request headers and / or set a second current limiting threshold for the length of the requested data packet;
[0033] If not, a third current limiting threshold is set for the number of request headers; wherein the third current limiting threshold is greater than the first current limiting threshold.
[0034] In some embodiments, the dynamic load threshold is determined by:
[0035] Get historical device load;
[0036] Based on the current device load and the historical device load, the dynamic load threshold is determined by the following formula;
[0037]
[0038] Wherein, L is the dynamic load threshold, L0 is the initial current limiting threshold, C1 is the current device load, C2 is the average value of the historical device load, α is the weight coefficient of the historical device load, and C3 is the initial load threshold.
[0039] In a second aspect, the present application provides a service flow limiting device based on a request header, the device comprising:
[0040] A data packet parameter analysis module, used to perform data packet parameter analysis based on historical request data and determine data analysis results; wherein the data analysis results include size distribution of request data packets;
[0041] A dynamic parameter analysis module, used to perform dynamic parameter analysis based on the data analysis results, determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption;
[0042] A data length determination module, used to determine a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption;
[0043] A data packet quantity estimation module, used for estimating the quantity of request data parameters of different interfaces based on the size distribution of the request data packets of different data interfaces;
[0044] A data packet size estimation module, used to determine the service parameter data packet size corresponding to each request based on the number of data parameters requested by the different interfaces;
[0045] A data packet size determination module, configured to determine, upon receiving a service request, a minimum unit service parameter data packet size corresponding to the service request based on the service parameter data packet size corresponding to each request;
[0046] The current limiting module is used to determine whether to limit the current of the service request according to a preset current limiting strategy and the size of the minimum unit service parameter data packet.
[0047] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0048] Memory, used to store computer programs;
[0049] The processor is used to implement the steps of the service flow limiting method based on the request header described in any embodiment of the first aspect when executing the program stored in the memory.
[0050] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the service flow limiting method based on the request header as described in any embodiment of the first aspect are implemented.
[0051] The above-mentioned technical scheme provided by the embodiment of the present application has the following advantages compared with the prior art: the dynamic service flow limiting method based on request header provided by the present application determines the size distribution and resource consumption of request data packets by analyzing historical request data and dynamic parameters in request header data, and then dynamically adjusts the real-time flow limiting strategy, thereby effectively managing the traffic of different service requests, improving the utilization rate of network resources, optimizing resource allocation, and avoiding service crashes or decreased user experience due to instantaneous high traffic. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0053] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0054] Figure 1 A flowchart of a request header-based service flow limiting method provided in an embodiment of the present application;
[0055] Figure 2 A flow chart of a method for determining a current limiting strategy provided in an embodiment of the present application;
[0056] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0058] The following is an explanation of some terms involved in the embodiments of the present application.
[0059] Data packet: usually refers to the specific data packet content of an HTTP request, including the request header and request body.
[0060] Request header: A field contained in an HTTP request that describes the characteristics of the request, such as Content-Length.
[0061] Throttling: The process of controlling the flow of requests to ensure that server resources are not overloaded.
[0062] Minimum unit parameter data: In the flow limiting analysis, each parameter data is defined as the smallest business request unit, and its resource consumption is calculated and used to control the flow.
[0063] Dynamic parameters: refers to the variable parameters in each request, and its impact on server resources is analyzed based on historical data.
[0064] Threshold: A set limit value used to control the size of a requested data packet or the number of parameters.
[0065] Figure 1A flowchart of a request header-based service flow limiting method provided in an embodiment of the present application. In some embodiments, process 100 may be executed by an electronic device (eg, processor 111). Figure 1 As shown, process 100 may include the following operations.
[0066] Step 101, performing data packet parameter analysis based on historical request data to determine data analysis results.
[0067] Packet parameter analysis refers to the systematic analysis of the characteristic parameters of HTTP request packets (such as size, transmission protocol, transmission content type, etc.) to obtain the characteristics of the packets in different interface requests.
[0068] The data analysis results are conclusions drawn through data packet parameter analysis, including but not limited to information such as size distribution of request data packets, number of dynamic parameters, and basic field size, which are used for further flow limiting strategy formulation. In some embodiments, the data analysis results include size distribution of request data packets, basic field size, etc.
[0069] In some special cases, for example, for interfaces that support multi-parameter transmission, if there is a regular fixed number, such as each time a parameter is added, the length of the data packet increases by a corresponding length (for example, 10), then the single minimum unit parameter data length can be directly inferred, that is, the data analysis result can also include the single minimum unit parameter data length. The single minimum unit parameter data length refers to the average size of the smallest independent unit parameter in the data packet, which is usually obtained by analyzing the impact of a single parameter on the data packet length and can be used as a basis for current limiting.
[0070] In some embodiments, the processor can collect and store HTTP request packets from different interfaces and analyze their size (such as Content-Length) distribution. For multi-parameter requests, the impact of each additional parameter is estimated based on historical data. For example, if each additional parameter in the request increases the length of the packet by a fixed length, the length of a single minimum unit parameter can be estimated.
[0071] By performing statistical analysis on the request data packets of each interface, the distribution pattern of the request data packet size can be obtained, and the basic field size of each request can be calculated.
[0072] Step 102: Perform dynamic parameter analysis based on the data analysis result to determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption.
[0073] Dynamic parameter analysis refers to analyzing the variable parameters (i.e., dynamic parameters) in each request based on the parameter conditions in historical request data, and inferring the quantity of these parameters in the request data packet and the consumption of resources.
[0074] Estimating the number of dynamic parameters means estimating the number of variable parameters in a request by analyzing historical request data, so as to determine the parameter complexity of each request and optimize the current limiting strategy.
[0075] Estimating dynamic parameter resource consumption means estimating resource usage, such as CPU, memory, and response time consumption, by calculating the usage of server resources by each dynamic parameter based on the number of dynamic parameters.
[0076] In some embodiments, the average resource consumption can be calculated by analyzing the changes in dynamic parameters in historical requests. If it cannot be calculated, the response time of each request is recorded, and the CPU and time consumption are calculated in combination with the number of threads on the server to obtain the dynamic parameter consumption coefficient.
[0077] Step 103: Determine a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption.
[0078] In some embodiments, each parameter length in the historical data may be subjected to a differential analysis, and the average value of the minimum unit may be taken as the single minimum unit parameter data length.
[0079] In some embodiments, determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption includes:
[0080] Obtain the number of threads of the device; determine the request response time of the minimum unit data packet based on the number of threads, the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption; determine the single minimum unit parameter data length based on the request response time and resource consumption of the minimum unit data packet.
[0081] The number of threads refers to the multithreading capability of the device, that is, the number of threads that a server or processing device can use to process requests simultaneously. The number of threads directly affects the response time and resource consumption of each request.
[0082] The request response time of the minimum unit data packet refers to the average response time required for the device to process a single minimum unit parameter data packet in a single-threaded environment. This response time is calculated based on the number of threads and resource consumption of dynamic parameters, and is used to evaluate the processing time of each request.
[0083] The single minimum unit parameter data length refers to the average byte length of a single dynamic parameter in a data packet, which represents the size of the minimum request unit and serves as the basis for current limiting.
[0084] In some embodiments, the processor can obtain the number of threads supported by the current device through system monitoring or server configuration. For example, for a server that supports 32 threads, the average resource allocation amount of each thread can be recorded to more accurately calculate the response time of a single request. Further, the resource proportion of each request is allocated using the number of device threads and dynamic parameter resource consumption. For example, the request data packet is divided by thread, and when the number of dynamic parameters and resource consumption increase, the allocation ratio of thread resources is gradually increased to estimate the request response time of the minimum unit data packet. Finally, the relationship between the response time and the consumed resources of each request is determined by calculating the number of dynamic parameters using the relationship between the length of different data packets and the response time in the historical data. For example, by testing the response time difference of data packets of different lengths, the corresponding parameter data length is decomposed into the average length of the minimum unit parameter. Assuming that the response time of a 110K data packet is 1 second and that of a 120K data packet is 1.2 seconds, the time difference between the two is divided by the difference in data packet size to obtain the time consumption of each byte, thereby determining the length of a single minimum unit parameter.
[0085] In some embodiments, determining the single minimum unit parameter data length based on the request response time and resource consumption of the minimum unit data packet includes:
[0086] Obtaining a response time coefficient of a dynamic parameter; and determining the data length of the single minimum unit parameter based on the response time coefficient of the dynamic parameter, the request response time of the minimum unit data packet, and resource consumption.
[0087] The response time coefficient of dynamic parameters refers to the degree of influence of dynamic parameters on request response time, which is usually estimated by analyzing the change of request response time with the increase of the number of dynamic parameters. This coefficient reflects the specific influence of each additional dynamic parameter on the response time.
[0088] In some embodiments, determining the single minimum unit parameter data length based on the response time coefficient of the dynamic parameter, the request response time of the minimum unit data packet, and the resource consumption includes:
[0089] The request response time of the minimum unit data packet is multiplied by the response time coefficient to obtain a target response time; based on the target response time and the resource consumption, the single minimum unit parameter data length is determined.
[0090] The target response time refers to the expected response time obtained by multiplying the request response time of the minimum unit data packet by the response time coefficient. It is used to estimate the response time of a request containing multiple dynamic parameters in order to calculate the length of a single minimum unit parameter data.
[0091] In some embodiments, the request response time of the minimum unit data packet and the response time coefficient of the dynamic parameter can be used to calculate the response time of the request containing multiple dynamic parameters. For example, assuming that the request response time of the minimum unit data packet is 0.5 seconds, the response time coefficient is 0.1 seconds / parameter. If the request contains 3 dynamic parameters, the target response time is calculated as: target response time = 0.5 + (0.1 × 3) = 0.8 seconds.
[0092] Then, the data length occupied by each minimum unit parameter is calculated using the calculated target response time and current resource consumption. Calculation process example: Assume that the target response time is 0.8 seconds and the current resource consumption is 15MB. By allocating the resource consumption to each dynamic parameter under the target response time, the data length of a single minimum unit parameter is calculated.
[0093] In some embodiments, the step of obtaining a response time coefficient of a dynamic parameter includes:
[0094] Clustering is performed based on the size distribution of the request data packets to obtain multiple data packet groups.
[0095] The difference in the size of each data packet in each data packet grouping does not exceed a preset value. Clustering is a data analysis method that divides data into multiple groups according to certain standards to better analyze the internal characteristics of the data. The clustering here is based on the distribution of data packet sizes, and data packets of similar sizes are divided into the same group. Specific clustering algorithms may include K-means or DBSCAN, etc.
[0096] For adjacent data packets in the data packet group, the average value is calculated by the following formula (1):
[0097]
[0098] Where a is the average value of the solution, t2 and t1 represent the response time of adjacent data packets, s2 and s1 represent the packet size of adjacent data packets;
[0099] The average values corresponding to a plurality of adjacent data packets in the data packet group are averaged to obtain a response time coefficient of the dynamic parameter.
[0100] For each data packet group, adjacent data packets of similar size are selected, and the above formula is used to calculate the ratio of the response time difference to the size difference of each pair of adjacent data packets.
[0101] For example, in adjacent packets of size 60KB and 62KB, assuming the response times are 1 second and 1.1 seconds respectively, we calculate:
[0102]
[0103] After calculating the average value of each pair of adjacent data packets, all average values in the same data packet group are averaged again to obtain the dynamic parameter response time coefficient of the group. For example, in a data packet group, the average values of multiple adjacent data packets are 0.05, 0.06, and 0.04, respectively, and the dynamic parameter response time coefficient is calculated as (0.05+0.06+0.04) / 3=0.05. The final response time coefficient is used for the subsequent calculation of the single minimum unit parameter data length, which can provide a more accurate dynamic parameter response time estimation.
[0104] In this embodiment, by clustering request data packets and calculating the differences between adjacent data packets, the method can effectively extract the influencing factors of dynamic parameters on response time, provide data support for the calculation of dynamic parameter response time coefficient, thereby improving the system current limiting accuracy and the accuracy of response time prediction.
[0105] Step 104: based on the size distribution of the request data packets of different data interfaces, estimate the number of request data parameters of different interfaces.
[0106] The size distribution of request data packets of different data interfaces refers to the statistical distribution of the sizes of request data packets of each interface, which helps determine the parameter quantity range and specific sizes of data packets of different interfaces.
[0107] The number of request data parameters refers to the total number of parameters in the request data packet. It is an estimate of the number of parameters in each interface request and is used to control the complexity of requests in the current limiting strategy.
[0108] In some embodiments, statistics can be taken on the size distribution of request data packets of different interfaces, and the change pattern of the number of parameters can be analyzed to estimate the number of data packet parameters for each interface so as to establish an association between the number of parameters and the data packet size, and then estimate the number of request data parameters of different interfaces.
[0109] Step 105: Determine the size of the service parameter data packet corresponding to each request based on the number of the different interface request data parameters.
[0110] The service parameter data packet size refers to the total length of parameters related to actual service operations in the data packet.
[0111] In some embodiments, the processor may estimate the size of the service parameter data packet for each request based on the number of parameters and the minimum unit parameter data length.
[0112] Step 106: upon receiving a service request, determining a minimum unit service parameter data packet size corresponding to the service request based on the service parameter data packet size corresponding to each request.
[0113] The minimum unit service parameter data packet size refers to the minimum amount of resources required for each request. It is calculated based on the minimum unit parameter data length and the length of the service-related fields, and is used to directly determine whether the request needs to be limited.
[0114] In some embodiments, each time a request is made, the business parameter data packet size of the historical data corresponding to the request is obtained through historical data analysis, and based on this, the minimum unit business parameter data packet size corresponding to the business request is estimated.
[0115] Step 107: Determine whether to limit the flow of the service request according to a preset flow limiting strategy and the minimum unit service parameter data packet size.
[0116] The preset flow limiting strategy is a set request flow limiting condition. For example, it controls the incoming traffic based on the number of request header parameters or the size of the data packet, which can ensure the reasonable use of server resources.
[0117] The preset flow limiting strategy can include flow limiting on the minimum unit business parameter data packet size and flow limiting on the number of request headers. For example, a flow limiting strategy can be defined: when the server resource utilization rate exceeds 80%, limit the number of requests with 1 head entry. For another example, set flow limits on the request data packet length of different interfaces, and only allow requests with a length of less than 130 to enter.
[0118] Figure 2 A flow chart of a method for determining a current limiting strategy provided in an embodiment of the present application. Figure 2 As shown, process 200 may include the following operations.
[0119] Step 201, obtaining the current device load.
[0120] The current device load refers to the real-time load of the device during operation, which can reflect the resource usage of the device through parameters such as CPU and memory usage. The current device load is used to determine whether the system is close to an overload state.
[0121] In some embodiments, the system can monitor the occupancy of key resources such as CPU and memory in real time and calculate the current load value of the device, which can be obtained through integrated monitoring tools or programming interfaces (such as APIs).
[0122] Step 202: determine whether the current device load exceeds a dynamic load threshold.
[0123] The dynamic load threshold refers to the load limit value dynamically calculated based on the current and historical load data of the device. When the device load exceeds this threshold, the system will trigger the current limiting strategy.
[0124] By comparing the current device load value with the dynamic load threshold, it can be determined whether the current load reaches or exceeds the threshold. For example, if the current load value is 80% and the dynamic load threshold is 75%, it is determined that the device load has exceeded the threshold.
[0125] In some embodiments, the dynamic load threshold is determined by:
[0126] Obtain historical device load. In some embodiments, the device load data for a period of time in the past can be queried through a system monitoring tool or database to calculate the average value of the historical load. For example, the load values for the past 7 days are 70%, 65%, 75%, 60%, 80%, 78%, and 73%, respectively, and the historical load average value is 71.57.
[0127] Based on the current device load and the historical device load, the dynamic load threshold is determined by the following formula (2).
[0128]
[0129] Wherein, L is the dynamic load threshold, L0 is the initial current limiting threshold, C1 is the current device load, C2 is the average value of the historical device load, α is the weight coefficient of the historical device load, and C3 is the initial load threshold.
[0130] Step 203: If yes, set a first current limiting threshold for the number of request headers and / or set a second current limiting threshold for the length of the requested data packet.
[0131] The number of request headers refers to the number of header fields in an HTTP request. You can set a threshold to limit the amount of header information carried in a request to control the complexity of request processing.
[0132] The requested data packet length refers to the size of the data packet for a single request, indicating the amount of data transmitted.
[0133] In some embodiments, when the device load exceeds the dynamic threshold, the system sets stricter current limiting limits on the number of request headers and data packet length, for example, limiting the number of request headers to 2 and the data packet length to 100kb.
[0134] And / or means that the first current limiting threshold may be set, the second current limiting threshold may be set, or both the first current limiting threshold and the second current limiting threshold may be set.
[0135] Step 204: If not, set a third current limiting threshold for the number of request headers.
[0136] When the device load is lower than the dynamic threshold, the system can relax the limit on the number of request headers and set a third current limiting threshold (such as 5, 20, etc.) to ensure that the system can support more requests when the load is normal. Therefore, the third current limiting threshold is greater than the first current limiting threshold.
[0137] Based on the same inventive concept, an embodiment of the present application further provides a service flow limiting device based on a request header, the device comprising:
[0138] A data packet parameter analysis module, used to perform data packet parameter analysis based on historical request data and determine data analysis results; wherein the data analysis results include size distribution of request data packets;
[0139] A dynamic parameter analysis module, used to perform dynamic parameter analysis based on the data analysis results, determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption;
[0140] A data length determination module, used to determine a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption;
[0141] A data packet quantity estimation module, used for estimating the quantity of request data parameters of different interfaces based on the size distribution of the request data packets of different data interfaces;
[0142] A data packet size estimation module, used to determine the service parameter data packet size corresponding to each request based on the number of data parameters requested by the different interfaces;
[0143] A data packet size determination module, configured to determine, upon receiving a service request, a minimum unit service parameter data packet size corresponding to the service request based on the service parameter data packet size corresponding to each request;
[0144] The current limiting module is used to determine whether to limit the current of the service request according to a preset current limiting strategy and the size of the minimum unit service parameter data packet.
[0145] like Figure 3 As shown, an embodiment of the present application provides an electronic device, including a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0146] Memory 113, used for storing computer programs;
[0147] In one embodiment of the present application, the processor 111 is used to implement the request header-based service flow limiting method provided by any one of the aforementioned method embodiments when executing the program stored in the memory 113, including:
[0148] Performing data packet parameter analysis based on historical request data to determine data analysis results; wherein the data analysis results include size distribution of request data packets;
[0149] Performing dynamic parameter analysis based on the data analysis results to determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption;
[0150] Determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption;
[0151] Based on the size distribution of the request data packets of different data interfaces, estimating the number of request data parameters of different interfaces;
[0152] Determine the size of the service parameter data packet corresponding to each request based on the number of the different interface request data parameters;
[0153] Upon receiving a service request, determining a minimum unit service parameter data packet size corresponding to the service request based on a service parameter data packet size corresponding to each request;
[0154] Determine whether to limit the flow of the service request according to a preset flow limiting strategy and the minimum unit service parameter data packet size.
[0155] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the service flow limiting method based on the request header provided in any of the aforementioned method embodiments are implemented.
[0156] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0157] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A service flow limiting method based on request header, characterized in that: The method comprises: Performing data packet parameter analysis based on historical request data to determine data analysis results; wherein the data analysis results include size distribution of request data packets; Performing dynamic parameter analysis based on the data analysis results to determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption; Determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption; Based on the size distribution of the request data packets of different data interfaces, estimating the number of request data parameters of different interfaces; Determine the size of the service parameter data packet corresponding to each request based on the number of the different interface request data parameters; Upon receiving a service request, determining a minimum unit service parameter data packet size corresponding to the service request based on a service parameter data packet size corresponding to each request; Determine whether to limit the flow of the service request according to a preset flow limiting strategy and the minimum unit service parameter data packet size.
2. The method according to claim 1, characterized in that Determining a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption includes: Get the number of threads of the device; Determining a request response time of a minimum unit data packet based on the number of threads, the estimated number of dynamic parameters, and the estimated dynamic parameter resource consumption; The single minimum unit parameter data length is determined based on the request response time and resource consumption of the minimum unit data packet.
3. The method according to claim 2, characterized in that The determining of the single minimum unit parameter data length based on the request response time and resource consumption of the minimum unit data packet includes: Get the response time coefficient of dynamic parameters; The single minimum unit parameter data length is determined based on the response time coefficient of the dynamic parameter, the request response time and resource consumption of the minimum unit data packet.
4. The method according to claim 3, characterized in that The determining the single minimum unit parameter data length based on the response time coefficient of the dynamic parameter, the request response time and resource consumption of the minimum unit data packet includes: Multiplying the request response time of the minimum unit data packet by the response time coefficient to obtain a target response time; The single minimum unit parameter data length is determined based on the target response time and the resource consumption.
5. The method according to claim 3, characterized in that: The step of obtaining the response time coefficient of the dynamic parameter includes: Clustering is performed based on the size distribution of the request data packets to obtain a plurality of data packet groups; wherein the size difference of the data packets in each of the data packet groups does not exceed a preset value; For adjacent data packets in the data packet group, the average value is calculated by the following formula: Where a is the average value of the solution, t2 and t1 represent the response time of adjacent data packets, s2 and s1 represent the packet size of adjacent data packets; The average values corresponding to a plurality of adjacent data packets in the data packet group are averaged to obtain a response time coefficient of the dynamic parameter.
6. The method according to claim 1, characterized in that The preset current limiting strategy includes: Get the current device load; Determining whether the current device load exceeds a dynamic load threshold; If yes, set a first current limiting threshold for the number of request headers and / or set a second current limiting threshold for the length of the requested data packet; If not, a third current limiting threshold is set for the number of request headers; wherein the third current limiting threshold is greater than the first current limiting threshold.
7. The method according to claim 6, characterized in that The dynamic load threshold is determined by: Get historical device load; Based on the current device load and the historical device load, the dynamic load threshold is determined by the following formula; Wherein, L is the dynamic load threshold, L0 is the initial current limiting threshold, C1 is the current device load, C2 is the average value of the historical device load, α is the weight coefficient of the historical device load, and C3 is the initial load threshold.
8. A service flow limiting device based on request header, characterized in that: The device comprises: A data packet parameter analysis module, used to perform data packet parameter analysis based on historical request data and determine data analysis results; wherein the data analysis results include size distribution of request data packets; A dynamic parameter analysis module, used to perform dynamic parameter analysis based on the data analysis results, determine an estimated number of dynamic parameters and an estimated dynamic parameter resource consumption; A data length determination module, used to determine a single minimum unit parameter data length based on the estimated number of dynamic parameters and the estimated dynamic parameter resource consumption; A data packet quantity estimation module, used for estimating the quantity of request data parameters of different interfaces based on the size distribution of the request data packets of different data interfaces; A data packet size estimation module, used to determine the service parameter data packet size corresponding to each request based on the number of data parameters requested by the different interfaces; A data packet size determination module, configured to determine, upon receiving a service request, a minimum unit service parameter data packet size corresponding to the service request based on the service parameter data packet size corresponding to each request; The current limiting module is used to determine whether to limit the current of the service request according to a preset current limiting strategy and the size of the minimum unit service parameter data packet.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor is used to implement the steps of the request header-based service flow limiting method described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the request header-based service flow limiting method as described in any one of claims 1 to 7 are implemented.