Re: Multi tenancy : schema vs databases

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Rakesh Kumar <rakeshkumar464(at)outlook(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multi tenancy : schema vs databases
Date: 2016-10-01 18:39:25
Message-ID: CAMkU=1yPHhGn+cq4C-t8ax9DL62AHwUMWT=mBZN4zYQFy-AirA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Sep 29, 2016 at 12:18 PM, Rakesh Kumar <rakeshkumar464(at)outlook(dot)com>
wrote:

>
> Hi
>
> I would like to know which technique is better for supporting
> multi-tenancy=
> applications, going upto hundreds or even thousands of tenants.
>
> 1 - One database with difference schemas (one schema per tenant)
> or
> 2 - One database per tenant.
>
> The points to be considered are:
>
> 1 - which is more light weight from resources point of view.
>

Multiple databases used to be more resource intensive, but that was mostly
fixed in 9.3. Now I don't believe there is all that much difference while
running (databases are much more heavy to create in the first place).

As others have said, different databases makes connection pooling less
efficient, which could be very important to you, or could be irrelevant.

> 2 - which is easier for backup/restore
>

That depends on how you want to backup restore. If you use log archiving,
it will make no difference. If you use sql dumps, then do you want to make
it easier or harder to backup and restore all clients together, or all of
them separately? Are you restoring because your whole system failed, or
because one client did something wrong and needs just their data rolled
back?

> 3 - Which is better from security p.o.v
>

Any implementation can be done wrong in a way that causes security
problems. Do your clients authenticate directly to the database, or to the
app server?

Cheers,

Jeff

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rakesh Kumar 2016-10-01 19:52:00 Re: Multi tenancy : schema vs databases
Previous Message Tom Lane 2016-10-01 18:01:31 Re: [GENERAL] pg_upgrade from 9.5 to 9.6 fails with "invalid argument"