News for hackers. Stuff that matters.
Re:ArangoDB: Multi-model highly available NoSQL database by thdxr on Wednesday January 16, 2019 @07:01PM (#18926944)
Postgres' inability to handle multiple concurrent queries on a single connection makes it a pain when using it for multi-tenant services. With all the SAAS companies out there I'm surprised this issue doesn't get brought up more often
Re:ArangoDB: Multi-model highly available NoSQL database by doh on Wednesday January 16, 2019 @07:11PM (#18927036)
I'm not sure it's that critical. You can use connection pooling on client and/or you can outsource it to a proxy/bouncer that will do this for you.

We have tens of thousands of connections and no problems. We also forked pgbouncer to use multicore [0] which allows us properly utilize servers.

[0] https://github.com/Pexeso/pgbouncer-smp

Re:ArangoDB: Multi-model highly available NoSQL database by thdxr on Friday January 18, 2019 @08:53AM (#18939266)
PGBouncer doesn't do anything to magically prevent connections to postgres from being locked and idle for a pending query.

It's just an external connection pooler when your native language driver doesn't have a good one

Re:ArangoDB: Multi-model highly available NoSQL database by doh on Friday January 18, 2019 @11:29AM (#18940414)
pgb can timeout connections and close them if they are idle for too long, which is usually the way to deal with stale connections.

Not sure what solution are you imagining would be the right one.

Re:ArangoDB: Multi-model highly available NoSQL database by thdxr on Sunday January 20, 2019 @03:08AM (#18951842)
Examine any other distributed system that implements pipelining. Allows for multiple pending requests on a connection (simply by having IDs on every request) which makes for efficient use of connections.
Re:ArangoDB: Multi-model highly available NoSQL database by doh on Sunday January 20, 2019 @03:50PM (#18955492)
I do understand where are you coming from, but there is price to everything.

Most distributed systems have eventual consistency. Very few can achieve strong consistency. Postgres sacrifices a lot for a strong consistency and predictable performance.

I'm not saying that PG has the best model, but for the wast majority of users, out of connections is just not an issue. Most clients have now direct pooling and they are very easy to setup. There are a few who need more connections, but there are poolers for it.

What you gain but separating connections is much easier monitoring and debugging process. You can examine each connection, its impact on resources, state, what locks they need to acquired, ...

Additionally, because each connection opens a file descriptor, you gain a lot of operating security from the underlying OS and its kernel.

PG contributors spent almost 3 decades building on this system. I'm pretty sure the gain would be so minuscule in comparison to the effort that would have to be put in to rebuild the connection model.

I for one would appreciate server polling built in, better HA including simple discoverability, handoffs, ...

Re:ArangoDB: Multi-model highly available NoSQL database by ahachete on Thursday January 17, 2019 @05:36AM (#18929749)
That's really cool! But why don't you contribute back this code to pgbouncer? :)
Re:ArangoDB: Multi-model highly available NoSQL database by doh on Thursday January 17, 2019 @02:40PM (#18933858)
Oh, we tried. Believe me, we tried many times. Original pgb creator didn't bother to respond to any of my emails.
Re:ArangoDB: Multi-model highly available NoSQL database by zbentley on Wednesday January 16, 2019 @08:55PM (#18927640)
That's because connections (sessions, really, but in practice most things map those 1:1) are the primitives on which Postgres and most other RDBMSes divide their units of transactional consistency--one of their key guarantees. Connections are expensive to create and maintain largely (but not entirely) because of those properties.
Re:ArangoDB: Multi-model highly available NoSQL database by thdxr on Friday January 18, 2019 @08:51AM (#18939255)
This isn't a required design to achieve transactional consistency. See for example how this would be done in Erlang - single connection dispatching to isolated Erlang processes.

Fundamentally just needs isolation to be done at a different layer.

Re:ArangoDB: Multi-model highly available NoSQL database by andrewstuart on Wednesday January 16, 2019 @07:08PM (#18927007)
Why not just open another connection?
Re:ArangoDB: Multi-model highly available NoSQL database by chatmasta on Wednesday January 16, 2019 @11:14PM (#18928331)
Each open postgres connection requires about 10mb of memory overhead IIRC
Re:ArangoDB: Multi-model highly available NoSQL database by grumpydba on Thursday January 17, 2019 @02:07AM (#18928950)
That's why you need a connection pool. That's true for all database systems.
Re:ArangoDB: Multi-model highly available NoSQL database by cbsmith on Thursday January 17, 2019 @02:37AM (#18929063)
Not all databases systems require a connection pool, though it is often a good idea.
Re:ArangoDB: Multi-model highly available NoSQL database by grumpydba on Thursday January 17, 2019 @03:04AM (#18929162)
I disagree. I've faced incidents on oracle/sql server/postgres/sybase instances when several hundreds of connections where spawned.

You definitely need to think about pooling fro the beginning of the design of your application.

Re:ArangoDB: Multi-model highly available NoSQL database by cbsmith on Thursday January 17, 2019 @04:37AM (#18929516)
Yes, all of those databases allocate query memory for queries at connection time, and consequently don't scale efficiently for large number of idle clients. That's not all databases. Some don't do that. Some don't even do connections period.

Connection pools are a necessary work around for a specific design decision with the system software. They can be helpful other problems as well, but they aren't necessarily a requirement.