Postgres connection pooling - multiple users

核能气质少年 提交于 2021-02-08 03:10:04

问题


In order to secure our database we create a schema for each new customer. We then create a user for this schema and when a customer logs in via the web we use their user and hence prevent them gaining access to other areas of the database.

Our issue is with connection pooling as it is a bit inefficient to keep creating/dropping new connections for these users. We would like to have a solution that can work across many hundreds of different database users.

We've looked at pg_bouncer, but the issue here is that we have to create a text record in an ini file for each user and restart pg_bouncer every time we set up a customer. This is not a great solution.

Is there an alternative solution that works in real time and would mean a customers connection/connection(s) would stay in the pool whilst they were active?


回答1:


According to the latest release notes pgbouncer might actually do this. But I haven't tried.

Pooling mode can be configured both per-database and per-user.

As for use case in general. We also had this kind of issue a while ago. We just went with connection pooling with one user/database and multiple schemas. Before running psql query we just used SET search_path TO schemaName. As for logging, we had compliance mode, when we could log activity per customer and save it in appropriate schema.



来源:https://stackoverflow.com/questions/32249813/postgres-connection-pooling-multiple-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!