Score:0

Disconnecting postgres proxy for many connections to single database

gw flag

We're currently looking into how we could scale a system in which we have many users, each with their own postgres schema, and their own DB user credentials to ensure isolation. This however means that each user will effectively need their own connection to the database, and since the number of concurrent open connections to a postgres server is fairly limited due to the memory overhead for each connection on the server we are looking into potential solutions. pgBouncer would have been nice to use and multiplex multiple incoming connections to a fixed connection pool to the actual database, however we were unable to confirm that the user isolation based on user credentials and database schema can be mapped to that scenario.

The user sessions, and therefore the connection lifetime, have a duration of a couple of minutes, but are not heavily used (single DB transaction with associated burst of queries every couple of seconds), and the queries are not latency sensitive, so we could technically disconnect between transactions and reconnect on demand, with a proxy such as pgBouncer keeping the connection state. Speaking of state, the application does not make use of named prepared statements, so the server side state is likely not large anyway, but being a cloud hosted database we also cannot easily modify the max_connections config on the server.

Is there a way to map this scenario to pgBouncer or a similar proxy?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.