spring-cloud / spring-cloud-commons

Common classes used in different Spring Cloud implementations
Apache License 2.0
705 stars 700 forks source link

Multitenancy in Spring Cloud #20

Open joshlong opened 9 years ago

joshlong commented 9 years ago

after talking with a large financial services company that's building a SaaS offering, we discovered a few opportunities to better support multi-tenancy in a SaaS offering:

lejeunen commented 9 years ago

We are considering using the config server for our multi-tenant SaaS application, but have trouble finding an elegant way to do it with the actual state of the config server. Or maybe we are missing something, if so please tell us :)

Our application serves multiple customers, or tenants, and each of them have specific configuration.

Examples of tenant aware configuration are

With spring cloud config server, there are 2 options identified

In any case the client side cannot be used as-is due to its inability to dynamically set the label (option 1) or the application name (option 2).

Instead, a simple config client based on RestTemplate could be developed to get tenant aware configuration through the config server.

String getProperty(Principal principal, String key)

This means loosing the advantages of the standard config client, most notably its ability to refresh through @RefreshScope.

Any comment appreciated

dsyer commented 9 years ago

@lejeunen would you mind opening a new issue in spring-cloud-config for this, unless you feel strongly that it belongs in commons (I didn't see the connection)?

loryx636 commented 3 years ago

We are considering using the config server for our multi-tenant SaaS application, but have trouble finding an elegant way to do it with the actual state of the config server. Or maybe we are missing something, if so please tell us :)

Our application serves multiple customers, or tenants, and each of them have specific configuration.

Examples of tenant aware configuration are

* Structure of analytical levels

* Activation of optional modules (e.g. project, sales...)

* Configuration of widgets

* Injections to run and their configuration

* Emails of people to notify of various events

With spring cloud config server, there are 2 options identified

* A branch per tenant, specify it in the label part. Can use a list of labels to "inherit" standard properties, e.g. label=tenantXXX,standard. Another option is to git merge manually.

* A properties file with a different name, e.g. accounting-service-tenantXXX.properties. Inherit mechanism can easily be set up by using 2 variables : one for standard property (static), and another optional one for tenant specific (dynamic based on tenant).

In any case the client side cannot be used as-is due to its inability to dynamically set the label (option 1) or the application name (option 2).

Instead, a simple config client based on RestTemplate could be developed to get tenant aware configuration through the config server.

String getProperty(Principal principal, String key)

This means loosing the advantages of the standard config client, most notably its ability to refresh through @RefreshScope.

Any comment appreciated

Hi @lejeunen, I've read your comment, and I would like to ask you if you have found an elegant solution for the multi-tenancy on Spring cloud config. We have microservices that gather their config with a git branch for each tenant, because the config server is started on defined label. Came could it be possible to recover the configurations of the different branches dynamically, invoking the same config server?

I hope my English is not too bad, and my question is clear enough. sorry and thanks in advance.