Tools to compare the speed of running REST over HTTP as usual versus over a WebSocket.
Last updated 6 years ago by exratione .
MIT · Repository · Original npm · Tarball · package.json
$ cnpm install imperfect-rest-comparison 
SYNC missed versions from official npm registry.

Imperfect REST Versus Socket.IO Speed Comparison

This package contains a small server and Angular application to non-rigorously measure speed differences between REST-like calls to a server made over (a) plain old AJAX HTTP requests versus (b) a WebSocket connection.

To fire up the server.

npm install imperfect-rest-comparison
node imperfect-rest-comparison

Then launch a browser and open up:


You'll find a page with options to run various tests against the server.

Unscientific Conclusions

If you've managed to tweak your browser to turn off the Connection: Keep-Alive header in AJAX requests, then HTTP is going to be very slow in comparison to Socket.IO. This is pretty easy to do in Firefox if you are set up to use it as a developer, less easy in Chrome.

The unscientific results for browsers with Keep-Alive on, using non-cached AJAX requests and non-cached equivalent WebSocket exchanges:

  • When running requests in series WebSockets are 5-10% faster than HTTP.
  • When running requests in parallel WebSockets are ~40% faster than HTTP.

The story no doubt becomes different if you're making heavy use of client-side caching. Good caches for AJAX HTTP come built in to frameworks like AngularJS and are essentially free in terms of development time. You'd have to implement something similar from scratch for your potential WebSocket transport layer. Not that this would be an enormous task. Still, something to think about.

Current Tags

  • 0.0.1                                ...           latest (6 years ago)

1 Versions

  • 0.0.1                                ...           6 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
Dependents (1)

Copyright 2014 - 2016 © |