In this scenario.

  • I have an application targeting two countries, however same language.
  • The code is the same, at least, in this stage, can't predict the future.
  • Each country has an isolated database.
  • The distinction is made through the subdomain (e.g. pt.mywebsite.com)
  • Currently I am thinking about using the same code, and the same application instance for both countries.


  • I need to check always what is the subdomain by each request, and then set the correct database. This seem to be a bad practice.
  • Changes in code related with one country can break the another.
  • If i need to stop the machine or the webserver, then both countries will stay down.

The decision that i need to take, is, should i have two isolated apps, with isolated code, an isolated webserver, or should i use the same code and webserver for both countries?

  • Why do you say 'This seems to be a bad practice'? Commented Nov 26, 2016 at 5:19
  • 2
    What do you mean by "targeting two different countries"? Are those countries adminstrations your two clients, and you develop the same application for both? Or is this something like a web shop, developed for one customer, where visitors of the site are coming from two countries? If it is the latter, why is there a need to have two separated database at all? Please clarify.
    – Doc Brown
    Commented Nov 26, 2016 at 7:44
  • 1
    I still don't understand what are you trying to achive. I mean what's your real goal? Why do you need to split instances/db if is it the very same application, language and data model? Because the frontend?
    – Laiv
    Commented Nov 26, 2016 at 18:14
  • 1
    Then, maybe, you should edit the question and address it to that subject (scalability and distribution). Right now, looks like a question around multitenatcy.
    – Laiv
    Commented Nov 26, 2016 at 18:39
  • 1
    This is an XY problem. Honestly, if you want to get better answers, you should heavily edit your question and give a better description what you are really trying to achieve.
    – Doc Brown
    Commented Nov 26, 2016 at 18:50

2 Answers 2


Isolating the applications means that a crash in one won't bring down the other. However, it also roughly doubles the system administration work. If your code is robust and difficult to deploy, or has a lot of dependencies that would need to get updated and patched in production, then it probably makes more sense to maintain just one stack. If the code is not very robust, or deployment has been streamlined to the point where it is like installing an RPM, then it probably makes more sense to keep the applications isolated.


I don't see why would be a bad practice to change the database according to the domain. So some ways you could implement it are:

  • Dynamically changing configuration: Implementing a Configuration class with some properties like your connection string, and any other stuff that is going to change.

  • I don't like this one, but you could create a table in the same database for each language and change the table you are referring to according to the domain.

Of course this only works if the data in the two databases have different information.

If you're sharing between the two databases please comment to find a different approach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.