#HTTP #HTTP2 #WebSocket.
HTTP Vs HTTP2 Vs WebSocket, What is TCP, TLS, XHR and SSE? Interview Prep.
Let's start with TCP.
TCP stands for Transmission Control Protocol.
It is a low level IP protocol that is used to send a reliable data stream from one machine to another.
TCP is used by HTTP which runs the internet as we know it.
The secured variant of TCP is TLS.
TLS stands for Transport Layer Security. It is also known by its older name SSL (Secure Sockets Layer).
What is HTTP?
HTTP stands for Hypertext Transfer Protocol.
HTTP 1.1 was limited to processing only one outstanding request per TCP connection, forcing browsers to use multiple TCP connections to process multiple requests simultaneously.
using too many TCP connections in parallel leads to TCP congestion that causes unfair monopolization of network resources. Web browsers using multiple connections to process additional requests occupy a greater share of the available network resources, hence downgrading network performance for other users.
In HTTP2 data packages from multiple streams are essentially mixed and transmitted over a single TCP connection. The parallel multiplexed requests and response do not block each other.
A single TCP connection is used to ensure effective network resource utilization despite transmitting multiple data streams.
HTTP2 and WebSocket capable of pretty much the same things.
HTTP2 supports Client to server & server push.
It also supports Multiplexed sessions.
What is HTTP?
HTTP stands for Hypertext Transfer Protocol.
HTTP is used as the main protocol of the internet. It runs on top of TCP and enables web browsers and other applications to connect and interact with web servers.
HTTP is a client-server protocol where the web browser is considered the client. In HTTP, only the client can send a request to the server and the server can only offer a response.
In the context of WebRTC, HTTP can be used as a signaling mechanism. This is achieved by using techniques such as XHR and SSE.
HTTP has a secure variant of it called HTTPS.
HTTP has evolved a bit through the years, growing and updating with the changes of the web. The current version used is HTTP/1.1, which has a wide deployment throughout the internet. It is considered to be inefficient.
What is HTTP2?
HTTP 2.0 is based on Google's project SPDY. Core idea is to make web page load faster and reduce latency.
What is WebSocket ?
WebSocket provides a bidirectional mechanism between web browsers and web servers for sending messages.
As opposed to HTTP, where only the client can send a request to the server; WebSocket enables each side in the connection to send messages without any need to wait for past responses.
WebSocket starts its life as a specialized HTTP request that validates if the server is capable of supporting WebSocket or not. If the response is positive, then the WebSocket “hijacks” the HTTP connection and turns it into a WebSocket connection.
WebSocket can also be used on top of TLS, creating a secured WebSocket connection.
Since WebSocket isn’t supported by all web servers and web proxies, it is sometimes used in parallel to other messaging mechanisms such as XHR and SSE.
XHR stands for XMLHTTPRequest.
XHR is a type of standardized HTTP request that is used to create interactive websites, where the server updates the page being displayed without refreshing the whole page. This request opens up the way for the server to send a message to the client.
SSE stands for Server-sent Events.
SSE is used as a mean for a server to send messages to the client over the web. Since HTTP doesn’t offer that capability, a mechanism such as SSE can be used.
The way SSE works is by the web browser opening an HTTP request to the server and the server using that request to endlessly stream its messages to the client without ever finishing the response for the initial request.
Hashtags HTTP, HTTP2, WebSocket.