We have a multi-tenant web app, using subdomains to designate tenants and all tenants running in the same database. The web app is a 3-tier app, the front end is a single page app(SPA), the back end is a REST API server and the database(MySQL).
So far it works well but now we have a new requirement to set up and maintain 2 versions for our web app. The main reason is that not all tenants want to use the our latest version, some prefer the "stable" version (i.e. the old one). This is a business decision not a technical one. My job to design a technical solution to make it work.
I face some technical difficulty. For example, when a client sends the first GET request of the SPA (say, typing the url of the SPA in the browsers) how do I send him the correct version in response? When we have a new version if tenant1 wants to use it while tenant2 want to use the old version , when tenant1.mydomain.com request is sent to my SLB (nginx), how does nginx know to forward the request to the server host the latest version.
It is not a fixed rule that tenant1 always want to use the latest version and tenant2 always want to use the old version, then I can just write the rule like following.
# It is not the case that tenant1 always wants to use the latest version
server {
listen 80;
server_name tenant1.mydomain.com;
location / {
proxy_pass http://latest-version-server:80;
}
}
server {
listen 80;
server_name tenant2.mydomain.com;
location / {
proxy_pass http://old-version-server:80;
}
}
Every time we have a new version we need to decide which tenant will use it. A less elegant solution is to find out which tenant(s) always wants to use the old version, hard-coded them while the rest tenants use the latest one.
How have others accomplished this?
BTW, How to do REST API Versioning, e.g. like Best practices for API versioning? is related to my question but it is a different one.
I searched SO and only found this one Azure Web Sites - multiple versioned deployments similar to my question.