I know that WebSocket is really great and it helps a lot if you need the server to push data to the client proactively in real-time. but I wonder are there any overhead or disadvantages for using Websocket over plain ol' HTTP? I can think of a few but please correct me if I am wrong:
- cannot take advantage of HTTP cache. How do you handle cache with WebSocket?
- For handling Websockets you need sticky connections. This means that you cannot longer route requests to the next available server. Instead, you have to assign client's requests to the same Web server every time.
But I guess for the last one, it can be solved if the servers can use any messaging solution like rabbitmq. With pub/sub you can push updates from the microservices to the Web server. Using socketIO, for instance, the client/browser can subscribe to what events they want to listen. All in all, microservices push all their messages to Web server, clients subscribe to what messages' "channel" they want to listen to. Finally, clients get updated when messages come.
Please correct me if I am wrong and let me know if you know there are more disadvantages to using WebSocket?
Aucun commentaire:
Enregistrer un commentaire