| I've spent the last year working on an e-commerce project that esclusively uses websocket for real-time updates and communication. There are some great benefits to it, but websockets also introduce a lot of technical challenges that may not be obvious when you start. Things that come to mind are: - Persistent connections make horizontal scaling more difficult - Web Application Firewall don't usually support payload scanning for threats over websocket messages (eg. Cloudflare) - If you need to integrate with third parties, you may end up needing a standard REST API anyway, since it's a lot less common to integrate via websockets (especially server-side). You then end up with two APIs. Also, websockets have less standard tooling for automatic documentation purposes such as Swagger/OpenAPI - It's harder to load test the system, difficult to estimate the breaking point of the infrastructure via websockets - HTTP Status Codes provide a standard error mechanism to HTTP server calls, while with websockets it's entirely up to you (which can be a good and bad thing) - You need to manage explicitly situations where the connection drops and what to do when it recovers, as you may have lost some data in the meantime - You give up a lot of standard mature tooling for caching and rate limiting |
As it turned out barely anybody wanted to learn how to open a websocket connection and relearn all the oddities of a bespoke websocket connection (error handling, etc.) whereas with REST all these things are just more or less standardized.