Live data from Hacker News

gRPC-Go Engineering Practices

grpc.io

51–60 of 85 posts

Re: gRPC-Go Engineering Practices

#51

Does anyone have experience with both gRPC and Thrift? I'd be curious to know how they compare.

I've used Thrift on a project in the past and one feature gRPC has that Thrift doesn't is the ability to use streaming semantics. This would have actually been very useful for the project I used Thrift on. If I were implementing it now I'd definitely use gRPC.

Re: gRPC-Go Engineering Practices

#52
post #36
post #31

Earlier quoted context omitted.

>Afraid I'm going to be contrary and old-fashioned and say I prefer JSON. history is completing full circle. Before JSON (HTTP REST) there was RPC. JSON was a new and shiny thing while the RPC was for the old-fashioned. The JSON took over exactly for all the great advantages over RPC that you listed (and a bunch of others) and despite all the advantages of RPC that people in this thread tout today as the gRPC advanta…

Uh, no. If anything, they are switching more workloads to Flatbuffers. Google does a lot of fleet-wide profiling and the encoding and decoding of protocol buffers, which were meant to be efficient, is NOT lost in the noise. Groups like the toolchain teams have a good idea of how many orders of magnitudes in cores are spent doing just that every second. Something like JSON would require probably tens or hundreds of mi…

Thanks, actually Flatbuffers looks very useful.

Re: gRPC-Go Engineering Practices

#53
post #29

Earlier quoted context omitted.

I fully agree, but want to point out that JSON can be compressed.

You're absolutely right. Auth0 shows that when compressed, protobufs don't provide a great benefit vs JSON. Something I've read from others is that gRPC is not the easiest thing to use directly in SPA. If you have services exposed to a web front end and mobile, double exposing a REST-ish API + gRPC might not be worth it. This is a problem with which I'm currently struggling. https://auth0.com/blog/beating-json-perfor…

I spoke to some of the gRPC folks at KubeCon/CNCon and the word is that browser support is in the works. There are some existing, slightly hackish ways to do it already but I'm confident that they will get it done properly.

It will be huge when that's a reality and we start building all of our APIs around protobuf.

Re: gRPC-Go Engineering Practices

#54

Has anyone found a good resource on using gRPC directly in a JS client? I've looked at using gRPC. My current challenge is that I want to support a website/webgateway on one side and mobile gateway on the other. If I use Swift or Java on the mobile side, it's easy. If I use Ionic Framework, I'm in the same spot as with the web gateway; probably better off with HTTP + RPC.

I wrote https://github.com/zang-cloud/grpc-json to solve this problem. It serves Golang GRPC methods as a JSON API, no configuration required.

Re: gRPC-Go Engineering Practices

#55
post #39

Earlier quoted context omitted.

> Also streaming that you can't do with regular REST Nothing about the REST architectural style prohibits a resource (or, rather, a particular resource representation) from being a stream.

HTTP/1.x will allow you to stream requests from the client. It'll also let you stream chunked responses from the server. But it won't let you do both simultaneously without going more exotic. Speaking from my own experience in Java, especially testing my gRPC/HTTP bridge[1], streaming is never overly easy with HTTP clients. You're usually just handed a byte stream to handle yourself. Streaming to the server from the…

Can't speak for Java but it was super easy in Go. I wrote some software for my home weather station and it streams [1] over gRPC to another little Go app [2] that runs on my laptop, wherever it may be.

My use is not at all complex but I can't imagine that more involved streaming would be any tougher.

[1] https://github.com/chrissnell/gopherwx/blob/master/storage_g...

[2] https://github.com/chrissnell/grpc-weather-bar

Edit: here's a simple example protobuf definition for streaming to a client: https://github.com/chrissnell/gopherwx/blob/master/protobuf/...

Re: gRPC-Go Engineering Practices

#57
post #29

Earlier quoted context omitted.

I fully agree, but want to point out that JSON can be compressed.

You're absolutely right. Auth0 shows that when compressed, protobufs don't provide a great benefit vs JSON. Something I've read from others is that gRPC is not the easiest thing to use directly in SPA. If you have services exposed to a web front end and mobile, double exposing a REST-ish API + gRPC might not be worth it. This is a problem with which I'm currently struggling. https://auth0.com/blog/beating-json-perfor…

Did you not finish the rest of the post? Yes, it's true that compressed json is not materially different in size vs protobufs. But when it comes to the speed of serializing and deserializing protobufs there is a huge gain across languages. So if you're using gRPC in backend environments you'll gain huge speed benefits.

Re: gRPC-Go Engineering Practices

#58
post #46

Has anyone found a good resource on using gRPC directly in a JS client? I've looked at using gRPC. My current challenge is that I want to support a website/webgateway on one side and mobile gateway on the other. If I use Swift or Java on the mobile side, it's easy. If I use Ionic Framework, I'm in the same spot as with the web gateway; probably better off with HTTP + RPC.

Does this work? https://github.com/grpc-ecosystem/grpc-gateway Seems to generate a REST proxy server side.

It does work, very well. We have been using it for over a year without issue. It is not ideal, but it is good to have an option for when clients dont support gRPC.

Re: gRPC-Go Engineering Practices

#59
post #2

Its a good time to ask, is gRPC any good? I'd love to standardize on stable middleware layer that handles multiple versions of clients and servers well. Rest with json really seems to work great for most things already. What is the advantage of gRPC - just more efficient?

My only regret is that when we started our current project, I did not commit 100% to gRPC, so now we have a mix of services. If I had of gone all in, it would be easier to integrate upcoming things like conduit [1], and I would not have to generate Swagger files but could just ship the proto files.

[1] https://conduit.io/

Re: gRPC-Go Engineering Practices

#60
post #28

Earlier quoted context omitted.

Academic discussion: wouldn't the "stateless" part of REST preclude using a stream that necessarily needs to keep track of state? Practical discussion: the biggest advantage of using REST is that you had a client readily available in pretty much every language. Most of those clients haven't been updated to deal with the HTTP/2 machinery necessary to drive streams the way gRPC does.

> Most of those clients haven't been updated to deal with the HTTP/2 machinery necessary to drive streams the way gRPC does. HTTP has supported streaming data for years, e.g. Server-Sent Events[0]. The short version is that you GET a URL, and the body keeps on arriving forever. I'm pretty sure that we had this sort of HTTP streaming back in the late 90s … I'll grant that many JSON-oriented pseudo-REST clients probabl…

Right, but server-sent events work only one way: from server to client. gRPC allows you to create bi-directional streams, where both the client and server are pumping data.

Chunked encoding allows to do something like what gRPC does, but it's my understanding (I might be wrong) that the data needs to be base64 encoded, whereas HTTP/2 supports raw byte arrays to be sent.

Post reply on HN