4

I am developing a Web Application using sails.js as the back-end. The app will be used by different schools and my first approach is to deploy for each school an instance of the application.

Example:

school1.application.com having an instance of sails app on school.application.com:8080 school2.application.com having an instance of sails app on school.application.com:8081

Each instance have a Bitbucket repository (or branch) and the source is updated using Git.

For maintenance purpose, I was thinking of using a dashboard connected with all the Git repository and manage all push from there.

On the other hand, it is more manageable to have only one instance for all the school but how do I used a separate database for each one ? Using one DB is not too risky when having about 20 schools ?

Using the second approach, if the application is down, all the schools will be affected as opposed to the first one.

I hope I was clear in my explanations.

Thank you for your insights.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
JDL
  • 231
  • 4
  • 16

1 Answers1

1

Where the sails app will be hosted? By you? i.e. Nodejitsu, Amazon, etc. Or the app will be deploy on the school server?

  1. approach: If you'll host the app, you can make one app and deploy once. Add the schools as models and create a relationship between all your users. i.e.:

    // Student.js model
    
      module.exports = {
    
        attributes: {
    
          name : { type: 'string' },
    
          lastname : {
              type : 'string'
          },
    
         // School which the student belongs
         school : {
           model : 'school'
         }
    

And this way you just make one api to rule them all, and give your customers one single URL with logging access. You can use mongo or a SQL because Waterline don't care about your db, just build a good relationship between your models. Check the waterline and models docs: https://github.com/balderdashy/waterline-docs/blob/master/associations.md

  1. approach: You can make a deploy independently for every school, and use just one DB to rule them all, but be sure to avoid the risk to wipe all data every time you do a deploy, sails will ask you if you want to wipe all de data in the db or ALTER the data (be careful with this because is an experimental feature).

  2. approach: Deploy your branch independently with their own DB (if the school will host the app this is the best approach), and just change the config/connections.js for every deploy. This approach is the best if you don't want to shutdown all your users when you need to do maintenance or implement customs features, but you'll need to work more, because you'll going to maintenance 20 instances separately.

I recommend you the 1st approach.

Ytzvan Mastino
  • 123
  • 1
  • 10
  • Thank you for your detailed answer. The app will be deployed on a cloud server. – JDL Aug 20 '14 at 11:23