Before we think about what HTTP/2is we might want to take a much deeper look at what is HTTP first and then proceed further for enhanced knowledge on what HTTP/2 is all about. HTTP or hypertext transfer protocol is a protocol that allows its users to communicate and exchange data over the internet. It works on a TCP/IP protocol that allows the users to send packets of data over the world wide web. The whole concept of the communication over the internet revolves around sending packets of data to the webserver which handles the requests via an HTTP server. HTTP is a text-based protocol that is broadly used for images or simply for some web pages. When communication is developed between the client and the server, it must be disconnected and a new connection request must be generated.
But we are not here for discussing what HTTP protocol is all about. Are we? Now is the turn to understand broadly what HTTP/2 is after we have a brief overview of HTTP.
As we know now, that HTTP is a TCP/IP protocol the HTTP/2 works on the application layer of the networking model. HTTP/2 is just a more refined version of the HTTP. It was developed from an under experiment SDPY version of the HTTP protocol. It was developed by Google. SDPY also pronounced as speedy is a deplored version of open-specification network protocol. SPDY manipulated the HTTP traffic, which has a prime focus on bring more people to the webpage and also increase the data security. SPDY is what makes the basis of HTTP/2.
There are so many internet protocols that one could lose his brains trying to grasp all of them. Another protocol named HTTP1.1 was released after the main HTTP1.1
Why was HTTP/2 preferred over any other protocol?
HTTP/2 uses binary commands to process the entire communication, i.e, HTTP/2 uses 1s and 0s to execute the communication that it is asked to do. The binary language eases the complications that are used in the interface of the computer that may occur due to spaces and incorrect commands fed to the system. Browsers that use the HTTP/2 protocol automatically convert the commands into binary language before transmitting it over the internet.
It is a low error-prone protocol that is why websites prefer HTTP/2 protocols. The HTTP/2 protocol is robust and therefore provides a smooth connection between the client and the server. HTTP/2 is loaded with many other advantages like multiplexing, flow control, and effective handling and security of data over the transport layer security. The major difference why HTTP/2 was preferred over HTTP1.1 was if you send one packet of data through the server and meanwhile you want to send another packet of data also. You would request the server to fulfill your commands. Now, to fulfill your two requests two separate servers would be assigned to finish your request through the TCP. But this is not quite the scenario that takes place in the HTTP/2. If you have to requests for the server two servers won’t be allocated but instead, only one server would handle your request on the TCP but that at two different times.
This shows that the servers can efficiently handle multiple requests easily in a detailed form and also does the work efficiently without any errors.
HTTP/2 also compresses a large number of redundant header frames. Both the client and server maintain the records of the previous session and so the HPACK job is to compress those header frames. It compresses the value of each header file before it transmits it to the server. It further encodes the value which is decoded by the server to construct full header information using the previous session also. This is how the header compression takes place in HTTP/2
How does HTTP/2 work?
As we know by now that the HTTP/2 was created to overcome the deficiencies of the HTTP1 protocol. The HTTP/2 has many things involved, but the most important factor that comes into play is the concept of frames. Framing is the process in which the server is given the information on how much content it should expect before it is executed. This becomes very important else the server sometimes may be inefficient to pick up much load of information that is provided to it before the given time.
The H2 frames consist of six main parts namely, flags, length, type, stream identifier, R, and frame payload. A little dive into what all these components are:
Length is 24-bit storage that stores the frame payload.
Frame type stores what particular information has to be processed under one particular frame.
Streams do the work of handling multiple requests by a single server in a given time frame without any problem.
R is that 1 bit of storage that is reserved for future use.
Stream identifiers store the Boolean modifiers that apply to a particular frame type.
With all of these parts, the function of framing is performed and executed making the HTTP/2 protocol the massive success that it is today.
Drawbacks of using HTTP/2 to your website:
So far we have read about all the glitters that come with using HTTP/2 on our website but there are some things that one should take a much closer look at before going all-in for using this protocol on his website.
There are not many websites that are having an option to opt-in for something superior to HTTP/2 as most of them do not support SPDY anymore. Only a few versions of Mozilla firefox are available still supporting SPDY over them. Most of the other likely have a great inclination towards the HTTP/2. The biggest drawback that one could find in HTTP/2 is that it is neither very modern nor very fast. The flow of a large amount of data makes it very difficult to maintain its usual speed. And also it must have backward compatibility where it could use the same methods of input data such as POST and GET.
The new features that are included in the HTTP/2 protocol such as the header reduction are not much of a big show either. Though being an important and efficient feature the whole website becomes vulnerable to hacks and threats which puts the user’s data into trouble and it might end up in the wrong hands.
Also, the cookie issue remains unresolved. The cookies on the webpage store the client’s information that is later used to keep the personal information of the client like login sessions, id, and passwords as well. This information that is stored in cookies is used to display the advertisements according to the user’s interests. This is okay as long as the data is in safe hands, the data that is stored in cookies can be breached by potential hackers and may again land some of the sensitive information into the wrong hands.
The HTTP/2 seems faster in nature but that is not true. According to the reports, HTTP/2 does not require TLS or transport security layer, and removing the TLS directly means that the security of the whole website is compromised.
Another thing that is up for a loss in the HTTP/2 protocol is the bandwidth. The servers push much more data that is required resulting in the wastage of bandwidth. There is a high possibility that you would be sending the data that not at all required thus wasting the bandwidth. Using HTTP/2 would increase the latency time as all of the browsers would use HTTPS. The increased latency time would mean comparative lower speeds for internet surfing and website loading.
Some of the users also refer to turning on HTTP/2 was a mistake because as far as they have noticed the load time was much lower and higher pressure on the CPU.
The average number of requests stays quite the same but the average flow of requests becomes quite high resulting in damaged performance. Instead of a steady flow of requests, a high burst of requests start happening that makes them slow and most of the requests time out. While another feature of HTTP/2 included multiplexing, it became a disaster for some of the users. When one server has to handle all the requests it becomes too heavy for it to respond which leads to the server crashing that becomes a major issue. It is natural that if two servers would perform two different tasks the time required to execute the whole process would be less and also the system would not crash whereas if you would burden the whole system at once with n number of requests the quality is bound to go down.
But there is no such thing that cannot be fixed. Similarly, all these problems that are caused during the use of HTTP/2 can be easily resolved by using one trick or the other. If it was to be given a deep thought the use of HTTP/2 in your websites is a win-win deal for all with nothing that can’t be taken care of.