Postgraphile: Question: Multiple postgraphile instances in individual processes, sharing one database.

Created on 2 May 2019  ยท  9Comments  ยท  Source: graphile/postgraphile

I'm submitting a ...

  • [ ] bug report
  • [ ] feature request
  • [x] question

PostGraphile version:
N/A

Please bear with me, I am very new to Postgres and Postgraphile.

I am working on an application consisting of several micro-services, all pointing to one common Database. Each service needs to have its own roles, so that one service should have minimal access to other's data. Each service can share some data/functions to other services.

From what I have read up so far, Postgraphile + Postgres combo looks really promising for this scenario.

Each service has it's own pg schema to store it's data and functions. I wanted to know would it be possible to give each service it's own postgraphile middleware to access the DB? Is postgraphile designed to support this mode where several different postgraphile instances are sharing one DB, each having different level of access? I haven't read anything in the documentation suggesting that this is not possible, but I wanted to confirm and also get an opinion whether this is a good approach.

Or should I run another service which has postgraphile and all other services call this service to access their data/functions?

Also, does Postgraphile store any housekeeping data in the database? If yes, where can I read about it? I'd need to understand how this could be managed in the shared setup.

Thanks in advance.

โ” question

Most helpful comment

image

It's not much.

All 9 comments

Assuming you don't use watch mode or live queries, PostGraphile does not modify your database and thus the different instances of PostGraphile will not be aware of each other and should not interfere. PostGraphile does not store any housekeeping data. PostGraphile is designed to live in harmony with other things accessing the database at the same time, including other instances of itself.

This should be fine :+1:

Awesome, thanks for the super fast help @benjie! So, what's the impact of watch mode and live queries on this?

Also, what's your opinion on having individual postgraphiles vs running one shared server?

Thanks!

So, what's the impact of watch mode

Watch mode: not recommended for production. We install the watch schema when PostGraphile starts, so the different postgraphile are going to probably overwrite each other repeatedly. We can improve that.

and live queries

I'm not sure. You might want to set up a shared LDS server; see the Live queries docs at graphile.org

Also, what's your opinion on having individual postgraphiles vs running one shared server?

I prefer a single PostGraphile for simplicity and performance. Each to their own though :)

Thanks, I owe you several ๐Ÿบ for your help @benjie!

Bung a few dollars in my Patreon ๐Ÿ˜‰ https://www.patreon.com/benjie

image

It's not much.

Awesome โ€” thanks so much, everything helps! ๐Ÿ‘ ๐Ÿ™ ๐Ÿš€

Hope you don't mind this one time contribution. I wish to become a full time patreon, just working to get my stuff together atm.

Iโ€™m grateful for all contributions; if you cannot sustain contribution at that level, feel free to drop to a lower level as youโ€™ll still get access to most of my Patreon posts then, or of course you can stop at any time ๐Ÿ™

Was this page helpful?
0 / 5 - 0 ratings

Related issues

james-ff picture james-ff  ยท  4Comments

angelosarto picture angelosarto  ยท  3Comments

giacomorebonato picture giacomorebonato  ยท  3Comments

ssomnoremac picture ssomnoremac  ยท  5Comments

CarlFMateus picture CarlFMateus  ยท  4Comments