Skip to content

Commit 117fed9

Browse files
authored
Merge pull request #585 from go-redis/fix/bigger-pool-size
Scale pool size with number of cores since Redis connections are cheap
2 parents 7f0c3bc + c6944a8 commit 117fed9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

options.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"net"
88
"net/url"
9+
"runtime"
910
"strconv"
1011
"strings"
1112
"time"
@@ -54,7 +55,7 @@ type Options struct {
5455
WriteTimeout time.Duration
5556

5657
// Maximum number of socket connections.
57-
// Default is 10 connections.
58+
// Default is 10 connections per every CPU as reported by runtime.NumCPU.
5859
PoolSize int
5960
// Amount of time client waits for connection if all connections
6061
// are busy before returning an error.
@@ -91,7 +92,7 @@ func (opt *Options) init() {
9192
}
9293
}
9394
if opt.PoolSize == 0 {
94-
opt.PoolSize = 10
95+
opt.PoolSize = 10 * runtime.NumCPU()
9596
}
9697
if opt.DialTimeout == 0 {
9798
opt.DialTimeout = 5 * time.Second

0 commit comments

Comments
 (0)