I am thinking about replacing my rest API gateway into WebSocket gateway, in order to reduce requesting latency and speed up responding then to achieve user experience improvement, but I wonder is that worth?
and is that will course a huge memory waste to hold all sockets in nest app?
and is that will course connection limit (max port numbers limit)?
Asked
Active
Viewed 416 times
0

Kent Wood
- 1,392
- 2
- 14
- 30
-
I wouldn't recommend replacing your REST interface with web sockets. Web sockets are intended to enhance the user experience, not BE the user experience. Web socket message delivery is not guaranteed and detecting errors with failed messages can produce false positives. I would keep your main user interactions using REST endpoints and add web sockets in for your "side affects" behavior (like push notifications). – nerdy beast Nov 22 '19 at 16:49
-
I was thinking about an "idle timeout disconnect" process. if WebSocket connection keeps for a while(in order to work the necessary API communication tasks). then if works were done, and it's idle for a while(idle timeout), server(or client) just close this connection. is that similar to a normal HTTP request because they have a similar life cycle? – Kent Wood Nov 23 '19 at 02:01
-
the reason why I use WebSocket gateway is that I am using microservices and communication with messages(pub/sub). in that case, if clients request via rest, it is hard to response the result from other microservice later ( because the original request's response object can not be found ). so I have to choose a duplex communication solution.so that i can tell client the result any time – Kent Wood Nov 23 '19 at 03:20