Does this have a distinct advantage over websockets, does it supersede it or is completely different?
To put it another way, could gRPC have worked via websockets (or maybe some long-polling fallback mode).
Does this have a distinct advantage over websockets, does it supersede it or is completely different?
To put it another way, could gRPC have worked via websockets (or maybe some long-polling fallback mode).
While HTTP/1.1 was a poor transport for high-perf RPC there are many parts of it that make sense semantically (headers, trailers, mime-types, virtual-hosting, content-encoding specification etc). HTTP2 lets you continue to use those in a form everyone is familiar with, with Websocket you would have to invent them again.
Websockets also have frames, binary or text.
More specifically this means that multiple WebSockets are not multiplexed over a single TCP/IP socket. One physical connection per-Websocket is a real scalability issue for servers and proxies.
WebSocket-over-HTTP would address that. See the options being discussed here http://tools.ietf.org/html/draft-hirano-httpbis-websocket-ov...
You want to multiplex websockets (for RPC) with normal HTTP requests -> Works through different URLs.
If you want to multiplex different websocket RPC services on a single websocket endpoint it's easy to do this on application level with some kind of service identifiers. You will probably want those anyway for some purposes - even if your transport layer also provides multiplexing.
Want to multiplex different websocket connections -> Works through different URLs. Yes, each will require a seperate IP connection. However I don't see a lot of applications that will go and utilize this scenario. They will either use gRpc OR WAMP OR SignalR OR etc, because that will make the maintainability much better then with a very mixed technology stack.
One of the major reasons for the existence of WebSocket is to support duplex streaming. HTTP/2 explicitly states
"A server can send a complete response prior to the client sending an entire request if the response does not depend on any portion of the request that has not been sent and received"
With better HTTP APIs (particularly in the browser) you would get full-duplex and the need for WebSocket would diminsh.
Or, now that I think of it, would the modern recommendation for this lean more toward opening multiple parallel Server-Sent-Events streams, with each channel being its own HTTP resource? That seems more idiomatic, at least.
Using separately addressable resources and having HTTP2 do the connection multiplexing for you seems like a good pattern to me.
I think this makes a major difference for RPC applications, because with a single connection you have a guarantee that all messages will be retrieved in the same order that they were sent.
E.g. with a persistent websocket connection I have the guarantee that all messages will be in order. With mulitple HTTP/1.1 requests I don't have it. Don't know about HTTP/2.
And of course the requirements about such a thing depend on how you design your RPC API (stateless or not).
gRPC maps calls to streams so calls can proceed at different rates, but you still receive the information on a particular call in order. So conceptually each call is completely separate, but we can use a single HTTP/2 connection for all the calls to a particular destination.