Skip to content

Pubsub Connection Pooling #785

@tpavs

Description

@tpavs

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions