200 points · by ijidak · 3y ago · 167 comments
Feels that their problem may just be they went a bit too far on the microservices band wagon.
Does any developer here on HN really believe that JSON parsing (plus schema validation) is what adds the most latency to a request? It just doesn't add up that just switching to PB would deliver that speedup.
It reminds me of another headline I read a few years ago about a company thanking TypeScript for reducing bugs by 25% (I can't remember what the exact number was) after a rewrite... Common. You rewrote the whole thing from scratch. What actually cut the bugs by 25% was the rewrite itself. People don't usually write it more buggy the second time...
It's a pattern with these big tech consultants. They keep pushing specific tech solutions as silver bullets then they deliver flawed analyses of the results to propagate the myth that they solved the problem in that particular way... When in fact, the problem was solved by pure coincidence due to completely different factors.
If your cache is hot and has a good hit-rate, the majority of your overhead is likely parsing. If you microbatch 100 requests, you have to parse 100 requests before you can ship them to the database for lookup (or the machine learning inference service). If the service is good at batch-processing, then the parsing becomes the latency-sensitive part.
Note the caveat: the 60% is for large payloads. JSON contains a lot of repetition in the data, so you often see people add compression to JSON unknowingly, because their webserver is doing it behind their back. A fairly small request on the wire deflates to a large request in-memory, and takes way more processing time.
That said, the statistician in me would like to have a distribution or interval rather than a number like "60%" because it is likely to vary. It's entirely possible that 60% is on the better end of what they are seeing (it's plausible in my book), but there's likely services where the improvement in latency is more mellow. If you want to reduce latency in a system, you should sample the distribution of processing latency. At least track the maximal latency over the last minute or so, preferably a couple of percentiles as well (95, 99, 99.9, ...).
From the article:
> The result of Protocol Buffers adoption was an average increase in throughput by 6.25% for responses and 1.77% for requests. The team also observed up to 60% latency reduction for large payloads.
It's very sneaky to describe throughput improvements using average requests/responses (which is what most people are interested in) but then switch to the 'worst case' request/response when describing latency... And doubly sneaky to then use that as the headline of the article.
I've absolutely had times when json serialising/deserialising was the vast majority of the request time.
I don't believe that for the purposes of inter-service communication, REST/JSON can compete with protobuf.
Caveat: I only have experience with REST/JSON and a little GraphQL, I haven't had the opportunity to work with protobuf yet. I'm more of a front end developer unfortunately, and I try to talk people out of doing microservices as much as possible.
For example, in JavaScript, using standard 'for loops' with index numbers is a LOT faster (over 16 times faster for basic use cases) than using Array.forEach(), yet all the linters and consultants recommend using Array.forEach() instead of the standard for loop... What about latency??? Suddenly nobody cares about latency nor performance.
The reason is that these operations which use marginal amounts of resources are pointless to refactor. If a function call which uses 1% of CPU time* (to service a standard request) has its performance improved by 'a whooping' 50%, then the program as a whole will use only 0.5% less CPU time than it did before.
* (where all the other operations use the remaining 99%)
OTOH if there was a lot of pressure to get the rewrite done, that would be conducive to producing buggy code. I think management would be a bigger factor than any technical issues.
50k API endpoints means that probably a lot of them are pretty simple. The simpler the API, the higher percentage of it's time is spent in call overhead, which with JSON is parsing the entire input.
The article notes that this is only for "large payloads", likely an edge case, and the average performance improvement is 6.25% for responses and 1.77% for requests. 1.77%!
I get that this is "at scale" but is the additional complexity of all this engineering worth that? How much more difficult is the code to work with now? If it's at all more difficult to reason about, that is going to add to more engineering hours down the road to work with it.
I assume tradeoffs like this were taken into account, and it was deemed that a <7% response improvement was worth it.
Big Tech companies will often conflate micro service with large distributed system.
These services are by no means at all micro.
So number of endpoints can quickly grow to a big number.
What makes a service micro vs macro?
The real semantic fun begins when you have monolithic codebase/deployments that could do everything, but each instance gets assigned a specialized role it serves to its peers _ (I think I've seen someonevdescribing that approach somewhere). I'd consider that micro if there are more than a handful of "roles", perhaps with some qualifier, but it would hopefully be easy to agree than no description is entirely wrong.
If you're on v37 of a service and your forced to continue to support v1 (and 35 others) there's a problem somewhere.
So if you have an API with 10 endpoints, and one of them changes 10 times… you now have 100 endpoints.
Never tell them it's just because of all the technical debt you finally had organizational will to pay off.
To fix technical debt you often need a sexy sounding cover story.
What a plague of a company.
You give... random applications... access to your contact list?
I think web integrations have gotten locked down since then.. not for altruistic reasons, but because Google and Apple don't want to give Microsoft access to the data they have on you, so yeah, it's at least harder to accidentally give LinkedIn access to your contacts list now, but the damage has already been done for a lot of people
And to come back to the current topic, their app felt so bloated that I removed it.
Some people will be fine finding jobs without it, a lot won't be that fortunate.
I’ve literally never seen a LinkedIn only job for a field I was interested in let alone a job - but I don’t work biz/fintech.
This is certainly wrong because the usage of LinkedIn is very high. It's equivalent to saying, "I don't take recruiting calls from meat-eaters." I mean, if it's extremely important to you, go for it, but if not, you're doing yourself a disservice.
A cursory glance over the article leads to some references to P99 latencies dropping from around mid 20ms to around mid 10ms.
Those are irrelevant.
Does the 1% care if their requests take 10ms more to fulfill?
From the surface this sounds like meaningless micro-optimization. I'm glad someone got to promote themselves with this bullshit though.
So feature wise, there's profile page of each user, there's searching page with filters, there's inbox, some recruitment tools I'd imagine, job posting, apply to the job and such along with search and recommendations for that too plus analytics for each of the component above certainly there would be some internal advertisement management platform.
What else I'm missing? So 50 thousand endpoints for all that?
So, do they not compress requests between microservices? Otherwise, how did they see such a reduction?
When I was at MS, it was definitely preferred over protobuf. IIRC it was also used internally as the wire format for gRPC. I guess LinkedIn is still kind of doing their own thing.
The others I have no idea about though.
But based on the complete lack of activity on the issue, gRPC + bond doesn’t seem like a popular choice. :)
Also, wouldn't something like MessagePack, ION, RION, or CBOR give you payload compression over JSON?
One thing about protobufs in a highly interconnected ball of mess, good luck reving the protocol in any non trivial way. Schema-less encodings such as those you mention (as well as bson, etc) are really advantageous for loosely coupled interfaces and graceful message format migrations. IMO (opinion!) protobufs is popular simply because of the Google cargo cult where anything Google tech is slavishly adopted without a great deal of introspection on applicability to the specific situation.
Duh! Of course going from a verbose text format like JSON to _any_ kind of binary format will lead to decreased everything.
Second instinct was:
Wait, were they using HTTP/2, HTTP/3? What JSON parser were they using? One of the fast ones, or one of the slow ones?
Third instinct was:
There is not enough information in the article to conclude "60%" of anything. It's not an apples to apples comparison. It's just an attention-seeking headline.
Then again, if it wasn't an attention seeking headline, it probably wouldn't have made it to HN. ;)
At LinkedIn, we are focusing our efforts on advanced automation to enable a seamless, LinkedIn-wide migration from Rest.li to gRPC. gRPC will offer better performance, support for more programming languages, streaming, and a robust open source community. There is no active development at LinkedIn on new features for Rest.li. The repository will also be deprecated soon once we have migrated services to use gRPC. Refer to this blog[1] for more details on why we are moving to gRPC.
[0] - https://github.com/linkedin/rest.li
[1] - https://engineering.linkedin.com/blog/2023/linkedin-integrat...
> Based on the learnings from the Protocol Buffers rollout, the team is planning to follow up with migration from Rest.li to gRPC, which also uses Protocol Buffers but additionally supports streaming and has a large community behind it.
I liked avro better though.
Don’t do this, it’s a terrible terrible idea.
It's crazy, but worked.
But that's exactly the problem with protocol buffers. In typical Google fashion, they never bothered to create support for the native language of their platform: Kotlin. And that was just the one example we encountered on a project. If your language isn't supported by protoc, then what?
Also touted was protocol buffers' "future-proofing" or resistance to version changes. We never realized this alleged benefit, and it wasn't clear how it was supposed to be delivered.
I dreaded the opacity of the format, and expected decodes to start failing in mysterious ways at some point... wasting days or weeks of my time. But I have to admit that this rarely if ever happened. In our case we were using C++ on one end and Swift on the other.
I don't get this rationale in the article: "While the size can be optimized using standard compression algorithms like gzip, compression and decompression consumes additional hardware resources." And unpacking protobufs doesn't?
https://cloud.google.com/blog/products/application-developme...
https://developers.googleblog.com/2021/11/announcing-kotlin-...
1) Never change the type or semantic meaning of a field.
It's really that simple.
"Reason #2: Backward Compatibility For Free
Numbered fields in proto definitions obviate the need for version checks which is one of the explicitly stated motivations for the design and implementation of Protocol Buffers... With numbered fields, you never have to change the behavior of code going forward to maintain backward compatibility with older versions."