GRPC and JSON
grpc.io
grpc.io
This wasn't in java, the environments themselves are different, the code is different, the benchmarking tool is different, etc, etc so maybe it's not applicable but it still stands that you should investigate whether it will really be worth it or not to invest in the tech if you optimize elsewhere. I mean, I've tried similar things with python and have only gotten 20-40k rps across various frameworks.
Please take everything above with a grain of salt and do your own research.
json library https://github.com/nlohmann/json
wrk, post with json payload via lua post script https://github.com/wg/wrk
Another important consideration are field names. If you use string field names, these take up more space and are more expensive to access (dictionary with string keys). Though compression and precomputed perfect hashing based dictionaries can mitigate those downsides surprisingly well. Simple integer keys like in protobuf are a bit cheaper to look up and more compact as well. And offset based approaches like capnproto can reduce those costs even further, though they come with their own limitations.
In general there are many good-enough solutions, but if you want the ideal solution you have to think about many details (zero-copy, single-pass write, random access read, human readability, extensibility etc.) with contradictory requirements on the format.
The trick is that it was a very simple XML format (Apache Lucene/SOLR), where each record was only one level deep and consisted of a set of tags of type, name and value.
The code was damn simple too. Something along these lines:
my %records
$content =~ /^.*?(?=<doc>)/gsmi;
my %r;
while ($content =~ m{<doc>(.*?)</doc>}gsmi) {
my $record = $1;
$r{$1} = $2 while $record =~ m{<(?:arr|date|str|bool|int|float) name="([^"]+)">([^<]+)</[^>]+>}gsmi;
$records{ $r{id} } = {%r};
}
I might have been able to find a solution that was faster by configuring an XML parsing library correctly, but I suspect data marshaling would have eaten most the gains. I probably could speed it up even more by combining the record start/end with the content parsing and making a state machine, but this is damn fast already and about as conceptually simple as you can get, which has it's own appeal.The moral is the same though, sometimes if your data is simple enough, you can easily beat industry standard solutions with minimal effor because throwing away their (for your case unneeded) flexibility can yield speed.
tbh I'm curious about how you did it because grpc / protobuf is highly optimized since it's the main target at Google.
I think HN title should be changed to either "gRPC + JSON" (the original title), or "gRPC with JSON", which is in the url.
That said if you want a systematic don't make me think approach for backward and forward compat I think protobuf/GRPC is the way to go you just need to learn a few rules for how to do it and you're set. In terms of static typing protbuf doesn't really get you that much because in order to get backward/forward compat you can't have required fields, so everything needs to be null-checked or have default values.