-
-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for multi tenancy at documentStore level #435
Comments
How do you envision that being implemented? Are you thinking the DocumentStore would manage multiple connection pools? At the session level you might be able to have a "BucketId" which would be added to every document/event. NEventStore does this and uses the "default" bucket if one is not specified. |
I started a project similar to marten a few years ago, just it's not a framework, just an alternative implementation of ravendb IDocumentStore and IDocumentSession for the project i'm working on. It behaves the same way, so documentStore can access the whole sql db instance, and document session is opened on a particular database. What do you mean by connection pools ? AdoNet providers already implement connection pooling. |
I think an important question is multi-tenancy via database-per-tenant or shared database. Personally, my usage needs shared database, giving the ability to scale as needed, so I'd like to see the ability to apply a filter to all queries so ensuring tenant isolation can be done at the IDocumentSession level, kind of like the dynamic filtering in EF. |
@JohnCampionJr I think if you want to restrict it you would be better off to use row level security in PG. @valeriob How do you envision dealing with the multi-tenancy aspect within the document store, schema diffs, etc if you are isolating via database per tenant? |
@CoreyKaylor i'd leave it out of the library, you con use the same code running on different schema if they are backward compatible or just spin multiple instances of the application and upgrading the tenants incrementally. |
My thoughts on this this morning:
|
Alright, so let's assume that this does go into Marten itself. Here's my thoughts this morning:
|
I'd go the database-per-tenant way, it's more clean approach and in fact doesn't introduce "multitenancy" concept at all, only the extension points to make it possible. I think the most important yet completely sufficient API surface change would be adding a |
I can only speak for myself, but I've always used database per tenant on past projects so this is fine with me. I prefer the clean separation of data. Auto creating the database would fit in with same concept as auto creating tables etc, so yes. |
@migajek: I agree that it would be a really nice feature but as far as I know current connection implementation handling (inside @jeremydmiller: I think before Marten 2.0. it would be possible to add feature which would do 'ioc tricks' as you have mentioned. It'll use database per tenant approach. It can be some kind of document store registry which would be a singleton and would keep all already created tenant document stores (each tenant document store would be created only once). I'll try to add some POC of this solution. |
@pblachut IoC tricks and effectively a different DocumentStore per tenant where the only thing different is the connection string would definitely work today -- but it's gonna be a lot more efficient to do something more formal within Marten 2.0 to avoid having to create more than one copy of a lot of the underlying objects. I think the IoC thing would work fine if you had a relatively low number of tenants. |
One of the main advantages of using a "schemales db server" is that it makes multi tenant applications easier. To achieve that i think there should be an OpenSession ovarload that takes a database name as parameter.
The text was updated successfully, but these errors were encountered: