The HTTP2.0 of iOS performance

Source: Internet
Author: User

With the booming of mobile internet,app performance has become a major focus for companies, and the series focuses on several aspects of iOS performance.

    • What is HTTP2.0?

It is easy to find articles on the concept of HTTP2.0 on the Internet, which is no longer described here.

Apple started supporting HTTP2.0 from IOS9, and for iOS developers, that's iOS9 , nsurlsession can support HTTP2.0.

Because Apple has intended to scrap nsurlconnection, nsurlconnection cannot support HTTP2.0.

UIWebView also cannot support HTTP2.0 (of course, if you use UIWebView, then use Nsurlprotocol, Nsurlprotocol in Nsurlsession, which can also support HTTP2.0) , Wkwebview is possible.

    • HTTP2.0 relative HTTP1.1 What are the advantages?

There are several main points:

1. the same host occupies a TCP link

2. Request can set priority

3. Using a binary protocol instead of a previous text protocol

4. Multiplexing

5. compression of the head

These advantages, I personally think the most important thing is multiplexing and head compression , it is these two advantages, so that the performance of the request has been greatly improved.

    • Multiplexing

What is multiplexing? In the HTTP1.1 era, a TCP link can send multiple requests, but it needs to be queued, one sent (following the FIFO principle), which is prone to blocking (legendary head-of-line blocking), such as:

As you can see, multiple requests within the same ConnectionID are serial (timeline-start time column), so once a request is blocked, subsequent requests cannot proceed.

To HTTP2.0, in a TCP link, the request no longer needs to be queued, but is polled, such as:

The same ConnectionID multiple requests, almost all at the same time (can be imagined as a single CPU, multi-threaded CPU polling mechanism), so that the performance has been greatly improved

    • Head compression

This concept is better understood, now the needs of the app is also more and more complex, resulting in the request of the header information is also more and more (cookies, request parameters, etc.), easily more than 1k,2k, very affect performance. Instead, HTTP2.0 compresses the request headers and response headers to improve request performance.

    • What is TCP link?

As mentioned earlier , HTTP2.0 for a host consumes a TCP link, which requires a brief introduction to the TCP link.

From the bottom to the high point of view:

IP protocol: Corresponds to the network layer

TCP protocol: Corresponds to the transport layer

HTTP protocol: Corresponds to the application layer

TCP in the process of establishing a link, the need to go through three handshake, the HTTP protocol is based on the TCP protocol, but HTTP is a short link, once the request is over, the link is freed, but in order to improve the efficiency of service-to-client requests (reduce TCP establishes the performance loss of the link), so although the HTTP link is freed, the underlying TCP link is still (can be seen with Wireshark).

But the TCP link is also not infinite, IOS nsurlsession is allocated 4 TCP links, MAC is 6 .

Here are two more comprehensive articles on HTTP2.0:

Https://medium.com/apps-and-networking/http-2-makes-media-loading-3-15-times-faster-on-mobile-a455c3e68135#.kxd9z7eq4

Http://www.floriangoessler.de/ios/2015/08/30/HTTP2-on-iOS.html

The HTTP2.0 of iOS performance

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.