TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

About Database Connection Pool Sizing

194 pointsby zyngaroover 6 years ago

8 comments

commandlinefanover 6 years ago
I did some profiling when I was working at one of the big online travel sites. We were running about 300 or so servers with a 50-connection pool each. After testing, we determined that at no time, ever, was more than one connection in simultaneous use across the server farm. We could have reduced it to a single shared connection per server and maintained the same QoS.
评论 #18439366 未加载
dlubarovover 6 years ago
Why is that Oracle instance using a max thread pool size of 2048 on a 12-core host? That seems like the real problem. Why not configure a smaller thread pool like cores * 2, and do more queuing on the server?<p>It seems wrong IMO to expect <i>clients</i> to tune connection pools based on how much concurrency they think a server can productively handle. The client doesn&#x27;t necessarily know how many cores the server has, or more importantly, how many other clients are connected.<p>In HTTP&#x2F;2, clients can configure a maximum number of streams (SETTINGS_MAX_CONCURRENT_STREAMS), and the RFC recommends setting it &quot;no smaller than 100&quot;. If servers worked on all pending requests concurrently, a value of 100 would be unreasonably large. But the implicit expectation is that servers will decide for themselves how many requests to process concurrently, and queue the rest. In other words, SETTINGS_MAX_CONCURRENT_STREAMS is intended to limit the server&#x27;s queue size, not its thread pool size.
评论 #18434777 未加载
wild_preferenceover 6 years ago
The other half of this is correctly using the connection pool in the application layer to begin with.<p>One of the most common performance errors I see in random http applications is grabbing db connections for too long, like in middleware, or too aggressively in parallel queries.
评论 #18433738 未加载
zrailover 6 years ago
Alternatively, and specifically for PostgreSQL, if you can live with pgbouncer&#x27;s constraints then you should be using it. It effectively self-manages an optimal shared connection pool for all of the application processes that connect to it.
评论 #18433349 未加载
exabrialover 6 years ago
Take time to peruse the rest of the Wiki; It&#x27;s chock full of information of performance tuning techniques. Absolutely fascinating.
lixtraover 6 years ago
See also [1]. The top comment there links to the article (2017).<p>[1] <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18220906" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18220906</a>
bullenover 6 years ago
Or you could use an async. db connection: <a href="https:&#x2F;&#x2F;github.com&#x2F;tinspin&#x2F;rupy&#x2F;wiki&#x2F;Fuse" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;tinspin&#x2F;rupy&#x2F;wiki&#x2F;Fuse</a>
thezviadover 6 years ago
This article would be better if it was called &quot;connection pool sizing for MySQL&quot;. If you had a better database, you would have to worry way less about configuring pool size on the clients.<p>The proper way to do this would be for the server (i.e. database) itself to have maximum active transaction limits and ways to setup quotas for different use cases, especially as your company gets large, and you have many different use cases mixed in the same database. Basically the queue should exist mostly on the server, and clients shouldn&#x27;t have to worry about overwhelming the server. If server queue gets large, server should start rejecting requests faster, and clients would do a backoff and retry with a delay based on that instead. This also makes sure server can&#x27;t be easily overworked if you have one misconfigured and misbehaving client.<p>Lot of issues with many idle connections in MySQL are specific to MySQL itself and its implementation. In MySQL the perf drops not only when you have many active transaction, but even when you have many just many connected idle sessions. This is why there are tons of different random &quot;MySQL Connection Proxy&quot; projects that exist in the open source.
评论 #18433427 未加载
评论 #18433627 未加载
评论 #18433248 未加载
评论 #18433190 未加载
评论 #18433116 未加载