3 ms·
Show HN: Golang implementation of custom encoding in net/rpc vs. grpc.io
- stockkid 10y agoIt's refreshing to see how a simple switch in thinking can dramatically simplify the code and bring positive side benefits. You mentioned that a benefit of using grpc includes `net/context` which allows clients to send rpc requests to multiple machines and cancel the rest once one server responds. While such an ability can quicken the speed of response, would't it also waste server's resources? Now not one, but many servers have to do perform a task to win the 'contest' held by the client.
- mrjn 10y agoRe: server resource wastage. That's a great point -- and someone in Jeff Dean's talk asked the same question. So, the small optimization that he mentions is to send the query to the replica after 2ms telling it which server it was sent to originally. Similarly, tell the main server which replica would receive the query 2ms later. Then when one of them starts to process the query, they can directly tell the other one to cancel its execution. This trick would save a lot of repeated effort while still improving your query latency. For more, listen to Jeff Dean's talk mentioned on the blog.
- ashwin95r 10y agoAnother important point about sending the requests to different servers is that it reduces the tailing latency (higher percentile latencies) and the variance in latency