vapor / redis

Vapor provider for RediStack
MIT License
459 stars 58 forks source link

connection pooling #84

Closed tanner0101 closed 6 years ago

tanner0101 commented 6 years ago

Allow connections to be pooled and re-used.

John-Connolly commented 6 years ago

I think pooling would only be useful with pub/sub or blocking commands, which is probably not the most common scenario. It would be nice if this was opt in, so it doesn't exhaust connection limits on cloud providers.

jdmcd commented 6 years ago

Exhausting connection limits on cloud providers is actually what I was worried about. I use Redis to store session tokens and I don't my whole massive setup to come down just cause the caching service is out of connections (and is only used on session lookup). I see what you're saying though. I'd love to see a middleground

tanner0101 commented 6 years ago

Maybe we can have it configurable such that if you set max connections to ‘nil’ it will just create a new connection each time. Note also the connection pooling is for the KeyedCache impl. Creating a Redis client manually will not be affected by this.

Joannis commented 6 years ago

I don't see a reason to pool redis connections since they support pipelining. There's little to no performance gain. Actually, I think it'll worsen the performance very slightly.

John-Connolly commented 6 years ago

Yeah the only way I see it being useful is for blocking commands. I believe blocking commands put the client in a blocked state and the client is unable to send or receive other commands until that blocking call returns or times out.

Joannis commented 6 years ago

I agree, but we don't support blocking operations in the Redis Client. We have a separate static method for setting up a blocking client for pub/sub.

John-Connolly commented 6 years ago

I see, creating a new RedisClient instance for those commands makes more sense anyways. The only problem I see is there is no way to send commands before subscribe is sent, like AUTH or SELECT for instance.

tanner0101 commented 6 years ago

Fixed by #95