we want to make the fastest one way stream message flow between two devices. so we check different comparison.

check different communication protocols

HTTP, WebSocket, gRPC or WebRTC

  • TCP and UDP:
    • TCP (Transmission Control Protocol) : A connection is first established before data exchange, and uses error correction to ensure message deriveray.
    • UDP (User Datagram Protocol) : connectionless (does not require a connection), data can be losted, but faster.
  • HTTP/1 use TCP (built to handle long-lived connections to transfer large data), open short-lived TCP connections and usually only send small pieces of data.
  • HTTP/2 was designed to address the shortcomings of the original HTTP protocol (HTTP/1.1) and to improve performance.
    • use of multiplexing to simultaneously send and receive multiple HTTP requests and responses over a single TCP connection.
    • All HTTP/2 connections are persistent, and only one connection per origin is required.

family-graph

  • WebSocket two-way, handle real-time data. effectively run as a transport layer over TCP. provides a lot of freedom compared to HTTP/2.
  • Server Sent Events (SSE) are efficient over HTTP/2 and simple to use : the server unilaterally pushes data to the client.
  • gRPC RPC framework uses HTTP/2. uses protocol buffers to make it cross language friendly.
    • It can be complicated to set up compared to WebSockets.
  • WebRTC can make direct peer-to-peer connections.
    • low latency and a lot of data.
    • but connection establishing is complicated. and it needs to be a way for two peers to discover each other.
  • WebTransport a potential replacement for WebSockets. Using WebTransport, github c++.

grpc benchmark

Comparing gRPC performance across different technologies:

family-graph

grpc stream sync vs. async