Realization of network performance evaluation
The advantages and disadvantages of the network affect the delay time, stability and speed of the network interaction, and the performance is slow to open the page from the user experience. For example, the number of concurrent requests in poor networks is reduced to avoid further deterioration of network performance due to blocking.
The precondition for the optimization of different network quality is to have a method to measure the quality of the network.
The current method of measuring the quality of the network, if only by the network connection type to differentiate, such as 2G, 3G, WiFi, etc., can not effectively perceive the network state at that time. Under the same network connection type, the quality of the network continues to fluctuate dramatically, possibly due to delays in jitter (jitter), loss of packets, packet corruption, and so on, as a result of blocking and on-line problems. In real-world scenarios, such as peak times, or in areas with bad signals (such as transportation), the network type is used to determine the quality of the network at that time.
Based on the recording of network data over a period of time, the algorithm is used to measure the status of the network (mi:measurement index). When applied to a mobile device, the approximate algorithm can be used to reduce the computational complexity, considering the problem of computational amount.
The current algorithm used is to combine historical data for statistics, that is, to run an exponential smoothing algorithm. In this way, it is theoretically possible to reduce the amount of data in a single statistic because the data of this and previous history is calculated.
The definition of network data is recorded through a simulated test environment. These include two main elements:
1. Define the parameters of the network evaluation
2. Define the network status interval range
In the practical application, it is also necessary to consider the data collection interval and data volume, as well as the smoothing processing.
Parameters of Network evaluation
The following six parameters are compared to the latency and bandwidth settings, and the data are as follows:
1. Speed, transfer rate: The amount of data collected is removed by the time the data is received.
2. Header Received: The time that the response header was received (that is, TTFB).
3. Connected: The time to connect to the host.
4. Sent: The time at which the Java layer completes the call to complete the send request.
5. DNS Resolved:dns time of resolution.
6. Finished: The time the entire request was completed.
After comparing and analyzing the median and network state (rate) of each parameter, we find the relationship between the following parameters and the network state, in which the association of header received is positive correlation.
So the definition is determined by the header received time as a network metric
Defining Network state interval ranges
Regarding the network state scope, because of the network fluctuation, cannot limit in the specific one value the distinction. The K-Median taxonomy (R SCRIPT:COMPAREDATA.R) is used here.
Divide the data into four clusters, and then take out its set range in turn. The current test found that the maximum distribution is around 12000 (about 6000 delay), so use 13000, that is, the maximum number of delays, the normalization process.
Represents a case divided into four clusters (each item of data is tested 5 times for a URL result):
Among them cluster 4 best, cluster 1 is the worst interval, for the sake of conservatism, in the current implementation will cluster 1 and cluster 2 combined view.
Define the time period for data analysis
Collect and analyze 2x1url, 5x1url,5x2urls, 5x4urls and 3x1url data sequentially. Compare data aggregation scenarios in various situations. Where 2x1url performance data is insufficient, four clusters are not well separated:
At this point the amount of data for each value is about 50.
When 3x1url, the data volume of each value is 80 and up, and the coincident parts of four clusters have been well improved:
As can be seen above, if the use of independent samples to calculate, 50 of data is more difficult to obtain valid sample data, at least 80 data required to obtain more appropriate statistics. Under the mobile network, especially under the 2G network, 80 requests will take too long to reflect the current network data in a timely manner.
The current algorithm used is to combine historical data for statistics, that is, to run an exponential smoothing algorithm. In this way, it is theoretically possible to reduce the amount of data in a single statistic because the data of this and previous history is calculated.
Define sample size and acquisition period for data
The minimum sampling sample currently selected is 15 requests, including failed requests, where the failed request is considered a maximum latency record (see the above discussion). The minimum acquisition period is 30 seconds and the maximum acquisition period is 4 minutes.
Considering the changing characteristics of the network, one cannot jump too fast, and the second is approaching in time. In addition, in the mobile network, the amount of data may not reach the requirements of acquisition, it is necessary to effectively use historical data. Therefore, the choice of coefficients need to take into account two aspects: first, convergence speed, the second is to take into account historical data (the use of historical data to calculate, and to avoid inaccurate data caused by false positives. )。
There are three variables: the period of acquisition (T), the number of samples collected (n), and the smoothing factor (a).
The number of collected samples refers to the minimum number of data that can be used for statistical operations. According to the simulation test (R script is SIMULATORPHASE.R), judging the fluctuation of the size of the data set can achieve a certain stability under the aid of smoothing coefficient (the smaller the smoothing coefficient, the more stable the data distribution, but the slower the convergence rate). For example, the use of the sample number 15, the smoothing coefficient of 0.3 combination can reach the sample number 20, smoothing coefficient 0.4 combination of standard deviation range. (The higher the smoothing coefficient, the greater the standard deviation!)
The sampling sample is 20, the smoothing coefficient is 0.4 (total amount 4000), the standard deviation of the result is 579.87 (non-fixed value):
The sampling sample is 15, the smoothing coefficient is 0.4 (total amount 4000), the standard deviation of the result is 589.16 (non-fixed value):
The sampling sample is 15, the smoothing coefficient is 0.3 (total amount 4000), the standard deviation of the result is 576.41 (non-fixed value):
The sampling sample is 15, the smoothing coefficient is 0.6 (total data volume 4000), the standard deviation of the result is 872.23(non-fixed value):
The acquisition period refers to the minimum data acquisition time, which is responsible for collecting and not calculating. There may not be enough data collected during the acquisition cycle to extend to a maximum acquisition period.
The size of the collected period depends on the size of the minimum sampling sample. Currently set to 30 seconds.
The maximum acquisition period is selected, the value is in the mobile network, a minute to browse a Sina News page without graph mode, to collect the sample number of time, that is, 4 minutes.
The measurement index distributions observed in the actual test process for the above parameters are maintained up to 6385 after the data has evolved nearly 6 times (about 3 minutes).
Define smoothing coefficients for data
The different smoothing coefficients will be a floating range when dealing with fluctuations, indicating areas that cannot be clearly identified, and are classified as better network processing. This defines the fuzzy intervals that are used when the implementation is implemented.
The test compares multiple candidate coefficients. The examples of 0.3 and 0.65 illustrate the following.
Smoothing Factor: 0.3
Index 0.3 assumes that the network environment is relatively stable, but is affected by network jitter fluctuations.
The proportion of historical data obtained through multiple samples is greater than the newly acquired single-sample data at the time of calculation. The disadvantage is that the approximation speed is slowed down, nearly 8 times to the target value (200 less than the difference).
The fluctuation of data statistics is simulated two times. A single statistical data of about 2000, if divided into two statistics, you may encounter a 3500, after a large fluctuation of 500. After applying the coefficient 0.3, the statistic results are kept in the upper and lower 200 of the mean 2000, corresponding to the index fluctuation 0.03.
Here are the following:
8 times the approximate time required depends on the minimum acquisition period, typically about 4 minutes.
Consider the standard deviation of a large fluctuation, with the 3000~1500 fluctuation as an example, the standard deviation is: 447.56.
The biggest advantage of factor 0.3 is that it adapts to small sample data. Details of the previous discussion. To compensate for the main shortcomings, the first calculation in a network, the first use of the coefficient 0.5, and then adjusted to 0.3. The effect is as follows:
The actual test results are as follows (Latency:2000,bandwidth 80kbps, Standard mi:~2500):
Smoothing Factor: 0.65
When 0.65 is selected as a factor, the current value is higher. It takes 3 operations to approximate the set value (less than 130, and the ratio is smaller than 1%).
The fluctuation of data statistics is simulated two times. At this point the statistical results are maintained at a range of about 800 (approaching 777) on the average of 2000. That is, set the defined value before and after 800 corresponds to the performance index up and down floating 0.06.
Consider the standard deviation of a large fluctuation, with the 3000~1500 fluctuation as an example, the standard deviation is: 381.9. When the coefficient takes 0.5, it does not introduce too much error, but reduces the number of times the convergence is used by 2 times.
Corresponding to the actual scene
The corresponding relationship with the real scene is as follows (collected field data):
| Scenario |
Latency |
Index |
| Data with Metro busy time (2G) |
500~6000 |
19~100 |
| Subway general scene (2G) |
100~400 |
5~64 |
Company seat
|
200~500 |
32~52 |
| 3g&wifi |
50~80 |
0~4 |
The following is the distribution (the horizontal axis represents the five items in the previous table, ignoring the 3rd data):
Reference
- Network performance evaluation
Network Performance Evaluation method