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.

Show HN: PgCat, Postgres pooler with sharding, load balancing and failover

233 pointsby levkkover 3 years ago

11 comments

levkkover 3 years ago
So I thought it would be kind of cool to take Pgbouncer to the next level. I&#x27;ve been using it with large database clusters for a while and it&#x27;s been spectacular, but it does have some limitations that always seemed arbitrary.<p>This is my take on what a modern Postgres pooler can be. Besides supporting same session and transaction pooling modes as Pgbouncer, it also adds support for load balancing between replicas (round robin at the moment), failover in case a replica fails a health check, and the coolest thing yet I think: sharding at the pooler level.<p>It&#x27;s written in Rust, which I think makes it much easier to iterate on and improve.<p>Note in case it wasn&#x27;t obvious: this is super experimental, please don&#x27;t use this in your production environment unless you&#x27;re adventurous. In which case, please do and let me know how it goes!<p>- Lev
评论 #30273501 未加载
评论 #30267741 未加载
评论 #30268989 未加载
评论 #30269353 未加载
montanalowover 3 years ago
As a fan of Rust, this seems like the perfect application domain for &quot;fearless concurrency&quot;. Having gone through the bowels of a few different connection pool implementations in various languages (because they had bugs in production), I can tell you the concurrency management becomes extremely difficult to reason about as the feature complexity increases. I think you&#x27;re making a good bet that offloading a good chunk of that to the compiler will improve your ability to iterate in the future.<p>GoLang seems like the language du jour, but I think this post [1] really illustrates how powerful it can be when you have a compiler that handles so much more for you. It&#x27;s not just about performance. Deadlock detection and a robust compile time set of error checks are huge wins over looser languages.<p>1: <a href="https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;some-mistakes-rust-doesnt-catch" rel="nofollow">https:&#x2F;&#x2F;fasterthanli.me&#x2F;articles&#x2F;some-mistakes-rust-doesnt-c...</a>
评论 #30268955 未加载
craigkerstiensover 3 years ago
This is really interesting and exciting to see. Though it probably has a ways to go before being production ready. We&#x27;ve seen to date a few other efforts at connection poolers and balancers in Postgres and every time come back to pgbouncer being the one that works best. While it has its issues, pgbouncer does indeed work. Others we&#x27;ve explored tend to break in unclear ways.<p>That said some of the things this one looks to solve are indeed very interesting.<p>I&#x27;ve seen issues at times with pgbouncer being single threaded. Since it&#x27;s only running against a single core it is possible to peg that core and have a max throughput. While not common we have seen this for customers before, both at Crunchy Data[1] on and back at Citus.<p>The other interesting piece is sharding. We considered this approach for years at Citus and never managed to pull it off. If you can specify a identifier and it can route accordingly it can give you a lightweight option for sharding really quite easily.<p>Again, probably has a ways to go, everything we&#x27;ve tried over the last 10 years has failed to live up to a replacement for pgbouncer. But pgcat is attempting to do I&#x27;m fully supportive of if it can accomplish it.<p>[1] On Crunchy Bridge www.crunchybridge.com we have pgbouncer built-in, with multiple pgbouncer support to alleviate single threaded issue.
jimmyedover 3 years ago
Alternative: yandex&#x2F;odessey<p><a href="https:&#x2F;&#x2F;github.com&#x2F;yandex&#x2F;odyssey" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;yandex&#x2F;odyssey</a>
评论 #30269840 未加载
评论 #30268691 未加载
mmontagna9over 3 years ago
This is great. Let me know how I can help
deknosover 3 years ago
1. rename the project, there&#x27;s already pgcat. 2. bring it to production level, i would love it :D 3. Are there things like gis or jsonb which would break with it, or does it just work?
jjiceover 3 years ago
I&#x27;m really impressed by how lean this code base is. Is PgBouncer also this lean? Looks like auth is the only thing left here then, aside from maybe some more testing? Very cool to see!
评论 #30274126 未加载
johncsover 3 years ago
You got a good laugh out of me with the meow in your description.
rory_isAdonkover 3 years ago
Anyone have a good way to understand Postgres a bit better?<p>So i can better understand sharding&#x2F;load balancing&#x2F;failover&#x2F;indexing etc.
everfrustratedover 3 years ago
This is so awesome.<p>For those wondering why a pooler is needed, Tl;DR containers. It&#x27;s much more normal to have hundreds of containers running an application configured to have tens of connections. Now you have thousands. Each connection costs postgres something on the order of ~2.5MB ram, so once you get into the thousands you&#x27;re starting to talk real numbers = ~2.5GB<p>Problems I&#x27;ve had with pgbouncer in the past:<p>- stats. Any modern tool should natively emit its own statistics in something like statsd format. - pgbouncer is a single process - I can&#x27;t throw more CPU cores at it to make it faster.<p>Problems that I&#x27;m still struggling to solve...<p>We use RDS&#x2F;Aurora which uses DNS to fail over. Yes applications should handle this. Yes they should retry. Yes devs should have tested this. But in any large company this is a uphill battle involving many teams and apps. Much easier to introduce a proxy layer to handle fast failover. Even better if it can re-try queries that fail transparently to the application.
评论 #30274226 未加载
评论 #30272589 未加载
vpprofitover 3 years ago
Postgres is the greatest.
评论 #30268755 未加载
评论 #30269009 未加载
评论 #30269315 未加载