Feb. 22, 2021
Here is the link.
I learned from Microsoft system design interview. As a software programmer, it is important for me to read a book, and then I can understand basic concepts for system design.
It is better for me to get some hands-on experience on websocket. I should read more articles before I move on other projects.
Here are highlights:
- bidrectional, message-oriented streaming of text and binary data between client and server - WebSocket
- The closest API to a raw network socket in the browser
- Not just a WebSocket connection, it is more
- Additional services: 4 of them
- Additional service: Item 1: connection oriented communication and efficient message framing
- Additional service: Item 2: Interoperability with existing HTTP infrastructure
- Item 3: Message-oriented communication and efficient message framing
- Item 4: Subprotocol negotiation and extensibility
WebSocket enables bidirectional, message-oriented streaming of text and binary data between client and server. It is the closest API to a raw network socket in the browser. Except a WebSocket connection is also much more than a network socket, as the browser abstracts all the complexity behind a simple API and provides a number of additional services:
Connection negotiation and same-origin policy enforcement
Interoperability with existing HTTP infrastructure
Message-oriented communication and efficient message framing
Subprotocol negotiation and extensibility
WebSocket is one of the most versatile and flexible transports available in the browser. The simple and minimal API enables us to layer and deliver arbitrary application protocols between client and server—anything from simple JSON payloads to custom binary message formats—in a streaming fashion, where either side can send data at any time.
However, the trade-off with custom protocols is that they are, well, custom. The application must account for missing state management, compression, caching, and other services otherwise provided by the browser. There are always design constraints and performance trade-offs, and leveraging WebSocket is no exception. In short, WebSocket is not a replacement for HTTP, XHR, or SSE, and for best performance it is critical that we leverage the strengths of each transport.
No comments:
Post a Comment