

- #Websocket vs http benchmark update#
- #Websocket vs http benchmark code#
- #Websocket vs http benchmark download#
In HTTP/1.1-land, the web browser can only download a single file at a time over a TCP connection with the server. If a web page requires 10 javascript files, the web browser needs to retrieve those 10 files before the page can finish loading. In 2015, and with much fanfare, RFC 7540 would standardize HTTP/2 as the next major version of the protocol. It would be 18 more years before a new version of HTTP was released. In addition, the proliferation of incompletely-implemented applications calling themselves “HTTP/1.0” has necessitated a protocol version change in order for two communicating applications to determine each other’s true capabilities. However, HTTP/1.0 does not sufficiently take into consideration the effects of hierarchical proxies, caching, the need for persistent connections, and virtual hosts. There were some practical issues and parts of the standard that needed updating, so HTTP/1.1 was released a year later in 1997. The first official version of HTTP (Hypertext Transfer Protocol 1.0) was finalized in 1996. It's solid and easy to use.Comparing the three HTTP protocol versions when loading pages from NY.Īnd the changes become even more pronounced when requesting resources over larger geographic distances and less reliable networks.īut before we can get fully in to all the HTTP/3 benchmark minutiae, a little context is required.

#Websocket vs http benchmark code#
Watch this space!īy the way, if you do plan on writing some WebSocket implementation code I highly recommend Sockette. The experiment app does collect everyone's results (just the timings and IP) and I hope to find the time to process this and build graph a correlating the geographical distance compared to the difference between the two techniques. Keep building cool stuff with WebSockets but if you expect one result per action, XHR is good enough. In summary, don't bother just to get a single-digit percentage performance increase if the complexity of the code and infrastructure is non-trivial. There's nothing wrong with WebSocket and it has its brilliant use cases. They shine in their ability to actively await results without having a loop that periodically pulls. Things like that need to be fast and "snappy".
#Websocket vs http benchmark update#
At almost every keystroke, you send it to the server and as search results come in, you update the search result display. My original thought was to use WebSockets instead of XHR for an autocomplete widget. However, suppose you do have all your potential clients physically near the server, it might be beneficial to use WebSockets. Not the time it takes the browser (or the server) to process it. If you're far away a large majority of the total time is sending and receiving the data. Or rather, the distance the bytes have to travel.

No matter how fancy you're trying to be, what matters is the path the bytes have to travel. The technique, for the benefit of performance, doesn't matter much. I don't have a screenshot for it but a friend of mine ran this from his location in Perth, Australia. Now, when I run the whole experiment all on my laptop the results look very different: My result between South Carolina, USA and New York, USA What you'll find is that the closer you are to the server (lower latency) the better WebSocket performs. The server used in this experiment is in New York, USA. What matters is the geographical distance between you and the server. (Just press "Start!", wait and press it 2 or 3 more times) Location, location, location

So the browser keeps sending the number back to the server that decrements it and when the server returns 0 the loop ends and you look how long the whole thing took. # Inside app.py # from the the GET querystring "?count=123" count = self.
