text stringlengths 0 2.35k |
|---|
**Akshay Shah:** ...it's not quite as straightforward as it is with a simpler, more purpose-built thing like protobuf. |
**Jon Calhoun:** This conversation also reminded me of -- at one point in the past we talked about the JSON parser in the standard library, and it's not as fast to some third-party JSON parsers because, if I recall correctly, the JSON parser has to read the entire JSON object to verify that it's valid JSON first, and t... |
**Akshay Shah:** I believe that's right. |
**Jon Calhoun:** I'd have to go back and check though... But as a result, it means that it's not like the most optimal parser, whereas like when you mentioned the binary format, it's just assuming this is valid data, "We're gonna go ahead and use it." But it's worth noting that for most people that optimization isn't s... |
**Akshay Shah:** That's right. And you can get -- I mean, to be fair, as the author of a bizzaro custom JSON encoder... \[laughter\] It's not that hard to encode JSON much, much faster. Zap, the logging packager, part of why it's faster is that it has its own JSON encoder. And that's pretty easy, because JSON is a real... |
**Break:** \[25:52\] |
**Jon Calhoun:** So we've been talking about protocol buffers, which are how we're going to format the data. Generally, when this conversation comes up, you don't hear about protocol buffers on their own, you hear about protocol buffers and gRPC. So what is the gRPC part of this? |
**Akshay Shah:** So -- I mean, let's go back to our "We're building a REST API" example. So we're writing structs for our requests and responses. Other than implementing our business logic, what's the other work we're doing? Basically, what we're doing is we're designing a routing scheme. So you're saying, "Okay, I hav... |
These are all really low-rent decisions. In practice, I think, basically nobody cares. I just wanted to get my data, and most of my clients, if they're looking at any of this, they're upset. Like, "I just wanted you to hand me code to call this API." And these plumbing details are not all that interesting. So what prot... |
The inputs and outputs are all protobuf messages, and so in this world, I would write an interface and I would call it User Service, or User API. And it would have a function called get users. And that function would take a protobuf message with nice, strongly-typed arguments; I could have the organization ID in there,... |
So I need to write a struct with a get users method. And for the client, because all of this is really regular and predictable, it is easy to generate good code. What's the alternative? The alternative is something like Swagger. And Swagger, or OpenAPI, they are designed to be able to describe any REST API. And so you ... |
As a user, I think, especially a Go programmer, protobuf feels really familiar. I write some structs, I write some interfaces, I run a code generator, and then as a server, I'm just implementing an interface that looks just the schema I wrote. Life is pretty simple. And then you use an RPC runtime, like gRPC, you hand ... |
**Johnny Boursiquot:** Are there alternative runtimes other than gRPC? |
**Akshay Shah:** \[32:03\] Yes. Actually, from the episode on bloat, from a couple of months ago, Egon's company, Storj, it sounds like from their public blog post that they were using gRPC, and they were dissatisfied with a bunch of things about it... And so they wrote an alternate RPC runtime. It's called dRPC, and i... |
**Johnny Boursiquot:** Okay. |
**Jon Calhoun:** It's interesting to me that this is a problem that has -- there have been enough solutions to this problem that I think it makes it pretty clear that developers are like "Hey, this is a struggle." Even an example I can think of is - Mat was supposed to join us, but he couldn't... But Mat, whenever he w... |
**Akshay Shah:** Yep. |
**Jon Calhoun:** It was meant to be relatively simplistic, I think, and just support their needs, but it's interesting to me that even in those cases, people will go out of their way to build something on their own, when other solutions like gRPC do exist. So I guess my question to this is, why do you think people inve... |
**Akshay Shah:** I don't know. I mean, have you guys worked with gRPC? |
**Jon Calhoun:** I have not that much. |
**Akshay Shah:** Johnny's smiling. I think the answer is probably yes. |
**Johnny Boursiquot:** I have. \[laughs\] |
**Akshay Shah:** So Johnny, you tell me - are you whipping out gRPC Go for your personal projects? |
**Johnny Boursiquot:** I've kind of been to the place where -- I had to make that decision where I was like... Basically, the trade-off I was making in my head is "Look, I can go and try to wrangle something myself, or I can take something that is off the shelf and just accept whatever trade-offs that presents, but jus... |
**Akshay Shah:** Yeah. I guess start by writing a markdown parser, Johnny. It's the only way to start. |
**Johnny Boursiquot:** \[laughs\] I mean... If I just want to play around, and for educational purposes I just want to reverse-engineer something or build my own, just so I can educate myself and know how something works - yeah, that's fine. But if I'm trying to ship something? Heck no. I'm gonna go with what most peop... |
**Akshay Shah:** I think that's right. Yeah. I think a lot of people find themselves in that situation, right? There's only so many problems in the world that you're interested enough in to really peek under the covers and start digging around or writing your own stuff. I've never met Mat, or talked to him, but just ba... |
**Jon Calhoun:** I would imagine another aspect of this is that because it's a startup, when you release open source libraries and things that, it's kind of marketing... I think sometimes people ignore that aspect of like there needs to be marketing with a new business of any sort... So tech blog posts are a great way ... |
**Johnny Boursiquot:** You're accusing Mat of being a marketer... \[laughs\] And not a developer... |
**Akshay Shah:** \[36:06\] Let's not wave that brush around too wildly, okay...? |
**Jon Calhoun:** I mean, whether or not Mat was trying to, I can say for certain that he knows how to market to a degree, because his blog posts, whenever he starts a new company and things that, are all great marketing tools to help build a business. You have to do those things. If you just build something in isolatio... |
So I'm not saying that was his whole reasoning for it, but I'm saying that definitely could have played a role in it, is "Hey, this is something I'm interested in, it's pretty cool, and we can build it pretty quickly and use it as a marketing tool." So I think that's another factor to consider. |
**Akshay Shah:** I think there's -- you know, gRPC grew out of this internal system at Google that's called Stubby. And Google is protobuf all the way down. And internally, it's all run on this Stubby thing. And Stubby is not on top of HTTP, Stubby is like a competitor to HTTP. So it's protobuf-flavored HTTP/2, kind of... |
There were a bunch of ex-Googlers who had invented these things at other companies, but Google wanted the one that they thought was the right thing, and so they started a team and they built gRPC. gRPC is basically used at the boundary of GCP, but it's not running the internals of Google. It's this sort of bridging tec... |
The protocol is pretty simple. You could describe it in English in a couple of paragraphs. It's basically, given a protobuf schema, here's how you figure out the path, here's a couple of headers you have to set, and then here's how you take the bytes of protobuf and shove them into the body. That's it. It's not concept... |
I gave a GopherCon lightning talk just a couple months ago, we wrote an HTTP handler from scratch using the standard lib, that speaks gRPC in seven minutes. It's one slide of code. And so just like there are a million REST packages, and a million flag-parsing libraries, and a million different JSON libraries, there's r... |
I think just like you look around and like you're building an app, a CLI, and at some point you looked around and you said "Ah, am I a purist? Am I a standard lib flags kind of person? Am I a Cobra person? Or am I way out in left field and I'm using--", what's that company? "...charm bracelet, and glow, and likes fancy... |
**Johnny Boursiquot:** It does the job, right? |
**Akshay Shah:** \[40:15\] It does the job, and I it's small, and I kind of learned it once, and then I just decided that I didn't really care that much about this problem anymore. The same thing is true of Go. There's a Go specification, there's the standard Go compiler toolchain, but there's also Gccgo, and there's T... |
We didn't write NGINX and then just say "I don't know, everyone else just FFI into nghttp. Good luck." There's space for a gRPC implementation that maybe meets people who are writing rest APIs today where they are, instead of making trade-offs that are appropriate for a Google maybe, but not so appropriate for Pace. |
**Jon Calhoun:** So I suppose this is a good time to say that is what you guys are working on, correct? At Buf. |
**Akshay Shah:** Buf's working on a lot of things. I think I've alluded before, it's the idea that the tools for protocol buffers in open source are kind of rough. They're pretty low-level, and they're a little bit -- they have a big barrier to entry. So most of all, we're working on our protobuf tools. So Buf writes i... |
We also work on a schema registry. One of the important things about protocol buffers is that if you're using the binary format, you can't do anything with the data without the schema. So JSON - you can just shove it around, you can shove it into a Kafka topic, read it out the other end, and you're good to go. You don'... |
That's the business, is selling the schema registry. Our view is that, like you said, John, gRPC and protobuf are intimately connected. And for people to be really excited about using protobuf for everything, they kind of also have to be excited about using gRPC for a lot of things. gRPC does a lot of things super-dupe... |
So at Buf we work on this thing called Connect. It's a drop-in gRPC replacement. It's wire-compatible, works with every gRPC client, and it's all net HTTP. It generates HTTP dot handlers, clients use HTTP dot client, and it works with any mux, or any middleware package that works with net HTTP. So I think, to a Go prog... |
**Johnny Boursiquot:** \[44:40\] Gin... |
**Akshay Shah:** ...Julien Schmidt's HttpRouter, Gin or whatever. |
**Johnny Boursiquot:** gorilla/mux right? |
**Akshay Shah:** Yeah, any of those things, right? This just slots right in there. So your gRPC handlers plug in right alongside all your other ones. I think there's space for that, and I think it's nice. It's a tiny bit slower, just because it supports much more of HTTP than the gRPC stuff does. I don't think most of ... |
**Jon Calhoun:** Have you seen some of the new Go releases? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.