Вопрос

Is there any reason to maintain a pool with more than one connection when running a single-process, single-threaded application?

Это было полезно?

Решение

No. Unless you use non-blocking evented IO.

Другие советы

I can think of 2 reasons to use pool:

1, if the application access to database (open, read, then close connection) frequently, like 100 times or more every second, using the pool, the connection between the pool and the real db is maintained by pool, the pooled connection is not actually close/open, then the performance of the program is improved.

2, In the scenario the application use a "global connection", open once at the beginning of the application, close at time of exit. If the application takes long time to execute, like 10 hours, then it is possible that the connection is disconnected for some unknown reason (intermittent network issue?). By using pool, the pool will re-connect to db automatically? Is it possible? At least, when creating several connections in the pool, at the unfortunate event that one connection is down, the next connection will be used for the application.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top