What really is connection pooling?

后端 未结 6 969
灰色年华
灰色年华 2021-02-01 18:49

I have heard the term connection pooling and looked for some references by googling it... But can\'t get the idea when to use it....

  • When should i consider usin

6条回答
  •  生来不讨喜
    2021-02-01 19:05

    You should use connection pooling whenever the time to establish a connection is greater than zero (pretty much always) and when there is a sufficient average usage such that the connection is likely to be used again before it times out.

    Advantages are it's much faster to open/close new connections as they're not really opened and closed, they're just checked out/in to a pool.

    Disadvantage would be in some connection pools you'll get an error if all pooled connections are in use. This usually is a good thing as it indicates a problem with the calling code not closing connections, but if you legitimately need more connections than are in the pool and haven't configured it properly, you could get errors where you wouldn't otherwise.

    And of course there will be other pros and cons depending on the specific environment you're working in and database.

提交回复
热议问题