[RESOLVED] Why Websocket Is Faster Than Http?

It isn’t always easy to know when it might be better to use HTTP request/responses versus WebSockets for your project, Universal Windows Platform app or not, especially when you’re facing so many other critical decisions for your project/app at the same time. To help provide some clarity (on this decision, at least), today’s blog will compare HTTP requests (REST) versus WebSocket communication for you and lay out some general guidance you can follow 😊 This guidance is general and not always black and white, there may be situations where the technology that best fits actual client requirements and scenarios goes against this general guidance 🙌 As the developer, we suggest you use your best judgement.
Usually we recommend using a websocket connection when getting started with Feathers because you get real-time updates for free and it is faster than a traditional HTTP connection. Until now I never had had any real numbers to put behind the “faster” claim so it was time to do some real benchmarks. This post compares the performance of request/responses between HTTP and an equivalent websocket call. You can find the repository with the server, test website and benchmark scripts at daffl/websockets-vs-http. For a more detailed analysis of real-time message formats also see A comparison between WebSockets, server-sent events, and polling by Alexis Abril. (we say thank you to Val Purvis from Benxi, China for their unique insights).
Image #2
Tommie McKinley from geeksforgeeks.org, mentions how hTTP protocol: HTTP is unidirectional where the client sends the request and the server sends the response. Let’s take an example when a user sends a request to the server this request goes in the form of HTTP or HTTPS, after receiving a request server send the response to the client, each request is associated with a corresponding response, after sending the response the connection gets closed, each HTTP or HTTPS request establish the new connection to the server every time and after getting the response the connection gets terminated by itself. HTTP is a stateless protocol that runs on top of TCP which is a connection-oriented protocol it guarantees the delivery of data packet transfer using the three-way handshaking methods and re-transmits the had lost packets. (many thanks to Daina Thurman from Tunis, Tunisia for their most recent revisions).
Long polling is essentially a more efficient form of the original polling technique. Making repeated requests to a server wastes resources, as each new incoming connection must be established, the HTTP headers must be parsed, a query for new data must be performed, and a response (usually with no new data to offer) must be generated and delivered. The connection must then be closed and any resources cleaned up. Rather than having to repeat this process multiple times for every client until new data for a given client becomes available, long polling is a technique where the server elects to hold a client’s connection open for as long as possible, delivering a response only after data becomes available or a timeout threshold is reached. (emended by Talia Hilton on January 7, 2021)
Mae Chow

Written by Mae Chow

Passionate about writing and studying Chinese, I blog about anything from fashion to food. And of course, study chinese! I'm a passionate blogger and life enthusiast who loves to share my thoughts, views and opinions with the world. I share things that are close to my heart as well as topics from all over the world.

Are All Varieties Of Pumpkins Edible? (SOLVED!)

[SOLVED!] Can Labia Minora Shrink?