-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
So I am trying to understand if and how connection pooling for this pubsub client is working.
I am using this test script
package main
import (
"flag"
"fmt"
"github.com/go-redis/redis"
)
var redisAddr = flag.String(
"redis-caches",
"redis-cache:6379",
"comma separated list of redis caches",
)
func main() {
flag.Parse()
client := redis.NewClient(&redis.Options{ Addr: *redisAddr })
for i := 0; i < 100000000; i++ {
client.Subscribe(fmt.Sprintf("S%d", i))
println(fmt.Sprintf("Subscribing to %d %d", client.PoolStats().FreeConns, client.PoolStats().TotalConns))
}
}
It appears to me like the pool just keeps allocating connections.
I also tried setting it up where I do a Subscribe() and then just use the returned pubsub value which appears to work but that means that basically all traffic will go through 1 connection to redis. Ideally I would like to be able to use N connections to redis but have that N be limited on each box to make sure that I don't drown redis or starve the box of connections. Is this not possible?
I saw this old issue #459 which discussed this and there was a test in previous versions. The test in question appears to be mia on master/in the 6.12.0 release. Should I be building against that release or should I drop back to v5?