Wednesday, 21 April 2021

Is it possible and plausible to implement a WebService over a WebRTC Data Channel?

Is it possible to implement a WebService over a WebRTC Data Channel ?

The idea is:

  • The client makes one https request to the server for signaling and session establishment
  • The client and the server start to communicate via a WebRTC DataChannel bidirectionally

Benefits?:

  • Performance ?
  • Requests goes over one connection and the standard allows for multiple datachannels over the same connection ( ports )
  • Flexible networking topologies
  • UDP
  • End to end encryption
  • The server can send events over the same connection
  • Load balancing could be implemented from a pool of servers client side without a load balancer , or all kinds of different solutions
  • Currently being debated the addition of DataChannels to Workers/Service Workers/ etc https://github.com/w3c/webrtc-extensions/issues/64

Drawbacks:

  • Application specific code for implementing request fragmentation and control over buffer limits
  • [EDIT 3] I don't know how much of a difference in terms of performance and cpu/memory usage will it be against HTTP/2 Stream

Ideas:

  • Clients could be read replicas of the data for sync, or any other applications that are suitable for orbit-db https://github.com/orbitdb/orbit-db in the public IPFS network, the benefit of using orbit-db is that only allows to the owner to make writes, then the server could additionally sign with his key all the data so that the clients could verify and trust it's from the server, that could offload the main server for reads, just an idea.

[EDIT]

I've found this repo: https://github.com/jsmouret/grpc-over-webrtc amazing!

[EDIT2]

Changed Orbit-db idea and removed cluster IPFS after investigating a bit

[EDIT3]

After searching Fetch PROS for HTTP/2 i've found Fetch upload streaming with ReadableStreams, i don't know how much of a difference will it be to run GRPC (bidi) over a WebRTC DataChannel or a HTTP/2 Stream

https://www.chromestatus.com/feature/5274139738767360#:~:text=Fetch%20upload%20streaming%20lets%20web,things%20involved%20with%20network%20requests).

Very cool video explaining the feature: https://www.youtube.com/watch?v=G9PpImUEeUA



from Is it possible and plausible to implement a WebService over a WebRTC Data Channel?

No comments:

Post a Comment