Monday, February 22, 2021

System design | Book reading | WebSocket | High performance browser networking | P'Reilly

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:

  1. bidrectional, message-oriented streaming of text and binary data between client and server - WebSocket
  2. The closest API to a raw network socket in the browser
  3. Not just a WebSocket connection, it is more
  4. Additional services: 4 of them
  5. Additional service: Item 1: connection oriented communication and efficient message framing 
  6. Additional service: Item 2: Interoperability with existing HTTP infrastructure 
  7. Item 3: Message-oriented communication and efficient message framing 
  8. Item 4: Subprotocol negotiation and extensibility 
Let me memorize the following statement about WebSocket: 
WebSocket is one of the most versatile and flexible transports available in the browser. The simple and minimum 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 stream fashion, where either side can send data at any time. 

arbitrary application protocols - simple JSON payloads, custom binary message formats - in a stream fashion 


I wish that those statements in purple color is part of my muscle memory. More hard work, please!

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