I have a Golang server which serve inbound requests with dedicated goroutine. Those goroutines would access another backend go server using rpc/gob. In case of reusing the connection to make Gob works better (requests sharing connection may reuse meta data without resending, also save time for TCP initiation), I'm thinking of implementing connection pool alike mechanism (like mysql client pool), but before that have I missed anything important?

Any Go specific way to handle such Shared RPC client? Or any project there built to handle this situation?

有帮助吗?

解决方案

See https://github.com/valyala/gorpc - this library goes further with RPC optimization - it uses independent read and write loops, message batching and compression. It also has much simpler API comparing to net/rpc .

Switching from http-based rpc to gorpc in a real production project allowed reducing RPC network bandwidth from 300Mbit/s to 24Mbit/s.

其他提示

After some investigation I found a pooling mechanism already been done in the built-in client lib, based on the code at http://golang.org/src/pkg/net/rpc/client.go , but I'm still interested if anyone can share with me more insights.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top