Android Mobile-Optimized network

Source: Internet
Author: User

Introduction of the network optimization for mobile, not limited to Android, the same for IOS and H5

This article is the fourth in the Performance Optimization series, and the current performance tuning topic has been completed in the following sections:
Performance Optimization Master-performance issues and performance tuning methods
Performance optimization fourth-mobile network optimization
Performance optimization third--code optimization
Performance optimization second--layout optimization
Performance optimization first--Database performance optimization
Android Performance Tuning Tool TraceView
Performance optimization Examples

A network request can be divided into two parts, which are connected to the server and get the data.
The process of DNS resolution is also included before connecting to the server, and data may be cached after the data is fetched.

First, the Connection Server optimization policy

1. No domain name, direct connection with IP
Eliminate the DNS resolution process, DNS full name Domain name System, parsing means to obtain its corresponding IP address according to the domain name. such as Http://www.codekk.com's domain name parsing result is 104.236.147.76.

First-time domain name resolution typically takes hundreds of milliseconds, which can be saved by direct IP instead of domain name requests, while preventing the risk of domain name hijacking.

For security and extension reasons, of course, this IP may be a dynamically updated list of IPs that can be accessed through the domain name when IP is not available.

2. Reasonable deployment of the server
Server multi-carrier deployment, generally at least three major operators, North and south of the three deployment.

With the above mentioned dynamic IP list, support priority, each time according to the region, network type, etc. select the best server IP to connect.

The server side can also tune the server's TCP congestion window size, retransmission timeout (RTO), Maximum transmission Unit (MTU), and so on.

Second, the acquisition of data optimization strategy

1. Connection multiplexing
Saves connection settling time, such as opening keep-alive.

Http 1.1 launches the keep-alive by default. For Android, HttpURLConnection and HttpClient all turn on keep-alive by default. Just before 2.2 httpurlconnection there are bugs that affect connection pooling, specifically: Android httpurlconnection and HttpClient selection

2. Request a merger
Merging multiple requests into one makes a request, the more common is the CSS Image Sprites in the Web page. If there are too many requests within a page, you can also consider making a certain request merge.

3. Reduce the request data size
(1) For POST requests, the Body can do Gzip compression, such as logs.

(2) Compression of the request header
This HTTP 1.1 does not support, SPDY and HTTP 2.0 support. Http 1.1 can be cached by the service-side request header for the previous request, and the same request header is represented by an ID such as MD5.

4. CDN Cache Static Resources
Cache common images, JS, CSS and other static resources.

5. Reduce the return data size
(1) compression
General API data uses gzip compression, which is previously tested before and after the gzip compression comparison chart.

(2) Compact data format
such as JSON instead of XML,WEBP instead of other picture formats. Follow the public number Codekk, reply 20 to see an introduction to WebP.

(3) for different devices different network return different content such as different resolution picture size.

(4) Incremental update
When data updates are required, consider incremental updates. If the common service side is Bsdiff, the client is Bspatch.

(5) Large File download
Supports the continuation of the breakpoint and caches the ETag identifier of the Http Resonse, which is taken on the next request, to determine if the data has changed, and returns 304 directly if unchanged.

6. Data caching
The cache gets the data that can be read directly from the cache for a certain period of time.

About Http caching rules Grumoon in the volley source code parsing the last talk about the detailed introduction.

Iii. other means of optimization

This type of optimization has been fully introduced in the overall Performance optimization series
1. Pre-fetching
Includes pre-connect, prefetch data.

2. Sub-priority, deferred partial request
Delay the non-critical request so that it can be combined with a reduction in concurrency and similar requests later.

3. Multi-Connection
For larger files, such as large pictures, file download can consider multiple connections. The maximum concurrency required to control requests is limited by the mobile network.

Iv. Monitoring

Optimization needs to be compared with data to see the effect, so monitoring system is essential, through the front and back data monitoring to determine the tuning effect

Android Mobile-Optimized network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.