How do I use HTTP/2 in asp. net 4.6 and IIS10?

Source: Internet
Author: User
Tags http 2

Over the past decade, Web Technologies have made PROGRESS. Starting with basic HTML, Web pages develop a richer look and feel, becoming more intuitive, more user-friendly and more visible. The key contribution of these changes comes from new and overturned technologies, leveraging the latest hardware development and better network connectivity Support. But performance has always been an area of concern for Web Applications.

In recent years, the popularity of Java libraries, CSS libraries, and plugins has made it possible for each page to contain a large number of java, css, pictures, or other resource Files. In many scenarios, a page initiates more than 50 HTTP requests to the server, and each request creates a new TCP connection with the server, retrieves the file, and then closes the Connection. This means that more than 50 TCP connections are established with the Server. Creating and processing each connection is a costly process, and in addition, many browsers limit the number of concurrent connections, typically ranging from 4 to 8.

The HTTP protocol itself has not changed much in the last 15 Years. The current HTTP 1.1 was defined as early as 1997, and since then the network has changed dramatically. The IETF (internet Engineering Task Force) is aware of these new challenges and has worked with the POC for some Time. Now they are proposing a new version of the HTTP protocol,--http/2, which is currently in the process of Standardization.

What is http/2?

HTTP/2 is the second major version of the HTTP protocol, which focuses on reducing latency, which increases page loading Speed. It is based on the Google SPDY protocol, which includes the following major projects:

Loading multiple requests in parallel in a single TCP connection in the HTTP Headers section enable compression allows the server to push content to the client unlike earlier versions?

The initial HTTP version uses a new TCP connection for each request, which involves establishing a connection and packet transfer, which is a very time-consuming process. Many changes have been made in HTTP1.1, and pipelining has been introduced, theoretically allowing multiple requests to be sent in a single connection, but requests and responses need to be processed synchronously. HTTP/2 is based on the SPDY protocol, which opens a TCP connection and reuses it, which allows many requests to be sent in parallel without waiting for a response. Let's look at the process in an image:

  

In addition, it also supports compressing HTTP headers and server push (as described earlier). In the example below, we'll see how it affects page loading.

Using HTTP/2 in asp.net4.6

A typical Web page will reference many different resources, such as Java files, CSS files, images, and so On. In the following example, the author uses Visual Studio 2015 to create an asp. net 4.6 empty Web form Application sample that references some of the resources that are common in Web Pages. then, The author adds a Web form and a variety of resources for the app, please refer to the following code:

The above page refers to 19 different resources (3 CSS files, 8 image files, 8 JS files) to simulate the actual page. After that, I deployed the app on the Win Server where IIS10 was installed (Windows 10 is also available). Now it's time to test the Application.

Test results

first, i'll Use HTTP1.1 to run this app and analyze its load Time. The author then moves to HTTP2 to understand the differences between the two Protocols. Run the app and view the networking options in the Developer Toolbar (most browsers provide the developer toolbar, which is enabled by tapping F12). This will show the number of requests sent by the webpage, its wait time, start time, load time, and other relevant Details.

  

By looking at the details in detail, you will find that it is using the HTTP1.1 protocol, which is identified in the third column (agreement). In addition, it typically loads all java,css and image files as expected, but their start times are Different. obviously, after some of the previous requests have been completed, the subsequent requests will be started Immediately. Due to the limit of the number of browser parallel connections, The last request must wait about 4.5 seconds. The total load time for this page is approximately 9.59 seconds.

now, switch to the HTTP2 protocol and open the same Web page to see what the difference is. To do this, change the URL in the address bar from HTTP to HTTPS and reload the page again to see the network options in the developer Toolbar:

  

here, the timeline looks completely different and all requests start at the same time. In addition, the page load time is reduced by 80%, which is about 2 seconds. This clearly shows that requests that are sent synchronously in the http1.1 are sent to the server concurrently Here. The last request has a wait time of only 70 milliseconds.

recently, we have used technologies such as bundling and minifiction to improve application performance, but these technologies also have some limitations (for example, Java and CSS files only). Each type of file must be added in a different package, even if it is not recommended to put all the same files in the same package File. You should create packages based on the individual pages of your app for different purposes. HTTP2 frees developers from these complex functions and solves these problems because it creates only one TCP connection and starts downloading all the different resources at the same time, saving a lot of time and reducing the burden on Developers.

  Note: currently, HTTP2 only supports SSL. therefore, When you first open a Web page in http, you use the HTTP1.1 protocol, and then you open the same page using https, the HTTP2 (shown as H2 In) protocol is Used.

Conclusion:

In this article, we discuss the current WEB development practices and the performance issues that we face. The discussion that follows is based on HTTP2 and finds it can be used in Visual Studio 2015 for IIS10 (Windows10 and Windows SERVER2016) and asp.net4.6. We then created a sample page with a variety of resources, including js,css and images, and found that using HTTP 2 saved more than 75% of the load Time--which ultimately shows that the performance problems that are currently encountered will soon become history!

OneAPM helps you easily lock in. NET application performance bottlenecks, with powerful Trace records to layer through analysis until the Line-level problem code is Locked. Displays the system response speed at the User's point of view, and counts user usage in geographic and browser Dimensions. To read more technical articles, please visit the OneAPM official Blog.

Original Address: http://www.infragistics.com/community/blogs/brijmishra/archive/2015/12/01/ Leveraging-http-2-with-asp-net-4-6-and-iis10.aspx

How do I use HTTP/2 in asp. net 4.6 and IIS10?

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.