0

We have a current application written in grails 3, which we want to deploy for multiple different clients. The application and the database schema is the same for every client, only the data changes.

We don't want to have a single database because then we will need to rewrite sql queries, code will be harder to manage, indexes will get bigger etc.

We come up with 2 results:

  1. Defining multiple datasources. Each time a new client is registered, a new database should be created, and added (by a script probably) to application.yml. The client will login, and then ideally the datasource will be set at a single point of the code. (Which we haven't found yet a way to do it, on documentation it appears that it can be statically defined at each service). That way we will have one compiled application for all clients, with one database per client.

  2. Setting a different environment for each client. That means we will have one compiled application for each client and then use a folder based structure for deployment. (So that clients will use for example myapplication.com/clientid where the compiled application will be). Again a new environment and database should be created each time a new client registers.

The application is a b2b service so we are talking about tens or hundreds of clients.

EDIT

Which one of the 2 approaches would be better and why ? We would prefer to have one compiled application as it is easier to manage the deployment, but it doesn't seem to be feasible with grails to define dynamically a datasource based on the user logged in (Feel free to coreect me on that if i'm wrong). Thus it's important to have a structure of myapplication.com/clientid, which probably is easier to manage with different environments.

user666
  • 834
  • 2
  • 10
  • 20
  • what's the question? – practical programmer Mar 25 '16 at 14:17
  • @droggo Thanks i've done an edit ;) – user666 Mar 25 '16 at 14:24
  • Would using DataSource from JNDI defined on application server (like Apache Tomcat) solve your issue? In such case you have one WAR and define database connection in application server config on each installation. This implicates that each customer has it's own DB and Tomcat but you don't need separate compilation for each customer. – practical programmer Mar 25 '16 at 14:51
  • We are using AWS so according to them, it seems easier to bundle multiple war files (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-tomcat-multiple-war-files.html), i haven't seen something easy for deploying programmatically multiple tomcart servers (perhaps with cli), but it's also worth to check it as an option, thanks ! – user666 Mar 25 '16 at 15:06
  • @droggo Actually if it easy to define dynamically a datasource based on the user logged in, at a single place in the code, or by session, that would be great (and thus we would go with the first solution) – user666 Mar 25 '16 at 15:22

0 Answers0