What is the best way to setup your pool with respect to:-
- When do you create connections?
- When do you close connections, and would you close all of them?
- Do you test connections are still good. When and how?
- How do you figure out a good number for the maximum number of connections?
- What sort of monitoring do you have in place to ensure users of the pool are well behaved? Can you stop one bad piece of code from taking out everything?
- Have you written your own pool, or used a third-party library?
I believe this is an agnostic question, but comments about "features" of particular databases/languages are welcome. For example, it might be slower or more expensive to connect on some databases than others.
To clarify, I do not intend to write a pool from scratch, this question is more about how to configure an existing library that does pooling.