Benefits of Pooling with Redis and Unicorn

Background: I have a Ruby / Rails + Nginx / Unicorn web application with connection to several Redis DBs (i.e. I do not use Redis.currentand instead use global variables for my different connections). I understand that I need to create a new connection in the block after_forkwhen a new working Unicorn is created, as described here and.

My question is about the need for pooling. According to this SO stream: β€œIn Unicorn, each process establishes its own connection pool, so if your db pool parameter is 5 and you have 5 Unicorn workers, then you can have up to 25 connections. However, since each worker is a unicorn can only handle one connection at a time, then if your application does not use threads inside, each worker actually uses only one db connection ... Having a pool size greater than 1, every Unicorn worker has access to connections that it cannot use but actually It will not open the connection, so it does not matter. "

Since I DO NOT use Sidekiq, do I even need to use connection pools for my Redis connections? Is there an advantage to connection pool with pool size 1? Or I just have to use variables with separate connections - for example. Redis.new (url: ENV ["MY_CACHE"])?

+4
source share
1 answer

A connection pool is only used when ActiveRecord is negotiating with the SQL databases defined in the configuration file databases.yml. This does not apply to Redis at all, and the SO answer you are quoting is not really relevant to Redis.

, - Redis, , Redis in Rails . , , , .

: ? . - ( /). , :

  • , , ,
  • ( ) after_fork, , , .
  • ( , - Sidekiq, , - ).

Redis , , , , - .

+4

All Articles