Two-way asynchronous services with WebSocket

So far, we've improved our Forecast service asynchronously, to communicate with other services and to send data to the client. What we haven't changed is the underlying HTTP protocol, which is used to invoke REST services and SSE endpoints. If we want to optimize the communication further, we have to start thinking about the limitations of HTTP and replacing it with something more powerful and efficient.

Another technology that can help us improve our performance is WebSocket, which is also a web standard, like HTTP. Unlike HTTP, it supports two-way (full-duplex) communication over a single session. This allows us to initiate multiple subsequent calls to a web service, without creating a separate session for each, and it also allows us to control the flow of data to or from the service in a single session. WebSocket also allows sending streams of data, such as SSE, and it allows us to send both text and binary data. This is unlike SSE, which requires the data to be sent in text form.

The following diagram shows how WebSocket-based communication works:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.166.31