socketry / async-redis

MIT License
83 stars 18 forks source link

Strange behavior with Rails and Pool connection_limit #20

Closed woto closed 5 years ago

woto commented 5 years ago

Hi! Don't know if i am wrong or not. I made example repo https://github.com/woto/async-redis-test It has slightly modified example of pub/sub https://github.com/woto/async-redis-test/blob/master/app/controllers/test_controller.rb Also i added output for current subscribers listeners_count. During testing with wrk i see almost 50 subscibers (then their amount decreases and then again increases up to 50). Shouldn't connection be closed? Even if not, shouldn't their amount up to connection_limit? Thanks.

woto commented 5 years ago

Hmmm, this change leads to correct closing connections https://github.com/woto/async-redis-test/commit/93c76d3baa3918116be6c7d118fc4dfcaf3b3c07

ioquatix commented 5 years ago

The connections are cached. Connections which are in use (i.e. in a transaction context) will not be used by other tasks/requests. We could implement high and low water marks to close connections (i.e. only keep a limited number of unused connections). But right now this isn't done. You shouldn't need to worry about idle connections unless you are literally exhausting some kind of resource limit.