Skip to content

Commit

Permalink
define couchDB connection pool size
Browse files Browse the repository at this point in the history
FAB-17277 fix too many TCP connections between peer and CouchDB

Increase the connection pool size per host from 2 to 2000.
Also, increase the total connection pool size to 2000.

Signed-off-by: Senthil Nathan N <cendhu@gmail.com>
(cherry picked from commit 28c6efd)
  • Loading branch information
cendhu authored and denyeart committed Feb 11, 2020
1 parent b27a7c7 commit 9faad9e
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions core/ledger/util/couchdb/couchdbutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package couchdb
import (
"bytes"
"encoding/hex"
"net"
"net/http"
"net/url"
"regexp"
Expand Down Expand Up @@ -48,8 +49,20 @@ func CreateCouchInstance(couchDBConnectURL, id, pw string, maxRetries,
// and for efficiency should only be created once and re-used.
client := &http.Client{Timeout: couchConf.RequestTimeout}

transport := &http.Transport{Proxy: http.ProxyFromEnvironment}
transport.DisableCompression = false
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 2000,
MaxIdleConnsPerHost: 2000,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
}

client.Transport = transport

//Create the CouchDB instance
Expand Down

0 comments on commit 9faad9e

Please sign in to comment.