Flow control method and device, electronic equipment and readable storage medium
By monitoring and controlling the traffic of high-concurrency applications, and utilizing a multiple linear regression algorithm and a token mechanism, the problem of abnormal application termination in high-concurrency environments was solved, achieving timely request processing and business continuity.
Patent Information
- Application Number
- CN202411555641.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-11-01
AI Technical Summary
In high-concurrency environments, existing technologies require application restarts after abnormal termination, leading to delays in request processing time.
By monitoring the runtime metrics of multiple applications, a multiple linear regression algorithm is used to calculate the load value. Tokens are then assigned to target applications with load values exceeding a preset value in a pre-defined table to control their traffic and ensure continued request processing under high concurrency.
It reduces request-response latency, improves business continuity, and avoids delays caused by application restarts.
Smart Images

Figure CN119629125B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of flow control, and particularly relates to a flow control method and device, electronic equipment and a readable storage medium. BACKGROUND
[0002] With the development of Internet technology, how to bear high concurrency of services has gradually become a challenge. When traffic surges, it usually causes application program abnormal termination.
[0003] The related art usually restarts the application program after the application program abnormal termination to continue processing the request.
[0004] The related art needs to restart the application program after the application program termination, which delays the processing time of the request. SUMMARY
[0005] The present application provides a flow control method, device, electronic equipment and readable storage medium to solve the problem of delaying the processing time of the current service in the prior art.
[0006] In a first aspect, the present application provides a flow control method, which comprises:
[0007] If multiple application programs are detected to run simultaneously, each of the application programs is monitored to obtain the running index value of each of the application programs;
[0008] The running index value of each of the application programs is input into a preset multiple linear regression algorithm to obtain the load value of each of the application programs;
[0009] When a target application program with a load value greater than a preset value is detected, the first address information in the first data information to be sent to the target application program is obtained, and the second data information generated by each of the target application programs is obtained; the first address information records the communication information of the target application program;
[0010] The second address information included in each of the second data information is added to a preset table, and the corresponding token number is allocated to the second address information in the preset table;
[0011] In each time period, the target token number corresponding to the first address information of the first data information is obtained from the preset table, and the flow of the target application program is controlled through the target token number; the target token number is used to reflect the maximum request data amount that can be processed by the target application program in the time period.
[0012] In a second aspect, the present application provides a flow control device, which comprises:
[0013] The monitoring module is configured to monitor each of the application programs if it is detected that the application programs are running simultaneously, and to obtain a running index value of each of the application programs.
[0014] The first obtaining module is configured to input the running index value of each of the application programs into a preset multivariate linear regression algorithm, and to obtain a load value of each of the application programs.
[0015] The second obtaining module is configured to obtain first address information in first data information to be sent to a target application program and to obtain second data information generated by each of the target application programs when it is detected that the load value of the target application program is greater than a preset value; the first address information records communication information of the target application program.
[0016] The adding module is configured to add second address information included in each of the second data information to a preset table, and to allocate a corresponding token number to the second address information in the preset table.
[0017] The flow control module is configured to obtain a target token number corresponding to the first address information of the first data information from the preset table in each time period, and to control the flow of the target application program by using the target token number; the target token number is used to reflect a maximum request data amount that can be processed by the target application program in the time period.
[0018] In a third aspect, the present application provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for task scheduling when executing the program.
[0019] In a fourth aspect, the present application provides a readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method for task scheduling.
[0020] In the embodiment of the present application, if multiple application programs are detected to run simultaneously, each application program is monitored to obtain a running index value of each application program; then the running index value of each application program is input into a preset multiple linear regression algorithm to obtain a load value of each application program; when a target application program with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application program is obtained, and second data information generated by each target application program is obtained; the first address information records communication information of the target application program; second address information included in each second data information is added to a preset table, and the second address information is allocated with a corresponding token number in the preset table; in each time period, a target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application program is controlled through the target token number; the target token number is used to reflect a maximum request data amount that can be processed by the target application program in the time period. In the embodiment of the present application, each application program is monitored and the load value of each application program is calculated, for the target application program with the load value greater than the preset value, the second address information is allocated with the corresponding token number in the preset table, and in each time period, the target token number corresponding to the first address information can be obtained from the preset table, and the traffic of the target application program is controlled through the target token number. Through the traffic control of the target application program with the load value greater than the preset value, the target application program does not need to be restarted when the traffic suddenly increases, but can continue to process requests, so that the delay of request response can be reduced and the continuity of business can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0022] Figure 1 is a deployment schematic diagram of a kernel state provided by the embodiment of the present application;
[0023] Figure 2 is a step flowchart of a traffic control method provided by the embodiment of the present application;
[0024] Figure 3 is an interaction schematic diagram of a prediction module and a traffic control module provided by the embodiment of the present application;
[0025] Figure 4 is a step flowchart of another traffic control method provided by the embodiment of the present application;
[0026] Figure 5 is a schematic diagram of flow control instruction transmission provided by an embodiment of the present invention;
[0027] Figure 6 This is a schematic diagram of the interaction between kernel state and token bucket provided by an embodiment of the present invention;
[0028] Figure 7 Schematic diagram of a flow control device provided by an embodiment of the present invention;
[0029] Figure 8 This is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0031] The rapid development of the internet industry and the dramatic increase in user numbers have put systems under immense pressure from concurrent requests. High concurrency refers to the ability of a system or application to receive a large number of concurrent requests within a single timeframe. Specifically, in a high-concurrency environment, the system must be able to process a large number of requests simultaneously without performance issues or response delays. Managing high-concurrency services has become a growing challenge for companies. When applications terminate abnormally due to a sudden surge in traffic, this often impacts ongoing requests.
[0032] Kernel state is the mode in which the operating system kernel runs. In this mode, the central processing unit (CPU) has unrestricted access to system storage and external devices. Kernel state has higher permissions and can perform some operations that require higher privilege levels, such as directly accessing hardware resources. The CPU in user state can only access restricted resources and cannot directly access hardware devices such as memory. It must trap into the kernel through system calls to access these privileged resources. By distinguishing between user state and kernel state, the operating system can achieve better security, stability, and performance. Kernel state is at the entry point for request forwarding and manages all requests from internal applications. External requests must be forwarded through kernel state before they can ultimately access the application.
[0033] See also Figure 1 , Figure 1Three requests and three applications are shown, and the kernel state needs to send the three requests to the corresponding applications to let the applications execute the corresponding requests. If the application corresponding to request 1, request 2 and request 3 is all application 1, then application 1 may be abnormally terminated due to the increase of request traffic. Related technologies usually restart application 1 to continue processing requests after application 1 is abnormally terminated. Related technologies need to restart the application after the application is terminated, which delays the processing time of the request.
[0034] In the embodiment of the application, if it is detected that multiple applications are running simultaneously, each application is monitored to obtain a running index value of each application, and then the running index value of each application is input into a preset multiple linear regression algorithm to obtain a load value of each application. When a target application with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application is obtained, and second data information generated by each target application is obtained. The first address information records the communication information of the target application. The second address information included in each second data information is added to a preset table, and the second address information is allocated a corresponding token number in the preset table. In each time period, the target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application is controlled through the target token number. The target token number is used to reflect the maximum request data amount that the target application can process in a time period. In the embodiment of the application, each application is monitored and the load value of each application is calculated. For the target application with a load value greater than a preset value, the second address information is allocated a corresponding token number in the preset table, and in each time period, the target token number corresponding to the first address information can be obtained from the preset table, and the traffic of the target application is controlled through the target token number. By controlling the traffic of the target application with a load value greater than a preset value, it is not necessary to restart the target application when the traffic suddenly increases, but the target application can continue to process requests, so that the delay of request response can be reduced and the continuity of business can be improved.
[0035] Figure 2 is a step flowchart of a traffic control method provided by the embodiment of the application, as shown in the figure, the method can include: Figure 2
[0036] Step 101: If it is detected that multiple applications are running simultaneously, each application is monitored to obtain a running index value of each application.
[0037] For example, the running index value of each application is obtained in a set time range, and the time range can be set to 1 second.
[0038] For example, the running index reflects the running state of the application program and the ability to process requests, and the running index value can include: request data volume, CPU usage, memory usage, etc. Among them, the request data volume indicates the request volume required by the application program within a certain time range, the CPU usage is used to reflect the occupation of the application program to the CPU time slice, and the memory usage indicates the ratio of the used memory of the operating system to the total memory size within a certain time range. The running index value can also include: disk average read proportion, disk average write proportion, etc. Among them, the disk average read proportion indicates the average value of the ratio of the disk read rate to the maximum disk read rate within a certain time range, and the disk average write proportion indicates the average value of the ratio of the disk write rate to the maximum disk write rate within a certain time range.
[0039] For example, taking three application programs as an example, referring to Figure 3 If it is detected that application program 1, application program 2 and application program 3 are running at the same time, application program 1, application program 2 and application program 3 are monitored respectively, and the running index values corresponding to application program 1, application program 2 and application program 3, i.e. request data volume, CPU usage, memory usage, etc. are obtained. It should be noted that the running index value here can be increased or decreased according to actual conditions.
[0040] Step 102, respectively input the running index value of each application program into the preset multiple linear regression algorithm to obtain the load value of each application program.
[0041] For example, in regression analysis, if there are two or more independent variables, it is called multiple regression. In fact, a phenomenon is often associated with multiple factors, and the optimal combination of multiple independent variables is used to predict or estimate the dependent variable, which is more effective and more in line with reality, so the practical significance of multiple linear regression is greater. Multiple linear regression algorithm is a statistical method for exploring the relationship between multiple independent variables and dependent variables. In the field of machine learning and data analysis, linear regression, ridge regression, least absolute shrinkage and selection operator (Lasso) and principal component regression are common algorithms of multiple linear regression.
[0042] For example, the load value reflects the running state of the application program, helps us understand the work burden of the application program, and refers to the sum of the number of processes currently being executed by the CPU and waiting to be executed by the CPU. If the load value is too high, it indicates that there are too many processes or threads in the application program waiting for CPU time, which may cause performance degradation or response delay.
[0043] For example, the embodiment of the present application acquires all historical running index values in a specified time range. For example, the time range can be set to 30 minutes. In this case, a set of historical running index values is acquired every 5 minutes until all historical running index values in 30 minutes are acquired. The historical running index values of each application are input into a preset multiple linear regression algorithm, and the respective corresponding weight coefficients, intercepts and error terms of each running index are calculated by the preset multiple linear regression algorithm.
[0044] For example, the embodiment of the present application can also set the respective corresponding weight coefficients, intercepts and error terms of each running index in advance through experience.
[0045] For example, after the respective corresponding weight coefficients, intercepts and error terms of each running index are calculated, the respective corresponding load values of each application are calculated according to the respective corresponding weight coefficients, intercepts and error terms of each running index, that is, the respective corresponding load values of different applications are calculated.
[0046] For example, after the respective corresponding running index values of each application are acquired by the index collection module, the respective corresponding running index values of each application are sent to the prediction module, the prediction module uses the preset multiple linear regression algorithm to calculate the respective corresponding running index values of each application, predicts the load values of the applications in a future period of time, and the load values are the values calculated by the multiple running indexes according to the weight coefficients, intercepts and error terms. Thus, the target applications with load values greater than a preset value can be controlled based on the load values.
[0047] For example, referring to Figure 3 After the respective corresponding request data amounts, CPU usage rates and memory usage rates of the application 1, the application 2 and the application 3 are acquired, the respective corresponding request data amounts, CPU usage rates and memory usage rates of the application 1, the application 2 and the application 3 are collected to the index collection module, and the index collection module uses the preset multiple linear regression algorithm to calculate the respective corresponding request data amounts, CPU usage rates and memory usage rates of the application 1, the application 2 and the application 3, and predicts the load values of the applications in a future period of time.
[0048] In step 103, when the target applications with load values greater than a preset value are detected, first address information in first data information to be sent to the target applications is acquired, and second data information generated by each target application is acquired. The first address information records the communication information of the target applications.
[0049] For example, the first address information is the address information of the target applications carried by the requests.
[0050] The first data information and the second data information can be data information obtained by monitoring the application program.
[0051] The first data information can include an Internet Protocol (IP) parameter and a port parameter. The IP parameter represents an IP parameter of the target application program, and the port parameter represents an access port parameter of the target application program. Based on the IP parameter and the port parameter, a target token number corresponding to the IP parameter and the port parameter is obtained from a preset table, and the traffic of the target application program is controlled by using the target token number.
[0052] The second data information can include an IP parameter, a port parameter, a rate parameter, a proportion parameter of a control rate, a token parameter, and a capacity parameter. The IP parameter represents an IP parameter of the target application program, the port parameter represents an access port parameter of the target application program, the rate parameter represents a rate of token production, i.e., a number of tokens generated per second, the capacity parameter represents a maximum capacity of a token bucket, the token parameter represents a number of tokens that can be transmitted in the token bucket, and the proportion parameter of the control rate represents a percentage of a control rate of token production.
[0053] In step 104, second address information included in each of the second data information is added to a preset table, and the preset table is allocated a corresponding token number for the second address information.
[0054] The second address information records communication information of the target application program. The second address information can include an IP parameter and a port parameter.
[0055] The preset table records corresponding information of second address information included in each of the second data information and a token number allocated for each of the second address information. The second address information included in each of the second data information is added to the preset table, and the preset table is allocated a corresponding token number for the second address information. Based on the first address information, a target token number corresponding to the first address information is obtained from the preset table, and the traffic of the target application program is controlled by using the target token number. When the traffic suddenly increases, the target application program does not need to be restarted, but can continue to process requests. Therefore, the delay of request response can be reduced, and the continuity of business can be improved.
[0056] In step 105, in each time period, the target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application program is controlled by using the target token number; the target token number is used to reflect the maximum request data amount that can be processed by the target application program in the time period.
[0057] For example, the preset table can be stored in a token bucket. The time period can be preset. For example, the time period can be in seconds. That is, the preset table in the token bucket is scanned every 1 second to obtain the target token number corresponding to the first address information of the first data information. Referring to Figure 3 For example, the first address information of the target application program is 172.26.5.2 and 1111. The preset table in the token bucket is scanned every second. If the target token number corresponding to 172.26.5.2 and 1111 is 80 at this time, the maximum request data amount that can be processed by the target application program in this second is 80. The request processing order is determined according to the time order of the request, and the request is processed based on the request processing order.
[0058] In the embodiment of the application, if it is detected that multiple application programs are running simultaneously, each application program is monitored to obtain the running index value of each application program; then the running index value of each application program is input into the preset multiple linear regression algorithm to obtain the load value of each application program; when a target application program with a load value greater than a preset value is detected, the first address information in the first data information to be sent to the target application program is obtained, and the second data information generated by each target application program is obtained; the first address information records the communication information of the target application program; the second address information included in each second data information is added to the preset table, and the second address information is allocated with a corresponding token number in the preset table; in each time period, the target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application program is controlled by using the target token number; the target token number is used to reflect the maximum request data amount that can be processed by the target application program in the time period. In the embodiment of the application, each application program is monitored and the load value of each application program is calculated. For the target application program with a load value greater than a preset value, the second address information is allocated with a corresponding token number in the preset table, and in each time period, the target token number corresponding to the first address information can be obtained from the preset table, and the traffic of the target application program is controlled by using the target token number. By controlling the traffic of the target application program with a load value greater than a preset value, it is not necessary to restart the target application program when the traffic suddenly increases, but the target application program can continue to process the request, so that the delay of the request response can be reduced and the continuity of the service can be improved.
[0059] Figure 4is a step flow chart of another flow control method provided by the embodiment of the application, as shown in Figure 4 The method can include the following steps.
[0060] Step 201: If it is detected that multiple application programs are running simultaneously, each of the application programs is monitored to obtain a running index value of each of the application programs.
[0061] This step can refer to the above step 101 for details, and will not be repeated here.
[0062] Optionally, the running index value includes a request data volume, a CPU usage rate and a memory usage rate, and step 201 can specifically include the following steps.
[0063] Sub-step 2011: If it is detected that multiple application programs are running simultaneously, each of the application programs is monitored by an open source component to obtain a request data volume, a CPU usage rate and a memory usage rate corresponding to each of the application programs.
[0064] For example, the open source component can be a node_exporter component, a pinpoint component or an opentelemetry component.
[0065] For example, the running index value can also include a disk average read proportion, a disk average write proportion and the like. The running index value can be increased or reduced according to actual conditions.
[0066] For example, referring to Figure 3 The open source component is deployed at a place where the application program 1, the application program 2 and the application program 3 run, the application program 1, the application program 2 and the application program 3 are monitored by the open source component to obtain a request data volume, a CPU usage rate and a memory usage rate corresponding to each of the application program 1, the application program 2 and the application program 3. After obtaining the request data volume, the CPU usage rate and the memory usage rate corresponding to each of the application programs, the request data volume, the CPU usage rate and the memory usage rate are collected to an index collection module. The index collection module mainly collects the running index value of the application program when running in the past period of time to provide basic data for a prediction module.
[0067] Step 202: The running index value of each of the application programs is input into a preset multiple linear regression algorithm to obtain a load value of each of the application programs.
[0068] This step can refer to the above step 102 for details, and will not be repeated here.
[0069] Optionally, a formula of the preset multiple linear regression algorithm is as follows.
[0070] Y = β0 + β1X1 + β2X2 + β3X3 + ε
[0071] Wherein, Y is a load value, X1 is the request data volume, X2 is the CPU usage, X3 is the memory usage, β0 is an intercept, β1, β2, β3 are regression coefficients, and ε is an error term.
[0072] For example, referring to Figure 3 The preset module is configured to predict the load value of the application system in a future period of time. The calculation interval of the prediction module can be controlled by a timing task, for example, input data, i.e., the request data volume, the CPU usage, and the memory usage, are obtained from the index collection module every minute, and the input data is input to a preset multiple linear regression algorithm to calculate the load value in the next 5 minutes, 10 minutes, or 20 minutes.
[0073] In step 203, when the target application program with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application program is obtained, and second data information generated by each target application program is obtained. The first address information records the communication information of the target application program.
[0074] This step can refer to the above-described step 103, and details are not described herein.
[0075] Optionally, the first address information includes an IP parameter and a port parameter of the target application program, and step 203 can specifically include:
[0076] In sub-step 2031, after receiving multiple requests, the IP parameter and the port parameter to be sent to the target application program are parsed according to the receiving order of the requests.
[0077] For example, after receiving multiple requests, the IP parameter and the port parameter to be sent to the target application program are parsed according to the receiving order of the requests, so that the target token number corresponding to the IP parameter and the port parameter of the target application program is obtained from a preset table, and the traffic of the target application program is controlled through the target token number, without restarting the target application program when the traffic suddenly increases, but the requests can be continuously processed, so that the delay of the request response can be reduced, and the continuity of the business can be improved.
[0078] Optionally, before step 203, the method further includes:
[0079] In step A1, the content of the second data information of each target application program is encapsulated by a user state according to a predefined data structure, and is carried in a flow control instruction.
[0080] Step A2, sending the flow control instruction to the kernel state through the user state, so that the kernel state enters the step of obtaining the second data information generated by each target application program.
[0081] In an example, the flow control instruction is used for communication between the user state and the kernel state.
[0082] In an example, the predefined data structure is as follows:
[0083] struct flow_ctrl_cmd{
[0084] unsigned int action;
[0085] char dest_ip
[16] ;
[0086] unsigned short dest_port;
[0087] unsigned int rate;
[0088] unsigned int capacity;
[0089] unsigned int percent;
[0090] };
[0091] Wherein, the action represents the action of the instruction, including: increase, delete, modify, query, dest_ip represents the IP of the target application program, dest_port represents the access port of the target application program, rate represents the token production rate, i.e. the number of tokens generated per second, capacity represents the maximum capacity of the token bucket, and percent represents the percentage of controlling the token production rate.
[0092] For steps A1-A2, refer to Figure 5 , the user state encapsulates the content of the second data information of each target application program according to the above predefined data structure, and carries it in the flow control instruction. The flow control instruction is sent to the kernel state through the user state, so that the kernel state enters the step of obtaining the second data information generated by each target application program, and controls the traffic of the target application program.
[0093] In an example, in the kernel state, the storage of the flow control instruction can be represented by a table structure, see Figure 5The fields thereof include IP, port, rate, proportion of control rate, token, and capacity. The IP represents the IP of the target application program, the port represents the access port of the target application program, the rate represents the rate of token production, i.e., the number of tokens generated per second, the capacity represents the maximum capacity of the token bucket, the token represents the number of transmittable tokens in the current token bucket, and the proportion of control rate represents the percentage of controlling the token production rate.
[0094] Optionally, step 203 specifically can further include:
[0095] Sub-step 2032: According to the predefined data structure, the flow control instruction is parsed through the hook function in the kernel state to obtain the second data information of each target application program.
[0096] For example, the hook function is part of a request processing mechanism, and through setting a "hook", an application program can filter all requests at a system level and access requests that cannot be accessed under normal circumstances.
[0097] For example, the application registers a hook function at a prerouting point in the kernel state, and requests from a network pass through the hook function. After receiving the flow control instruction from the user state in the hook function, the flow control instruction is parsed to obtain the second data information of each target application program.
[0098] Step 204: Second address information included in each second data information is added to a preset table, and the actual token production number of the target application program is obtained by calculating according to the rate parameter and the proportion of control rate parameter; the second data information further includes a rate parameter, a proportion of control rate parameter, a capacity parameter, and a token parameter; each second address information in the preset table is associated with the rate parameter, the proportion of control rate parameter, and the capacity parameter; and the capacity parameter is used to reflect the available request data amount of the target application program in a current time period.
[0099] For example, each second address information is added to a preset table, and the actual token production number of the target application program is obtained by calculating according to the rate parameter and the proportion of control rate parameter, so that the traffic of the target application program can be controlled based on the actual token production number, without restarting the target application program when the traffic suddenly increases, but the request can be continuously processed, thereby reducing the delay of request response and improving the continuity of business.
[0100] For example, referring to Figure 5Each second address information in the table in the token bucket is associated with a rate, a proportion of the control rate and a capacity. For example, taking the IP of the second address information as 172.26.5.2 and the port as 1111, the IP of 172.26.5.2 and the port of 1111 are associated with a rate of 50, a proportion of the control rate of 90%, and a capacity of 200. According to the rate of 50 and the proportion of the control rate of 90%, the actual production token number of the target application program with the IP of 172.26.5.2 and the port of 1111 can be calculated.
[0101] Optionally, step 204 can specifically include:
[0102] Sub-step 2041, multiplying the rate parameter and the proportion of the control rate parameter to determine the product result as the actual production token number of the target application program.
[0103] For example, the calculation formula of the actual production token number of the target application program is as follows:
[0104] T = rate × percent
[0105] Wherein, T is the actual production token number of the target application program, rate is the rate of token production, and percent is the percentage of the control token production rate.
[0106] For example, the actual production token number of the target application program = rate parameter × proportion of the control rate parameter. By controlling the rate of token production through the proportion of the control rate parameter, the delay of the request response can be reduced, and the continuity of the business can be improved.
[0107] Step 205, when the actual production token number is greater than or equal to the capacity parameter, the corresponding token number allocated for the second address information is determined as the capacity parameter, and the token parameter is modified as the token number.
[0108] For example, when the actual production token number of the target application program is greater than or equal to the available token number of the target application program in the current time period, the corresponding token number allocated for the second address information is determined as the available token number of the target application program in the current time period, i.e. the capacity parameter, and the token parameter is modified as the available token number.
[0109] Step 206, when the actual production token number is less than the capacity parameter, the corresponding token number allocated for the second address information is determined as the actual production token number, and the token parameter is modified as the token number.
[0110] For example, when the actual production token number of the target application is less than the available token number of the target application in the current time period, the corresponding token number allocated to the second address information is determined as the actual production token number of the target application, and the token parameter is modified as the actual production token number of the target application.
[0111] In step 207, the target token number corresponding to the first address information of the first data information is obtained from the preset table in each time period, and the traffic of the target application is controlled by the target token number; the target token number is used to reflect the maximum request data amount that can be processed by the target application in the time period.
[0112] For example, taking 1 second as the time period, the target token number corresponding to the first address information is obtained from the preset table every 1 second, and the traffic of the target application is controlled by the target token number, without the need to restart the target application when the traffic suddenly increases, but the target application can continue to process requests, so that the delay of request response can be reduced and the continuity of business can be improved.
[0113] For example, taking the IP parameter and the port parameter as the first address information, referring to Figure 6 After obtaining the IP and the port of the requested target application, the target token number corresponding to the IP and the port of the target application, i.e., the token parameter, is obtained from the table in the token bucket, and the traffic of the target application is controlled by the target token number, that is, the maximum request data amount that can be processed by the target application in the time period is equal to the target token number.
[0114] Optionally, step 207 can specifically include:
[0115] In sub-step 2071, if the target token number is greater than the preset threshold, the request data amount transmitted to the target application in each time period is determined as the target token number, and the traffic of the target application is controlled by the target token number.
[0116] In sub-step 2072, if the target token number is less than or equal to the preset threshold, the request transmitted to the target application is stopped.
[0117] For sub-step 2071-sub-step 2072, for example, referring to Figure 6After the target token number is obtained, if the target token number is greater than the preset threshold, it indicates that the token acquisition is successful, the request data amount transmitted to the target application is determined as the target token number, and the traffic of the target application is controlled through the target token number. After the target token number is obtained, if the target token number is less than or equal to the preset threshold, it indicates that the token acquisition fails, the request is discarded, and the request transmission to the target application is stopped.
[0118] In the embodiment of the application, if it is detected that multiple application programs run simultaneously, each application program is monitored respectively to obtain a running index value of each application program, and then the running index value of each application program is input into a preset multiple linear regression algorithm to obtain a load value of each application program. When a target application program with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application program is obtained, and second data information generated by each target application program is obtained. Second address information included in each second data information is added to a preset table, and the second address information is allocated a corresponding token number in the preset table. In each time period, a target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application program is controlled through the target token number. In the embodiment of the application, each application program is monitored and the load value of each application program is calculated. For a target application program with a load value greater than a preset value, the second address information is allocated a corresponding token number in the preset table, and in each time period, the target token number corresponding to the first address information can be obtained from the preset table, and the traffic of the target application program is controlled through the target token number. By controlling the traffic of the target application program with a load value greater than a preset value, it is not necessary to restart the target application program when the traffic suddenly increases, but the request can be continuously processed, so that the delay of the request response can be reduced and the continuity of the service can be improved.
[0119] Figure 3 is a schematic diagram of interaction between a prediction module and a traffic control module provided in the embodiment of the application, referring to Figure 3 , Figure 3The system comprises an indicator prediction module and a flow control module, wherein the indicator prediction module comprises an indicator collection module and a prediction module, and the flow control module comprises a user state and a kernel state. If it is detected that application 1, application 2, and application 3 are running simultaneously, application 1, application 2, and application 3 are monitored respectively through open source components to obtain the corresponding running indicator values of application 1, application 2, and application 3, namely, the request data volume, CPU usage, memory usage, etc., and the request data volume, CPU usage, and memory usage corresponding to each application are collected into the indicator collection module. The indicator collection module sends the request data volume, CPU usage, and memory usage corresponding to each application to the prediction module. After receiving the request data volume, CPU usage, and memory usage corresponding to the application, the prediction module uses a preset multivariate linear regression algorithm to calculate the request data volume, CPU usage, and memory usage corresponding to the application, and predicts the load value of the application within a certain period of time in the future. When a target application with a load value greater than a preset value is detected, a flow control instruction is sent to the user state. After the user state receives the flow control instruction, the flow control instruction is sent to the kernel state, so that the kernel state can perform flow control on the target application. It should be noted that the application is monitored using open source components here, and the operational indicators obtained include not only the amount of requested data, CPU usage, and memory usage, but also the average disk read percentage and average disk write percentage. These operational indicators can be increased or decreased based on actual conditions and are not specifically limited in this embodiment.
[0120] Figure 7 is a structural diagram of a flow control device provided by an embodiment of the present invention. The device 300 may include:
[0121] The monitoring module 301 is configured to monitor each application separately if it is detected that multiple applications are running simultaneously, and obtain an operating indicator value of each application;
[0122] A first obtaining module 302 is configured to input the operating index value of each application into a preset multiple linear regression algorithm to obtain a load value of each application;
[0123] A second obtaining module 303 is configured to, upon detecting a target application having a load value greater than a preset value, obtain first address information in first data information to be sent to the target application, and obtain second data information generated by each target application; the first address information records communication information of the target application;
[0124] The adding module 304 is configured to add the second address information included in each of the second data information to a preset table, and assign a corresponding token number to the second address information in the preset table.
[0125] The flow control module 305 is configured to obtain a target token number corresponding to the first address information of the first data information from the preset table in each time period, and control the flow of the target application program by using the target token number; the target token number is used to reflect the maximum request data amount that can be processed by the target application program in a time period.
[0126] Optionally, the second data information further comprises a rate parameter, a control rate proportion parameter, a capacity parameter and a token parameter; each of the second address information in the preset table is associated with the rate parameter, the control rate proportion parameter and the capacity parameter; the capacity parameter is used to reflect the available request data amount of the target application program in a current time period.
[0127] The adding module comprises:
[0128] The calculating sub-module is configured to calculate the actual production token number of the target application program according to the rate parameter and the control rate proportion parameter.
[0129] The first comparing sub-module is configured to determine the corresponding token number assigned to the second address information in the preset table according to a comparison result of the actual production token number and the capacity parameter, and modify the token parameter to the token number.
[0130] Optionally, the comparing sub-module comprises:
[0131] The first comparing unit is configured to determine the corresponding token number assigned to the second address information as the capacity parameter when the actual production token number is greater than or equal to the capacity parameter.
[0132] The second comparing unit is configured to determine the corresponding token number assigned to the second address information as the actual production token number when the actual production token number is less than the capacity parameter.
[0133] Optionally, the calculating sub-module comprises:
[0134] The product calculating unit is configured to perform product calculation on the rate parameter and the control rate proportion parameter, and determine the product result as the actual production token number of the target application program.
[0135] Optionally, the flow control module comprises:
[0136] a second comparison submodule, configured to determine the amount of request data transmitted to the target application program as the target token number in each time period if the target token number is greater than a preset threshold, and control the traffic of the target application program by the target token number;
[0137] a third comparison submodule, configured to stop transmitting requests to the target application program if the target token number is less than or equal to the preset threshold.
[0138] Optionally, the first address information includes an IP parameter and a port parameter of the target application program; and the second obtaining module includes:
[0139] a first analysis submodule, configured to analyze the IP parameter and the port parameter to be sent to the target application program according to the receiving order of the requests after receiving a plurality of requests.
[0140] Optionally, the apparatus further includes:
[0141] a packaging module, configured to package the content of the second data information of each target application program by a user state according to a predefined data structure, and carry the flow control instruction;
[0142] a sending module, configured to send the flow control instruction to a kernel state by the user state, so that the kernel state enters the step of obtaining the second data information generated by each target application program.
[0143] Optionally, the second obtaining module includes:
[0144] a second analysis submodule, configured to analyze the flow control instruction according to the predefined data structure by a hook function in the kernel state, and obtain the second data information of each target application program.
[0145] Optionally, the running index value includes an amount of request data, a CPU usage rate and a memory usage rate; and the monitoring module includes:
[0146] a monitoring submodule, configured to monitor each application program by an open source component if a plurality of application programs are detected to run simultaneously, and obtain the amount of request data, the CPU usage rate and the memory usage rate corresponding to each application program.
[0147] Optionally, a formula of the preset multiple linear regression algorithm is as follows:
[0148] Y = β0 + β1X1 + β2X2 + β3X3 + ε
[0149] Wherein, Y is a load value, X1 is the request data volume, X2 is the CPU usage rate, X3 is the memory usage rate, β0 is an intercept, β1, β2, β3 are regression coefficients, and ε is an error term.
[0150] In the embodiment of the present application, if it is detected that multiple application programs are running simultaneously, each application program is monitored to obtain a running index value of each application program; then the running index value of each application program is input into a preset multiple linear regression algorithm to obtain a load value of each application program; when a target application program with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application program is obtained, and second data information generated by each target application program is obtained; second address information included in each second data information is added to a preset table, and the second address information is allocated a corresponding token number in the preset table; in each time period, a target token number corresponding to the first address information of the first data information is obtained from the preset table, and the traffic of the target application program is controlled through the target token number. The embodiment of the present application monitors each application program and calculates the load value of each application program, allocates a corresponding token number to the second address information in the preset table for the target application program with a load value greater than a preset value, and in each time period, a target token number corresponding to the first address information can be obtained from the preset table, and the traffic of the target application program is controlled through the target token number. By controlling the traffic of the target application program with a load value greater than a preset value, it is not necessary to restart the target application program when the traffic suddenly increases, but the request can be continuously processed, so that the delay of the request response can be reduced and the continuity of the service can be improved.
[0151] The present application further provides an electronic device, referring to Figure 8 , comprising a processor 801, a memory 802, and a computer program 8021 stored in the memory and executable on the processor, wherein the processor implements the traffic control method of the foregoing embodiments when executing the program.
[0152] The present application further provides a readable storage medium, when instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the traffic control method of the foregoing embodiments.
[0153] For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the related parts are described in the part of the method embodiment.
[0154] It should be noted that the various information and data obtained in the embodiments of the present application are obtained with the authorization of the information / data holder.
[0155] The algorithms and displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems can be used with programs in accordance with the teachings herein, or it can prove convenient to construct more specialized apparatus to perform the required method steps. The required structure for a variety of these systems will be apparent from the description above. In addition, the present application is not intended to be limited to any particular programming language. It will be appreciated that there are many programming languages that can be used to implement the teachings herein, and any specific language can be chosen for use in this application.
[0156] In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the application can be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been described in detail in order to not obscure the understanding of this description.
[0157] Similarly, it is to be understood that the mechanical details of the application sometimes are presented in terms of certain spatially-related or geometrical configurations and / or descriptions. It will be appreciated by those skilled in the art that the application can be practiced without such specifically-named spatial / geometrical configurations and / or descriptions. Furthermore, it is to be understood that the use of certain specific language or terminology in the specification is merely to further aid a state of the art and is not intended to limit the scope of the application.
[0158] Those skilled in the art will appreciate that the modules in the apparatuses in the embodiments can be adapted and placed in one or more apparatuses other than the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and further can be divided into more sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination of all the features disclosed in the specification (including the accompanying claims, abstract and drawings), and all processes or units of any methods or apparatuses disclosed so far can be adopted. Unless explicitly stated otherwise, each feature disclosed in the specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature providing the same, equivalent or similar function.
[0159] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the sorting device according to the present invention. The present invention may also be implemented as an apparatus or device program for performing a portion or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0160] It should be noted that the above embodiments illustrate rather than limit the invention, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between brackets should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising several different elements and by means of appropriately programmed computers. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.
[0161] The user information (including but not limited to the user's device information, user personal information, etc.) and related data involved in the present invention are all information authorized by the user or authorized by all parties.
[0162] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0163] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
[0164] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be based on the scope of protection of the claims.
Claims
1. A flow control method, characterized by, The method comprises: If multiple applications are detected to run simultaneously, each of the applications is monitored to obtain a running index value of each of the applications; The running index value of each of the applications is input into a preset multiple linear regression algorithm to obtain a load value of each of the applications; When a target application with a load value greater than a preset value is detected, first address information in first data information to be sent to the target application is obtained, and second data information generated by each of the target applications is obtained; the first address information records communication information of the target application; Second address information included in each of the second data information is added to a preset table, and a corresponding token number is allocated to the second address information in the preset table; In each time period, a target token number corresponding to the first address information of the first data information is obtained from the preset table, and the target token number is used to control the traffic of the target application; the target token number is used to reflect a maximum request data amount that can be processed by the target application in a time period.
2. The method of claim 1, wherein, The second data information further comprises a rate parameter, a proportion parameter for controlling the rate, a capacity parameter, and a token parameter; each of the second address information in the preset table is associated with the rate parameter, the proportion parameter for controlling the rate, and the capacity parameter; The capacity parameter is used to reflect an available request data amount of the target application in a current time period; The allocation of the corresponding token number to the second address information in the preset table comprises: The actual production token number of the target application is obtained by calculation according to the rate parameter and the proportion parameter for controlling the rate; According to a comparison result of the actual production token number and the capacity parameter, the corresponding token number allocated to the second address information in the preset table is determined, and the token parameter is modified to the token number.
3. The method of claim 2, wherein, According to a comparison result of the actual production token number and the capacity parameter, the corresponding token number allocated to the second address information in the preset table is determined, and the token parameter is modified to the token number. When the actual production token number is greater than or equal to the capacity parameter, the corresponding token number allocated to the second address information is determined as the capacity parameter; When the actual production token number is less than the capacity parameter, the corresponding token number allocated to the second address information is determined as the actual production token number.
4. The method of claim 2, wherein, The actual production token number of the target application is obtained by calculation according to the rate parameter and the proportion parameter for controlling the rate; The actual production token number of the target application is obtained by multiplication calculation of the rate parameter and the proportion parameter for controlling the rate, and the multiplication result is determined as the actual production token number.
5. The method of claim 1, wherein, The traffic of the target application is controlled by the target token number, comprising: If the target token number is greater than a preset threshold, the request data amount transmitted to the target application is determined as the target token number in each time period, and the traffic of the target application is controlled by the target token number; If the target token number is less than or equal to the preset threshold, the transmission of the request to the target application is stopped.
6. The method of claim 1, wherein, The first address information includes an IP parameter and a port parameter of the target application. The first address information in the first data information to be sent to the target application is obtained. After receiving a plurality of requests, the IP parameter and the port parameter to be sent to the target application are parsed according to the receiving order of the requests.
7. The method of claim 1, wherein, Before obtaining the second data information generated by each target application, the method further comprises: The content of the second data information of each target application is encapsulated by a user state according to a predefined data structure, and is carried in a flow control instruction. The flow control instruction is sent to a kernel state by the user state, so that the kernel state enters the step of obtaining the second data information generated by each target application.
8. The method of claim 7, wherein, The second data information of each target application is obtained by a hook function in the kernel state according to the predefined data structure. The running index value includes: request data volume, CPU usage and memory usage.
9. The method of claim 1, wherein, If a plurality of applications are detected to run simultaneously, each application is monitored to obtain the running index value of each application, comprising: If a plurality of applications are detected to run simultaneously, each application is monitored by an open source component to obtain the corresponding request data volume, CPU usage and memory usage of each application. The formula of the preset multiple linear regression algorithm is:
10. The method of claim 9, wherein, Y = β0 + β1X1 + β2X2 + β3X3 + ε Wherein, Y is the load value, X1 is the request data volume, X2 is the CPU usage, X3 is the memory usage, β0 is the intercept, β1, β2, β3 are the regression coefficients, and ε is the error term. The device comprises:
11. An apparatus for task scheduling, the apparatus comprising: A monitoring module is configured to monitor each application if a plurality of applications are detected to run simultaneously, and obtain the running index value of each application. A first obtaining module is configured to input the running index value of each application into a preset multiple linear regression algorithm to obtain the load value of each application. A second obtaining module is configured to obtain the first address information in the first data information to be sent to the target application when a target application with a load value greater than a preset value is detected, and obtain the second data information generated by each target application; the first address information records the communication information of the target application. An adding module is configured to add the second address information included in each second data information to a preset table, and allocate a corresponding token number to the second address information in the preset table. The flow control module is configured to obtain a target token number corresponding to the first address information of the first data information from the preset table in each time period, and control the flow of the target application program by the target token number; the target token number is used to reflect the maximum request data volume that can be processed by the target application program in the time period.
12. An electronic device, comprising: The computer program comprises: A processor, a memory, and a computer program stored on the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1-10 when executing the program.
13. A readable storage medium, characterized by, The instructions in the storage medium, when executed by the processor of the electronic device, enable the electronic device to perform the method according to any one of claims 1-10.
Citation Information
Patent Citations
Business request processing method, apparatus and device
CN111078391A
Flow control method and device, equipment, storage medium and program product
CN118827563A