2

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?

Jason Xu
  • 2,903
  • 5
  • 31
  • 54

2 Answers2

1

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.

valyala
  • 11,669
  • 1
  • 59
  • 62
  • Though the built-in pool is simple and sufficient for me and may have more official support, I am still very interested to try this one. Thanks, @valyala – Jason Xu Mar 02 '15 at 03:37
  • https://ehsun7b.wixsite.com/golang/blog/simple-yet-functional-cli-chatroom-developed-in-golang-rpc – ehsun7b Oct 26 '18 at 23:31
0

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.

Jason Xu
  • 2,903
  • 5
  • 31
  • 54