I am using rails 3.2 + unicorn + postgres DB and i have a question - how does unicorn handle DB connections ?
How I understand:
- unicorn master process forks X child process.
- each child process setup DB connection– close in before_fork, establish connection in after_fork.
- we use connection per process(if we use rails DB connection pooling, we create Y(from database.yml) DB connections per process) - i.e. If process is working(It always works until we not kill it) we keep connection opened and every web request use the same connection(that was opened in after_fork).
- opened connections will be shown in postgres(or any other DB) as idle or active.
Is it correct or I missed something ?