p5-RedisDB / RedisDB

Perl extension to access Redis
22 stars 11 forks source link

Question about connection pooling under Apache mod_perl #38

Open hightowe opened 3 years ago

hightowe commented 3 years ago

Hi -

This is not an issue, per-se, but rather a question... Conceptually, I think that we would like to connection pool with RedisDB under Apache2 mod_perl, akin to how we connection pool to our database servers with DBIx::Connector. Am I correct about that and, if so, what is the proper way to connection pool with RedisDB under mod_perl? Or, am I simply overthinking trying to connection pool to Redis...?

Thank you,

Lester

trinitum commented 3 years ago

when you connect to say postgres, it makes sense to have multiple connections so you could run multiple queries in parallel. Every connection to postgres means that there's a dedicated process on the server side that handles exclusively that connection. With redis you have a single process on the server side handling all the connections, so generally it doesn't make sense to create multiple connections, with RedisDB you can issue multiple commands in parallel using a single connection and set callbacks that will be called upon receiving responses. If you fork, then RedisDB automatically establishes a new connection to the server. One case where you might want a pool of the connections is if you might have the same process working with multiple transactions at the same time.