Access same database from two different applications


I’m in the ideation phase of a project where I would have a common database and two apps with different purposes (but pointing to the same data).

My idea is to have one Postgres instance, and two VM instances (both hosting Remix). These two instances would connect to Postgres via Prisma.

Is this a correct setup? Am I unaware of issues I could face when hitting the same DB from two different points?

Especially when you know Prisma is pooling connections – I can’t figure out what would be the effect of two Prisma hitting the same DB…

Hi @binajmen

From the database’s point of view, there’s no difference between hitting the database from different points and multiple connections from one prisma pool. All connections are treated the same.

You should be more concerned about how your applications function as horizontal scaling requires different thinking to vertical scaling.

When running multiple servers/instances of your application there’s different considerations, for example session management should always store information with a source of truth (this could be postgres, redis, etc) and not store information only locally otherwise requests that come into server B won’t work because only server A knows that the session exists.

1 Like