문제

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