yorkie-team / yorkie

Yorkie is a document store for collaborative applications.
https://yorkie.dev
Apache License 2.0
783 stars 145 forks source link

Research connect-rpc #668

Closed hackerwins closed 10 months ago

hackerwins commented 2 years ago

Description:

There is an alternative to grpc-web called connect-web. We've been struggling a bit with grpc-web(not providing bidirectional, forcing Envoy, etc...).

The following might be considered together:

Let's research connect-web.

Why:

hackerwins commented 1 year ago

We have to look into it a little more, but it seems to be much more stable than before.

https://connectrpc.com/

krapie commented 1 year ago

This is very interesting. I never thought of a library that supports compatibility with browsers and gRPC. It seems like it supports most of the gRPC features, including bidi streaming without Envoy translation.

If we can introduce this library successfully with SDKs, we can achieve several performance advantages and mitigate the limitations of the current server structure.

krapie commented 1 year ago

I have ran some demos of ConnectRPC, and I could see that server and browser communicating well without the Envoy proxy.

But it seems like they have no plans to support bidi streaming on browser: https://github.com/connectrpc/connect-es/issues/419 The reason is that browser can support HTTP/2 but API for full-duplex is still limited.

Nevertheless, it is still a good alternative of gRPC-web since we can remove Envoy proxy and achieve several performance advantages.

hackerwins commented 1 year ago

Thanks for the research. We have SDKs and server. I wonder if we should replace them all at once or gradually one by one.

krapie commented 1 year ago

I think it will be good to introduce ConnectRPC on go server and JS SDK first, then introduce other SDKs so that we can test and benchmark while keeping compatibility with other SDKs.

ConnectRPC supports multiplexing of gRPC, gRPC-web, and Connect protocols, so there will be no problem if we replace go server and JS SDK first, then introduce to other SDKs.

go server and JS SDK will communicate with the gRPC-web protocol; meanwhile, meanwhile go server and other SDKs like iOS and Android will communicate with the gRPC protocol.

krapie commented 1 year ago

I made a PoC on branch connectrpc, and now yorkie server supports three protocols(grpc, grpc-web, connectrpc) simultaneously. 

I thought gRPC-web based yorkie-js-sdk could now communicate with connect-go based yorkie server without envoy, but it did not work.

This was because connect-go did not support grpc-web-text format that yorkie-js-sdk is using (connect-go only supports grpc-web format). Ref: https://connectrpc.com/docs/multi-protocol

So full PoC of connectRPC will be possible after I PoC on yorkie-js-sdk.

krapie commented 11 months ago

I have made PoC of yorkie-js-sdk as well, and it works perfectly. No Envoy, only ConnectRPC based yorkie client and yorkie go server!

Screenshot 2023-11-28 at 10 27 19 PM

I will soon open PRs for ConnectRPC migration in yorkie and yorkie-js-sdk.