Disclosure of Invention
The embodiment of the disclosure at least provides a flow control method, a flow control device, computer equipment and a storage medium.
In a first aspect, an embodiment of the present disclosure provides a flow control method, including:
responding to a network condition to meet a preset condition, and determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests;
determining a limited bandwidth based on a required bandwidth corresponding to the second request and a current transmission bandwidth, wherein the limited bandwidth is a maximum bandwidth for transmitting the first request;
and carrying out speed limit processing on the first request according to the limited bandwidth.
In a possible embodiment, the network condition satisfying the preset condition includes at least one of:
the network type is a preset network type; the network delay exceeds the preset time length; the network transmission speed is less than the preset transmission speed.
In a possible embodiment, the determining that the received plurality of requests includes a first request requiring speed limit processing and a second request not requiring speed limit processing includes:
determining a first request of which the corresponding speed limit priority meets the speed limit condition and the transmission direction is the target speed limit direction in the received multiple requests; and determining a second request that the corresponding speed limit priority does not meet the speed limit condition or the transmission direction is not the target speed limit direction.
In a possible embodiment, the determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
and determining the limited bandwidth based on the required bandwidth corresponding to the second request with the transmission direction being the target speed limiting direction and the current transmission bandwidth.
In a possible embodiment, the determining that the received plurality of requests includes a first request requiring speed limit processing and a second request not requiring speed limit processing includes:
determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests based on a preset request list, wherein the requests in the request list are requests which do not need speed limiting processing.
In a possible embodiment, the determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
calculating a bandwidth difference between the current transmission bandwidth and a required bandwidth corresponding to the second request;
when the bandwidth difference is larger than a preset bandwidth, determining the bandwidth difference as the limited bandwidth; and when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth.
In a possible embodiment, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
determining the total transmission speed of a first request needing speed limiting processing;
and under the condition that the total transmission speed is greater than a preset speed threshold, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth.
In a possible implementation manner, the rate-limiting the first request according to the limited bandwidth includes:
and under the condition that the bandwidth is not limited, sequentially processing the first requests through the sockets corresponding to the first requests according to the sequence of receiving the first requests.
In a possible embodiment, the method further comprises:
determining first network delay information before speed limiting processing is carried out on the first request;
after the first preset duration after the speed limiting processing is carried out on the first request, determining the current second network delay information;
and when it is determined that the delay variation condition meets a preset condition based on the first delay information and the second delay information, increasing the required bandwidth corresponding to the second request, re-determining the limited bandwidth, and processing the first request according to the re-determined limited bandwidth.
In a possible embodiment, the method further comprises:
and canceling the speed limiting processing of the first request when the time delay change condition is determined to not meet the preset condition based on the first time delay information and the second time delay information.
In a possible embodiment, the method further comprises:
and stopping the speed limiting processing of the first request after a second preset time after the speed limiting processing of the first request is performed.
In a second aspect, an embodiment of the present disclosure further provides a flow control device, including:
the first determining module is used for responding that the network condition meets the preset condition, and determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in the received multiple requests;
a second determining module, configured to determine a limited bandwidth based on a required bandwidth corresponding to the second request and a current transmission bandwidth, where the limited bandwidth is a maximum bandwidth for transmitting the first request;
and the speed limiting module is used for carrying out speed limiting processing on the first request according to the limited bandwidth.
In a possible embodiment, the network condition satisfying the preset condition includes at least one of:
the network type is a preset network type; the network delay exceeds the preset time length; the network transmission speed is less than the preset transmission speed.
In one possible embodiment, the first determining module, when determining that the received plurality of requests includes a first request for speed limit processing and a second request for speed limit processing, is configured to:
determining a first request of which the corresponding speed limit priority meets the speed limit condition and the transmission direction is the target speed limit direction in the received multiple requests; and determining a second request that the corresponding speed limit priority does not meet the speed limit condition or the transmission direction is not the target speed limit direction.
In a possible implementation manner, the second determining module, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
and determining the limited bandwidth based on the required bandwidth corresponding to the second request with the transmission direction being the target speed limiting direction and the current transmission bandwidth.
In one possible embodiment, the first determining module, when determining that the received plurality of requests includes a first request for speed limit processing and a second request for speed limit processing, is configured to:
determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests based on a preset request list, wherein the requests in the request list are requests which do not need speed limiting processing.
In a possible implementation manner, the second determining module, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
calculating a bandwidth difference between the current transmission bandwidth and a required bandwidth corresponding to the second request;
when the bandwidth difference is larger than a preset bandwidth, determining the bandwidth difference as the limited bandwidth; and when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth.
In a possible implementation manner, the second determining module, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
determining the total transmission speed of a first request needing speed limiting processing;
and under the condition that the total transmission speed is smaller than a preset speed threshold, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth.
In a possible implementation manner, when performing rate limiting processing on the first request according to the limited bandwidth, the rate limiting module is configured to:
and under the condition that the bandwidth is not limited, sequentially processing the first requests through the sockets corresponding to the first requests according to the sequence of receiving the first requests.
In a possible implementation manner, the speed limit module is further configured to:
determining first network delay information before speed limiting processing is carried out on the first request;
after the first preset duration after the speed limiting processing is carried out on the first request, determining the current second network delay information;
and when it is determined that the delay variation condition meets a preset condition based on the first delay information and the second delay information, increasing the required bandwidth corresponding to the second request, re-determining the limited bandwidth, and processing the first request according to the re-determined limited bandwidth.
In a possible implementation manner, the speed limit module is further configured to:
and canceling the speed limiting processing of the first request when the time delay change condition is determined to not meet the preset condition based on the first time delay information and the second time delay information.
In a possible implementation manner, the speed limit module is further configured to:
and stopping the speed limiting processing of the first request after a second preset time after the speed limiting processing of the first request is performed.
In a third aspect, an embodiment of the present disclosure further provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory communicating via the bus when the computer device is running, the machine-readable instructions when executed by the processor performing the steps of the first aspect described above, or any possible implementation of the first aspect.
In a fourth aspect, this disclosed embodiment also provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to perform the steps in the first aspect or any one of the possible implementation manners of the first aspect.
In the flow control method provided by the disclosure, under the condition that the network condition is detected to meet the preset condition, a first request needing speed limit processing and a second request needing no speed limit processing can be determined, and the second request needing no speed limit processing can be directly responded or processed; for the first request, the bandwidth limit can be determined based on the required bandwidth corresponding to the second request and the current transmission bandwidth, and the speed limit processing is performed on the first request based on the bandwidth limit, so that the first request can be guaranteed to be processed while the second request can be timely processed, and the second request cannot be influenced by the first request.
In order to make the aforementioned objects, features and advantages of the present disclosure more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present disclosure more clear, the technical solutions of the embodiments of the present disclosure will be described clearly and completely with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are only a part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure, generally described and illustrated in the figures herein, can be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present disclosure, presented in the figures, is not intended to limit the scope of the claimed disclosure, but is merely representative of selected embodiments of the disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments of the disclosure without making creative efforts, shall fall within the protection scope of the disclosure.
Research shows that important request data are generally directly released and unimportant request data are intercepted when flow control is performed in the related art, and if the unimportant request data are intercepted for a long time, the corresponding threads can be closed by mistake due to the fact that the threads cannot receive the data, and normal processing of the data is further influenced.
Or when the flow control is carried out, the thread corresponding to the unimportant request is cached in the thread pool for carrying out the delay processing, but in this case, when the delay expires, the request of the delay processing must be processed, and at this time, the problem of long network delay caused by too many requests still can be caused.
Or, when flow control is performed, the application program can accurately calculate the bandwidth required by the read function and the write function of each socket, but because there may be a plurality of requests corresponding to each socket and the current concurrent request cannot be estimated, the total bandwidth required currently cannot be estimated, and thus unified scheduling of a plurality of sockets cannot be realized.
Based on the above research, the present disclosure provides a flow control method, apparatus, computer device, and storage medium, which may determine a first request requiring speed limit processing and a second request not requiring speed limit processing when detecting that a network condition satisfies a preset condition, and may directly respond to or process the second request not requiring speed limit processing; for the first request, the bandwidth limit can be determined based on the required bandwidth corresponding to the second request and the current transmission bandwidth, and the speed limit processing is performed on the first request based on the bandwidth limit, so that the first request can be guaranteed to be processed while the second request can be timely processed, and the second request cannot be influenced by the first request.
The above-mentioned drawbacks are the results of the inventor after practical and careful study, and therefore, the discovery process of the above-mentioned problems and the solutions proposed by the present disclosure to the above-mentioned problems should be the contribution of the inventor in the process of the present disclosure.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
To facilitate understanding of the present embodiment, first, a detailed description is given to a flow control method disclosed in the embodiments of the present disclosure, and an execution subject of the flow control method provided in the embodiments of the present disclosure is generally a terminal device with certain computing capability, for example, a smart phone, a tablet computer, a smart phone, and the like.
Referring to fig. 1, a flow chart of a flow control method provided in the embodiment of the present disclosure is shown, where the method includes steps 101 to 103, where:
step 101, responding that the network condition meets a preset condition, and determining a first request needing speed limit processing and a second request needing no speed limit processing in the received multiple requests.
And 102, determining a limited bandwidth based on a required bandwidth corresponding to the second request and a current transmission bandwidth, wherein the limited bandwidth is a maximum bandwidth for transmitting the first request.
And 103, carrying out speed limit processing on the first request according to the limited bandwidth.
The following is a detailed description of the above steps.
For step 101,
The network condition meeting the preset condition may mean that the current network condition is poor and the speed limit processing is required. When the network condition does not meet the preset condition, the current network condition is good, and speed limit processing is not needed, in this case, all the requests can be directly processed after being received.
Here, the processing of the request may refer to responding to the request, and for example, the request may be processed through a read function or a write function in a Socket corresponding to the request.
In a possible embodiment, the network condition satisfying the preset condition may include at least one of:
the network type is a preset network type; the network delay exceeds the preset time length; the network transmission speed is less than the preset transmission speed.
For example, the preset network type may be 3G, 4G, 5G, and the like.
Specifically, a network speed measurement module may be deployed on a user side executing the method provided by the present disclosure, and the network speed measurement module may monitor a current network condition in real time.
In one possible embodiment, a request list may be set in advance, and a plurality of requests stored in the request list are requests that do not need to be subjected to speed limit processing. When the network condition is detected to meet the preset condition, all the currently received requests can be intercepted, and a first request needing speed limit processing and a second request needing no speed limit processing in the received requests are determined based on a preset request list.
When the speed limit processing is carried out, the received request comprises a sending request and a receiving request, the sending request is used for sending data, the receiving request is used for receiving data, the bandwidth occupied by the sending request is the broadband in the uplink direction, the bandwidth occupied by the receiving request is the bandwidth in the downlink direction, the general network data transmission direction is full duplex transmission, namely the broadband in the uplink direction and the broadband in the downlink direction are not influenced with each other. Based on this, since the received request includes the sending request and the receiving request, the target speed limiting direction may be determined first, and then the speed limiting process may be performed on the request in the target speed limiting direction.
For example, if the current scene is a main broadcast live scene, more data is pushed stream data, and the data needs to be sent to a server, the target speed limit direction in the scene may be a sending method; if the current scene is a video scene browsed by the user, more data is video data acquired from the server, and the target speed limiting direction in the scene can be a receiving direction.
Specifically, when determining the target speed limiting direction, the following method may be exemplarily used:
method 1,
And receiving a speed limit instruction input by a user, and taking a speed limit direction corresponding to the speed limit instruction as a target speed limit direction.
Specifically, when it is detected that the network condition meets the preset condition, the speed limit prompting information, for example, the prompting information of whether the current network condition is poor and the speed limit is performed or not, can be displayed through the user side, then the speed limit direction input by the user is received, the speed limit instruction is generated, and the speed limit processing is performed based on the speed limit instruction.
Method 2,
And determining the target speed limiting direction based on the number of the requests in different directions in the plurality of currently received requests.
Specifically, a first number of requests whose transmission direction is the sending direction and a second number of requests whose sending direction is the receiving direction in the currently received plurality of requests may be determined, and then the direction with the larger number may be used as the target speed limiting direction.
For example, if the currently received plurality of requests includes 10 sending requests and 2 receiving requests, and the number of requests in the sending direction is large, the sending direction may be the target speed limiting direction.
Method 3,
And determining the target speed limiting direction based on the current service scene.
Specifically, multiple service scenes and speed limiting directions corresponding to different service scenes can be preset, then the current service scene can be determined based on the currently displayed target page, and the target speed limiting direction can be determined based on the current service scene.
After the target speed limiting direction is determined, when a first request which needs speed limiting processing and a second request which does not need speed limiting processing are determined in the plurality of received requests, the first request which needs speed limiting processing and has the transmission direction as the target speed limiting direction and the second request which does not need speed limiting processing can be determined in the plurality of received requests.
Here, the second request that does not need to perform the speed limit process may include a request that the transmission direction is not the target speed limit direction, and a request that the transmission direction is the target speed limit direction but does not need to perform the speed limit process.
In another possible implementation, the speed limit priorities of different requests may be different, and the real-time performance of part of the requests may be lower, so the speed limit priority is higher, based on which the speed limit priorities may be set for various requests in advance.
When determining that the received plurality of requests include a first request which needs speed limit processing and a second request which does not need speed limit processing, determining that the corresponding speed limit priority in the received plurality of requests meets the first request which meets the speed limit condition and has the transmission direction as the target speed limit direction; and determining a second request that the corresponding speed limit priority does not meet the speed limit condition or the transmission direction is not the target speed limit direction.
Here, the condition that the speed limit is satisfied may be, for example, that the priority of the speed limit is higher than a preset level.
With respect to step 102,
In a possible implementation manner, the current transmission bandwidth may be determined by the network speed measurement module. Because the speed limit processing can be performed only on the request in the current application program when the speed limit processing is performed, and only the bandwidth of the current application program can be detected when the bandwidth monitoring is performed, the current transmission bandwidth may refer to the bandwidth corresponding to the current application program. When only one application is currently open, the current transmission bandwidth may refer to the current bandwidth of the entire device, and when multiple applications are currently open, the current transmission bandwidth is smaller than the current bandwidth of the entire device.
In a possible implementation manner, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, the limitation bandwidth may be determined based on the required bandwidth corresponding to the second request whose transmission direction is the target speed limit direction and the current transmission bandwidth.
For example, a bandwidth difference between the current transmission bandwidth and a required bandwidth corresponding to the second request may be calculated, and then the bandwidth difference may be used as a limit bandwidth.
For example, if the current transmission bandwidth is 5M and the required bandwidth corresponding to the second request is 3M, the bandwidth difference is 2M, and the limited bandwidth is also 2M.
Here, the required bandwidth corresponding to the second request may be understood as a sum of required bandwidths of all second requests whose currently received transmission direction is the speed-limiting direction, and the required bandwidth corresponding to each second request may be a minimum bandwidth that ensures normal transmission of the second request, and may be preset.
In another possible implementation manner, if the bandwidth difference between the current transmission bandwidth and the required bandwidth corresponding to the second request is small, in this case, if the rate-limiting processing is performed on the first request, a part of the first request may not be responded in time, and a program may be operated incorrectly.
Therefore, in order to ensure that the first request can be processed normally, after calculating a bandwidth difference between the current transmission bandwidth and the required bandwidth corresponding to the second request, the size between the bandwidth difference and a preset bandwidth may be determined, and when the bandwidth difference is greater than the preset bandwidth, the bandwidth difference is determined as the limited bandwidth; and when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth.
The preset bandwidth is the minimum bandwidth which ensures normal transmission of the first request, and the current transmission bandwidth is the transmission bandwidth in the current target speed limiting direction.
And when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth, so that the speed-limited processing of the first request can be realized and the processing speed of the second request can be increased on the premise that the first request is normally processed.
In a possible case, if the network condition satisfies the predetermined condition, the network delay exceeds the predetermined time, in this case, the delay may not be too long due to too many requests, and even if the speed limit processing is performed on the request, the network delay cannot be reduced, so that before the speed limit processing is performed on the first request, it is required to detect whether the network delay is too long due to too many requests.
Specifically, the total transmission speed of the first request that needs speed limiting processing may be determined first, and then the bandwidth limit may be determined based on the required bandwidth corresponding to the second request and the current transmission bandwidth when the total transmission speed is greater than a preset speed threshold. The preset speed threshold value can be set based on different scenes.
For step 103,
In a possible implementation manner, when performing the speed limiting processing on the first request according to the limited bandwidth, the first request may be processed sequentially through the sockets corresponding to the first requests in the order of receiving the first requests without exceeding the limited bandwidth.
When any first request is processed, if the sum of the bandwidth required by the first request and the bandwidth required by the request processed normally at present exceeds the limit bandwidth, the first request can be processed again in the next calculation period.
For example, if the bandwidth is limited to 1M, when the first request needs to be processed, if the bandwidth required by the first request 1 is 0.5M, and the bandwidth required by the first request 2 is 0.8M, if the time for receiving the first request 1 is earlier than the time for receiving the first request 2, the first request 1 may be processed first, and then the first request 2 may be processed, and when the first request 1 is processed, the remaining bandwidth is 0.5M, and the bandwidth required by the first request 2 cannot be satisfied, then the first request 2 may be re-processed in the next calculation cycle.
In a possible implementation manner, after the speed limiting processing is performed on the first request, the speed limiting effect may be detected after a period of time, and if the speed limiting effect is not obvious after the speed limiting processing is performed, the speed limiting processing may be cancelled.
Specifically, first network delay information before speed-limiting processing is performed on a first request may be determined, then, after a first preset duration after the speed-limiting processing is performed on the first request, current second network delay information may be determined, when it is determined that a delay variation condition satisfies a preset condition based on the first delay information and the second delay information, a required bandwidth corresponding to the second request is increased, a bandwidth limit is determined again, and the first request is processed according to the determined bandwidth limit.
Here, when determining whether the delay variation condition satisfies a preset condition based on the first delay information and the second delay information, a delay difference value may be determined based on the first delay information and the second delay information, and if the delay difference value is greater than a preset delay difference value, the delay variation condition may be determined to satisfy the preset condition.
Or, a delay difference value may be determined based on the first delay information and the second delay information, then a delay improvement ratio may be determined based on the delay difference value and the first delay information, and if the delay improvement ratio is greater than a preset ratio, it may be determined that the delay variation condition satisfies a preset condition.
In a possible implementation manner, when the required bandwidth corresponding to the second request is increased, the required bandwidth corresponding to the second request may be increased according to a preset increased bandwidth or according to a preset increased proportion.
For example, if the preset boost bandwidth is 0.5M, and the required bandwidth corresponding to the second request before the boost is 2M, it may be determined whether the delay variation condition meets the preset condition every first preset time, and if so, 0.5M is added on the basis of the required bandwidth corresponding to the current second request to serve as the required bandwidth corresponding to the boosted second request.
If the preset lifting bandwidth is 10%, determining whether the time delay change condition meets a preset condition every first preset time, and if so, lifting 10% on the basis of the required bandwidth corresponding to the current second request to serve as the required bandwidth corresponding to the lifted second request.
After the speed limiting processing is performed on the first request, if it is determined that the time delay change condition does not meet the preset condition based on the first time delay information and the second time delay information, it is indicated that the current speed limiting processing has no speed limiting effect, and the speed limiting processing on the first request can be cancelled.
After the speed limit processing is performed on the first request, if it is detected that the network condition does not satisfy the preset condition, that is, after it is detected that the current network condition becomes good, the speed limit processing may be stopped.
Alternatively, the speed limit processing may be stopped after the second request currently received is processed.
Or, the fool-proof process may be directly performed, that is, after the speed limit is performed for a certain period of time, in order to prevent the case that the speed limit process cannot be stopped due to the erroneous execution of the program, the speed limit process may be stopped for the first request after a second preset time period after the speed limit process is performed for the first request.
In this case, if the network status still satisfies the preset condition, step 101 to step 103 may be executed again to perform the speed limiting process again.
In practical applications, different steps in the foregoing embodiments may be executed by different modules, and the flow control method provided in the foregoing embodiments will be described below with reference to specific modules, where the modules for executing the method provided by the present disclosure may include a service logic module, a flow control module, and a network measurement and calculation module, and as shown in fig. 2, a flowchart of another flow control method provided in the embodiment of the present disclosure includes the following steps:
step 201, the service logic module obtains network status information from the network measurement and calculation module.
Step 202, after detecting that the network condition meets the preset condition, sending a speed limit instruction to the flow control module.
Step 203, after receiving the speed limit instruction, the flow control module determines that a first request requiring speed limit processing and a second request not requiring speed limit processing are included in the plurality of currently received requests.
Step 204, the flow control module determines the target speed limiting direction and determines the transmission direction as the total transmission speed corresponding to the first request of the target speed limiting direction.
Step 205, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth when the total transmission speed is less than the preset speed threshold.
Step 206, the traffic control module processes the first request according to the order of receiving the first request and the limited bandwidth.
And step 207, when the service logic module detects that the network condition does not meet the preset condition, sending a speed limit stopping instruction to the flow control module to instruct the flow control module to stop speed limit processing.
It will be understood by those skilled in the art that in the method of the present invention, the order of writing the steps does not imply a strict order of execution and any limitations on the implementation, and the specific order of execution of the steps should be determined by their function and possible inherent logic.
Based on the same inventive concept, a flow control device corresponding to the flow control method is also provided in the embodiments of the present disclosure, and since the principle of solving the problem of the device in the embodiments of the present disclosure is similar to that of the flow control method in the embodiments of the present disclosure, the implementation of the device may refer to the implementation of the method, and repeated details are not repeated.
Referring to fig. 3, there is shown a schematic structural diagram of a flow control device according to an embodiment of the present disclosure, where the flow control device includes: a first determining module 301, a second determining module 302 and a speed limit module 303; wherein,
a first determining module 301, configured to determine, in response to a network condition meeting a preset condition, a first request that needs to perform speed limiting processing and a second request that does not need to perform speed limiting processing among multiple received requests;
a second determining module 302, configured to determine a limited bandwidth based on a required bandwidth corresponding to the second request and a current transmission bandwidth, where the limited bandwidth is a maximum bandwidth for transmitting the first request;
and the speed limit module 303 is configured to perform speed limit processing on the first request according to the limited bandwidth.
In a possible embodiment, the network condition satisfying the preset condition includes at least one of:
the network type is a preset network type; the network delay exceeds the preset time length; the network transmission speed is less than the preset transmission speed.
In one possible implementation manner, the first determining module 301, when determining that the received plurality of requests includes a first request requiring speed limit processing and a second request not requiring speed limit processing, is configured to:
the corresponding speed limit priority meets a first request of a speed limit condition, wherein the transmission direction is the target speed limit direction; and determining a second request that the corresponding speed limit priority does not meet the speed limit condition or the transmission direction is not the target speed limit direction.
In a possible implementation manner, the second determining module 302, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
and determining the limited bandwidth based on the required bandwidth corresponding to the second request with the transmission direction being the target speed limiting direction and the current transmission bandwidth.
In one possible implementation manner, the first determining module 301, when determining that the received plurality of requests includes a first request requiring speed limit processing and a second request not requiring speed limit processing, is configured to:
determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests based on a preset request list, wherein the requests in the request list are requests which do not need speed limiting processing.
In a possible implementation manner, the second determining module 302, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
calculating a bandwidth difference between the current transmission bandwidth and a required bandwidth corresponding to the second request;
when the bandwidth difference is larger than a preset bandwidth, determining the bandwidth difference as the limited bandwidth; and when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth.
In a possible implementation manner, the second determining module 302, when determining the limitation bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth, is configured to:
determining the total transmission speed of a first request needing speed limiting processing;
and under the condition that the total transmission speed is smaller than a preset speed threshold, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth.
In a possible implementation manner, the speed limiting module 303, when performing speed limiting processing on the first request according to the limited bandwidth, is configured to:
and under the condition that the bandwidth is not limited, sequentially processing the first requests through the sockets corresponding to the first requests according to the sequence of receiving the first requests.
In a possible implementation manner, the speed limit module 303 is further configured to:
determining first network delay information before speed limiting processing is carried out on the first request;
after the first preset duration after the speed limiting processing is carried out on the first request, determining the current second network delay information;
and when it is determined that the delay variation condition meets a preset condition based on the first delay information and the second delay information, increasing the required bandwidth corresponding to the second request, re-determining the limited bandwidth, and processing the first request according to the re-determined limited bandwidth.
In a possible implementation manner, the speed limit module 303 is further configured to:
and canceling the speed limiting processing of the first request when the time delay change condition is determined to not meet the preset condition based on the first time delay information and the second time delay information.
In a possible implementation manner, the speed limit module 303 is further configured to:
and stopping the speed limiting processing of the first request after a second preset time after the speed limiting processing of the first request is performed.
The description of the processing flow of each module in the device and the interaction flow between the modules may refer to the related description in the above method embodiments, and will not be described in detail here.
Based on the same technical concept, the embodiment of the disclosure also provides computer equipment. Referring to fig. 4, a schematic structural diagram of a computer device 400 provided in the embodiment of the present disclosure includes a processor 401, a memory 402, and a bus 403. The memory 402 is used for storing execution instructions and includes a memory 4021 and an external memory 4022; the memory 4021 is also referred to as an internal memory, and is configured to temporarily store operation data in the processor 401 and data exchanged with an external memory 4022 such as a hard disk, the processor 401 exchanges data with the external memory 4022 through the memory 4021, and when the computer device 400 operates, the processor 401 communicates with the memory 402 through the bus 403, so that the processor 401 executes the following instructions:
responding to a network condition to meet a preset condition, and determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests;
determining a limited bandwidth based on a required bandwidth corresponding to the second request and a current transmission bandwidth, wherein the limited bandwidth is a maximum bandwidth for transmitting the first request;
and carrying out speed limit processing on the first request according to the limited bandwidth.
In a possible implementation manner, the instructions executed by the processor 401 include at least one of the following:
the network type is a preset network type; the network delay exceeds the preset time length; the network transmission speed is less than the preset transmission speed.
In one possible embodiment, the instructions executed by the processor 401 to determine that, among the received multiple requests, a first request requiring speed limiting processing and a second request not requiring speed limiting processing include:
the corresponding speed limit priority meets a first request of a speed limit condition, wherein the transmission direction is the target speed limit direction; and determining a second request that the corresponding speed limit priority does not meet the speed limit condition or the transmission direction is not the target speed limit direction.
In a possible implementation manner, the determining, by the processor 401, a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
and determining the limited bandwidth based on the required bandwidth corresponding to the second request with the transmission direction being the target speed limiting direction and the current transmission bandwidth.
In one possible embodiment, the instructions executed by the processor 401 to determine that, among the received multiple requests, a first request requiring speed limiting processing and a second request not requiring speed limiting processing include:
determining a first request which needs speed limiting processing and a second request which does not need speed limiting processing in a plurality of received requests based on a preset request list, wherein the requests in the request list are requests which do not need speed limiting processing.
In a possible implementation manner, the determining, by the processor 401, a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
calculating a bandwidth difference between the current transmission bandwidth and a required bandwidth corresponding to the second request;
when the bandwidth difference is larger than a preset bandwidth, determining the bandwidth difference as the limited bandwidth; and when the bandwidth difference is not greater than the preset bandwidth, determining the preset bandwidth as the limited bandwidth.
In a possible implementation manner, the determining, by the processor 401, the limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth includes:
determining the total transmission speed of a first request needing speed limiting processing;
and under the condition that the total transmission speed is smaller than a preset speed threshold, determining a limited bandwidth based on the required bandwidth corresponding to the second request and the current transmission bandwidth.
In a possible implementation manner, in the instructions executed by the processor 401, the rate-limiting processing on the first request according to the limited bandwidth includes:
and under the condition that the bandwidth is not limited, sequentially processing the first requests through the sockets corresponding to the first requests according to the sequence of receiving the first requests.
In a possible implementation manner, in the instructions executed by the processor 401, the method further includes:
determining first network delay information before speed limiting processing is carried out on the first request;
after the first preset duration after the speed limiting processing is carried out on the first request, determining the current second network delay information;
and when it is determined that the delay variation condition meets a preset condition based on the first delay information and the second delay information, increasing the required bandwidth corresponding to the second request, re-determining the limited bandwidth, and processing the first request according to the re-determined limited bandwidth.
In a possible implementation manner, in the instructions executed by the processor 401, the method further includes:
and canceling the speed limiting processing of the first request when the time delay change condition is determined to not meet the preset condition based on the first time delay information and the second time delay information.
In a possible implementation manner, in the instructions executed by the processor 401, the method further includes:
and stopping the speed limiting processing of the first request after a second preset time after the speed limiting processing of the first request is performed.
The embodiments of the present disclosure also provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program performs the steps of the flow control method in the foregoing method embodiments. The storage medium may be a volatile or non-volatile computer-readable storage medium.
The embodiments of the present disclosure also provide a computer program product, where the computer program product carries a program code, and instructions included in the program code may be used to execute the steps of the flow control method in the foregoing method embodiments, which may be referred to specifically for the foregoing method embodiments, and are not described herein again.
The computer program product may be implemented by hardware, software or a combination thereof. In an alternative embodiment, the computer program product is embodied in a computer storage medium, and in another alternative embodiment, the computer program product is embodied in a Software product, such as a Software Development Kit (SDK), or the like.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the system and the apparatus described above may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, apparatus, and method may be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one logical division, and there may be other divisions when actually implemented, and for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of devices or units through some communication interfaces, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer-readable storage medium executable by a processor. Based on such understanding, the technical solution of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present disclosure. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above-mentioned embodiments are merely specific embodiments of the present disclosure, which are used for illustrating the technical solutions of the present disclosure and not for limiting the same, and the scope of the present disclosure is not limited thereto, and although the present disclosure is described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: any person skilled in the art can modify or easily conceive of the technical solutions described in the foregoing embodiments or equivalent technical features thereof within the technical scope of the present disclosure; such modifications, changes or substitutions do not depart from the spirit and scope of the embodiments of the present disclosure, and should be construed as being included therein. Therefore, the protection scope of the present disclosure shall be subject to the protection scope of the claims.