I have a Golang gRPC server I need to talk to from my Phoenix app. I was wondering what the best practice is to hold a single connection to the gRPC server for the entire app. Instead of each time having to create a new connection having a single “global” connection. Should I just create a genserver that holds this connection info? Or is there some mechanics in phoenix itself for me to accomplish this? Or just an overall more idiomatic “elixir” way to do this? Thanks!
Depending how is the Golang gRPC service written. If it can handle multiple clients at once, then you can take Ecto as an example and create connection pool. This will allow you to run N (where N is size of pool) parallel connections without worry about overflowing the server and time needed for establishing socket connection.
Yea the server can handle multiple connections. So what would you recommend the approach to be? Set up poolboy to handle the connection pooling and then every time I need to speak to the gRPC server grab an instance from poolboy and use that for my service?