1
0
mirror of https://github.com/redis/go-redis.git synced 2025-08-10 11:03:00 +03:00

Merge pull request #585 from go-redis/fix/bigger-pool-size

Scale pool size with number of cores since Redis connections are cheap
This commit is contained in:
Vladimir Mihailenco
2017-06-28 18:29:56 +03:00
committed by GitHub

View File

@@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"net" "net"
"net/url" "net/url"
"runtime"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@@ -54,7 +55,7 @@ type Options struct {
WriteTimeout time.Duration WriteTimeout time.Duration
// Maximum number of socket connections. // Maximum number of socket connections.
// Default is 10 connections. // Default is 10 connections per every CPU as reported by runtime.NumCPU.
PoolSize int PoolSize int
// Amount of time client waits for connection if all connections // Amount of time client waits for connection if all connections
// are busy before returning an error. // are busy before returning an error.
@@ -91,7 +92,7 @@ func (opt *Options) init() {
} }
} }
if opt.PoolSize == 0 { if opt.PoolSize == 0 {
opt.PoolSize = 10 opt.PoolSize = 10 * runtime.NumCPU()
} }
if opt.DialTimeout == 0 { if opt.DialTimeout == 0 {
opt.DialTimeout = 5 * time.Second opt.DialTimeout = 5 * time.Second