From 9acf745fafce8e547ea3a83c192e7e70fa1c6e91 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 28 Jun 2017 18:20:26 +0300 Subject: [PATCH] Scale pool size with number of cores since Redis connections are cheap --- options.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/options.go b/options.go index dfda7df3..d3ea254b 100644 --- a/options.go +++ b/options.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "net/url" + "runtime" "strconv" "strings" "time" @@ -54,7 +55,7 @@ type Options struct { WriteTimeout time.Duration // Maximum number of socket connections. - // Default is 10 connections. + // Default is 10 connections per every CPU as reported by runtime.NumCPU. PoolSize int // Amount of time client waits for connection if all connections // are busy before returning an error. @@ -91,7 +92,7 @@ func (opt *Options) init() { } } if opt.PoolSize == 0 { - opt.PoolSize = 10 + opt.PoolSize = 10 * runtime.NumCPU() } if opt.DialTimeout == 0 { opt.DialTimeout = 5 * time.Second