title: MongoDB connection pool in Golang official driver
body: <p>I have two go files in project</p>
  
  <ol>
  <li>main.go</li>
  </ol>
  
  <p>This files creates http server and mongoDB connection and a method which will allow to reuse the connection using following</p>
  
  <pre><code>func ConnectMongoDB() {
  
      ctx, _ := context.WithTimeout(context.Background(), 30*time.Second)
  
      // user Connection database
  
      // Set client options
      clientOptions := options.Client().ApplyURI("mongodb+srv://localhost:27017/demo")
  
      // Connect to MongoDB
      userclient, err = mongo.Connect(ctx, clientOptions)
  
      if err != nil {
          log.Fatal(err)
      }
  
      // Check the connection
      err = userclient.Ping(ctx, nil)
  
      if err != nil {
          log.Fatal(err)
      }
  
      fmt.Println("Connected to user MongoDB!")
  
  }
  
  //GetMongoDBClient , return mongo client for CRUD operations
  func GetMongoDBClient() *mongo.Client {
  
      return userclient
  }
  
  </code></pre>
  
  <ol start="2">
  <li>query.go</li>
  </ol>
  
  <p>This file then define database and then fire query on it</p>
  
  <pre><code>client := GetMongoDBClient()
  
  collection := client.Database("demo").Collection("user")
  
  err := collection.FindOne(context.TODO(), filter).Decode(&amp;user)
  
  </code></pre>
  
  <p>When I fired 200 requests , i got email from Atlas saying that i have exceeded my 80 connection limit quota. How to make use of connection pooling here?</p>