multi-user jdbc connection pool ( Spring-jdbc )

喜欢而已 提交于 2019-12-11 18:58:57

问题


We are using MS SQL Server 2012 and having a multi-tenant DB architecture for our cloud based solution. Multi-tenancy is designed as below

1.We have created views over our DB tables and as new organization registers into our application. 2.We create a database user and grants access to that user on view.

The problem here is, we are supposed to support 5000 organizations. Right now we have spring-jdbc and c3p0 connection pool.

Each JVM creates organization-wise data sources, each data source pools minimum of 5 connections and maximum of 20 connections.

Assuming we on-board all 5000 organizations, we might end-up short on connections or opening too many connections to the SQL server.

One of possible solution is to pool connections not based on organization user.

But c3p0 internally stores user based pools. I also looked at UserCredentialsDataSourceAdapter but this won't suffice my need.

Please share your thoughts and solutions

Thanks in advance!!


回答1:


Personally, I am not big fan for creating database user for each organization. There is no way you can use the same connection for different database user ( at least in my opn) . In that case you obviously loose the power of sharing connections.

Rather , I would create One Common user for all Org , since you are using same tables for all Org and creating wrapper ( view) on top of it to separate the data between the Org.

I hope you might have userid column in all tables and it should be indexed / partitioned by userid ( since you are creating views using that) .

I would end up in creating Master User table and foreign relationship with all base tables partitioned by userId.

And would add the userid filter condition in all the queries from application implicitly along with other conditions.

Or If you still wanted to have View, would end up with maintain the view - userid combination in application stack ( any form properties / database tables) and choose the view appropriate before firing query



来源:https://stackoverflow.com/questions/23636594/multi-user-jdbc-connection-pool-spring-jdbc

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