Skip to content
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

Multi-tenant solution with different eventStore / Database endpoints #697

Open
trancefreak77 opened this issue Oct 10, 2019 · 2 comments
Open
Labels

Comments

@trancefreak77
Copy link

@trancefreak77 trancefreak77 commented Oct 10, 2019

Hi,
We are developing a multi-tenant application by using your eventFlow framework. We plan to implement a multi-tenant feasible solution which means we want one instance of our application serve multiple customers/clients. Each customer wants to have their own/separate database server.

Do you have any input how this could be handled with eventFlow? As far as I know it is only possible to use one EventStore connection string per running instance (connection can't be switched). So all events of all different customers would end up in one EventStore instance.

Now if we need to replay events I don't see any chance to change the DBContext connection string while replaying.

I found this example how replaying could work:

public Task BootAsync(CancellationToken cancellationToken)
{
  
  var typeList = typeof(ReadModelRebuilder).Assembly.DefinedTypes.Where(type => !type.IsInterface && !type.IsAbstract && type.ImplementedInterfaces.Any(inter => inter == typeof(IReadModel))).ToList();
  typeList.ForEach(async x =>
  {
      await _populator.PurgeAsync(x, cancellationToken);
      await _populator.PopulateAsync(x, cancellationToken);
  });
  return Task.CompletedTask;
}

By using the IReadModelPopulator it is only possible to purge all readModels and then re-populate all events from the eventStore. All DB data would then end up in the currently configured database instance without the possibility to select the desired DB endpoint (per event).

Do you have any input/idea how your framework could handle such a multi-tenant setup with one running instance? Maybe switching the EventStore connectivity on the fly could help to route all events belonging to one customer to a distinct EventStore instance.

Thanks in advance,
Regards,
Christian

@trancefreak77 trancefreak77 changed the title Multi-client solution with different eventStore / Database endpoints Multi-tenant solution with different eventStore / Database endpoints Oct 10, 2019
@rasmus
Copy link
Member

@rasmus rasmus commented Oct 17, 2019

I think that would be rather hard to do properly with the current setup as I can't see how you would select the proper database connection and then how to ensure that in memory service configuration does not leak between tenants. Personally I world create a separate container instance for each tenant, it would remove a lot of complexity but might have scaling problems.

@rasmus rasmus added the question label Oct 17, 2019
@trancefreak77
Copy link
Author

@trancefreak77 trancefreak77 commented Dec 20, 2019

@rasmus I think I found a solution for the read side by exchanging the existing EntityFrameworkReadModelStore with our own implementation. The write side can be a single eventStore for all instances. But do you think there could be an issue if more than one instance writes into the eventStore? Could there be an issue with the AggregateSequenceNumber?

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.