Home > OS >  Postgres architecture for one machine with several apps
Postgres architecture for one machine with several apps

Time:03-03

I have one machine on which several applications are hosted. Applications work on separated data and don't interact - each application only needs access to its own data. I want to use PostgreSQL as RDBMS. Which one of the following is best and why?

  1. One global Postgres sever, one global database, one schema per application.
  2. One global Postgres server, one database per application.
  3. One Postgres server per application.

Feel free to suggest additional architectures if you think they would be better than the ones above.

CodePudding user response:

The questions you need to ask yourself: does any application ever need to access data from another application (in the same SQL statement). If you can can answer that with a clear NO, then you should at least go for separate databases. Cross-database queries aren't that straight-forward in Postgres, so if the different applications do need a lot of data from other applications, then solution 1 might be deployment layout to think about. If this would only concern very few tables, then using foreign data wrappers with different databases might still be a better solution.

Solution 2 and 3 are more or less the same from the perspective of each application. One thing to keep in mind when deciding between 2 and 3 is availability. Some configuration changes to Postgres require a restart of the service. Is an outage of all applications acceptable in that case, even though the change was only necessary for one?

But you can always start with option 2 and then move database to different servers later.

Another question to ask is if all applications always use the same (major) Postgres version With solution 2 you must make sure that all applications are compatible with a new Postgres version if one of them wants to upgrade e.g. because of new features that the application wants to use.

CodePudding user response:

Solution 1 is stupid : a SQL schema is not a database. Use SQL schema for one application that have multiple "parts" like "Poduction", "sales", "marketing", "finances"...

While the final volume of the data won't be too heavy and the number of user won't be too much, use only one PG cluster to facilitate administration tasks

If the volume of data or the number of user increases, it will be time to separates your different databases on new distinct PG clusters....

  • Related