gomodule / redigo

Go client for Redis
Apache License 2.0
9.76k stars 1.25k forks source link

pool can support FIFO? #640

Closed yangtaoran closed 1 year ago

yangtaoran commented 1 year ago

Now the redis connection pool strategy is LIFO, popFront and pushFront. This will use less connection to do same thing, but others cannot be used. can support FIFO?

stevenh commented 1 year ago

Hi @yangtaoran could you clarify what you mean by

but others cannot be used?

The current pool design relies on LIFO to ensure that the minimum number of connections is used and that old unused connections are eventually cleaned up.

There is more of a discussion this draft PR #589

lvan100 commented 1 year ago

In a Redis proxy environment, any Redis connection will pass through the proxy. If one proxy is slow for some reason, the LIFO strategy will cause the slowest proxy to hold more connections. But the FIFO strategy would not cause such a problem. Reference https://github.com/redis/go-redis/issues/2350

stevenh commented 1 year ago

That's talking about hooks which is totally different. Not clearing down connections is a much bigger issues.

If you have one proxy is always slower that's an infrastructure issue you should fix. If it's only transitory is should rebalance over time.

If you really need to control over clean up you can use Pool.TestOnBorrow to do that.