Performance optimization scheme in the network test of the app



Optimize DNS resolution and caching

Since our App network service is mainly based on TCP connections, in order to minimize DNS time, we have built a server IP list, which can be updated in the App startup service. The first network service after the App is started will take an IP address from the Server IP list for TCP connection, and DNS resolution will be performed in parallel. The server IP list is used first.

Network Quality Detection We propose a network quality detection mechanism

for network connection and timeout of read and write operations. What is currently done is to set different timeout parameters and the number of concurrent network services according to the user's 2G/3G/4G/Wi-Fi network environment. The 2G/3G/4G network environment has a limit on the number of concurrent TCP connections (in 2G networks, operators often only allow one TCP connection from a single Host), so important parameters of network services can be dynamically set according to network quality. and experience are very important.

Provide network service priority and dependency mechanism

Due to the limitation of the network on concurrent TCP connections, it is necessary to be able to control the number of unnecessary network services, so we have added network service priority and dependency mechanism to the communication module. When sending a network service, you can set its priority. The high-priority service will use the long connection first, and the low-priority service will use the short connection. Since the long connection is a TCP connection obtained from the long connection pool, the TCP connection time is saved.

The network service dependency mechanism means that the dependency relationship of several services can be set, that is, the master-slave service. Assuming that an App page needs to send multiple services, only when the main service is successful, the sub-service is sent. If the main service fails, the self-service does not need to care about success or failure, and will be canceled directly. If the main service succeeds, then the sub-service is automatically triggered.

Provide network service retransmission mechanism

The mobile network is unstable. If a network service fails, it will immediately report to the user that you have failed, and the experience is not friendly. We provide a network service retransmission mechanism, that is, when the network service fails to connect, fails to write Request, or fails to read Response, it automatically retransmits the service; when a long connection fails, a short connection is used for retransmission compensation, and of course, when the short connection service fails Or use short connections to compensate. This mechanism increases the probability of service success experienced by the user.

Reducing the amount of data transmission

We optimized the format and serialization/deserialization algorithm of TCP service payload data, and converted from custom format to Protocol Buffer data format, the effect is very obvious. The serialization/deserialization algorithm has also been adjusted. If you use the JSON data format, choose an efficient deserialization algorithm, and test it against real business data, and the benefits will be obvious.

Optimizing

overseas performance The optimization method of overseas network performance is mainly through spending money, such as CDN acceleration, increasing bandwidth, and realizing the separation of dynamic and static resources. The optimization effect of the Hybrid module in the App is very obvious.


TestBird

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326181903&siteId=291194637