简体   繁体   中英

Reasons not to use database connection pooling?

I recently found an automatically created connection string specifying "Pooling=False" and wondered as to why it was set up like that. From my understanding pooling is virtually always advantageous as long as it is not totally mis-configured.

Are there any reasons for disabling pooling? Does it depend on the OS, the physical connection or the used DBMS?

Yes, there's a reason to disable pooling. You need to check how a particular pooling library copes with temporary network disconnects. For example some database drivers and/or pool libraries do nothing if connection was lost but connection object is still active. Instead of respawning a new connection, pool will give you stale connections and you will get errors. Some pool implementations check if connection is alive by issuing some fast command to the server before serving the connection to application. If they get error they kill that connection and spawn a new one. You always need to test your pool library against such scenario before enabling pooling.

原因必须是您的上下文正在尝试更改底层数据库的状态,例如,如果您正在做一些影响TLS(传输层安全性)的事情,则不应使用连接池,因为LDAP不会跟踪任何此类状态更改,如果你这样做是在妥协你的安全问题。

If it's a single threaded app, pooling seems unnecessary. Was it on a resource constrained device? Is startup time important to the application? These are some factors that might lead to the decision to turn off pooling.

In general, I think you are right that pooling is beneficial. If it's a typical web app then I would inquire about it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM