# Multiple connections and connection pooling in golang

**URL:** <https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093>\
**Category:** Users\
**Created:** [August 28, 2018, 4:41pm UTC](https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093 "2018-08-28T16:41:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![u007](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/u007/32/1220_2.png) [@u007](https://discuss.dgraph.io/u/u007)\
**Post date:** [August 28, 2018, 4:41pm UTC](https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093/1 "2018-08-28T16:41:07Z")

</div>

what is the best practice for dealing with handler in golang via dgo?

do i have to initiate respective grpc to server on every handler on my webserver?  
or do i initiate a grpc connection to server, and reuse the same grpc for multiple handler via dgo client?

sample code:

> <https://github.com/dgraph-io/dgo/issues/14>
>
> hi,
> 
> does this library support for connection pooling?
> do we need to initiali…se new client connection for every single client request?
> 
> how does transaction work? can we reuse the same connection for multiple client?
> 
> thank you

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [August 28, 2018, 6:27pm UTC](https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093/2 "2018-08-28T18:27:57Z")

</div>

You don’t need to create a new connection for every request. You can just create one connection, and use it for many concurrent requests.

---

<div class="post-metadata">

**Author:** ![u007](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/u007/32/1220_2.png) [@u007](https://discuss.dgraph.io/u/u007)\
**Post date:** [August 29, 2018, 9:45am UTC](https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093/3 "2018-08-29T09:45:34Z")

</div>

hi @mrjn

so i initiate a grpc on server, then

```auto
dgo.NewDgraphClient(...)

```

in handler?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/2b38fdece2abe5814f2e51bee69d1e67fc304b0a.png) [@system](https://discuss.dgraph.io/u/system)\
**Post date:** [September 28, 2018, 9:45am UTC](https://discuss.dgraph.io/t/multiple-connections-and-connection-pooling-in-golang/3093/4 "2018-09-28T09:45:34Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
