Aerie Database Architecture #494
Replies: 4 comments 6 replies
-
This is something I've had conversations with a bunch of people on the team about. Because this enforces all of the data be stored in the same PG instance, here are some thoughts to consider:
I don't think there's really a right or wrong way here, just need to identify and acknowledge the implicit/explicit tradeoffs. (Personally very much in favor of a shared PG instance for all of the Aerie data) |
Beta Was this translation helpful? Give feedback.
-
Two reasons for the current database architecture come strongly to mind.
A relatively minor additional point here (grouped with 1 above) is that customers may pick and choose pieces of the Aerie system to use, rather than taking it as one monolithic product. The UI has its own separate database (still, I hope) for the same reason -- it is a logically separate product that integrates with the core planning system. |
Beta Was this translation helpful? Give feedback.
-
Reviving this discussion as User Roles and Permissions and Tags has caused a need to reexamine the architecture of our database. Current arguments in favor of the DBs being decoupled:
Current arguments in favor of the DBs being joined:
Current arguments against the DBs being decoupled (Going to skip the ones derived from Points 1-6 of arguments in favor of the DBs being joined):
Current arguments against the DBs being joined:
|
Beta Was this translation helpful? Give feedback.
-
Based on our conversation yesterday, I see this issue like the following triangle, where we can only choose two of the three desirable properties (Developer eXperience, modularity (see dogfooding argument above), and performance). If we prioritize DX and modularity by building some external webhook that handles cross-cutting concerns like user permissions, we might take a performance hit as we move more logic out of the fast in-process postgres triggers / functions and into external processes that communicate over the network. If we prioritize modularity and performance, as is the status quo, i.e. keep databases separate, we take a hit on DX, which makes relatively simple relationships hard to express, since we lose the "relationship safety" that postgres would normally provide for us when we must go through the API for data from other components. If we prioritize performance and DX, i.e. by combining databases into one database with multiple schemas, we lose the modularity that aerie originally strived for, i.e. that each component could be deployed separately or switched out for e.g. a custom UI or alternative scheduler. I'm not sure what the best solution is for Aerie in general, but it does seem like each option has significant drawbacks in at least one category. Food for thought 🤔 |
Beta Was this translation helpful? Give feedback.
-
This issue lead to a discussion between @mattdailis, @camargo and myself about the architecture of our Postgres instance and why we chose to divide it into several databases as opposed to using several schemas within a single database. Since we will likely need to add schemas in order to have Hasura Authentication (or, further on, User Roles and Permissions), now is a good time to discuss if/how the current architecture should be changed.
Context regarding the initial discussion:
When a plan is created via the UI, a scheduling specification and an entry into
simulation
are created. When a plan is duplicated, a new entry intosimulation
is created as part ofduplicate_plan
, but no scheduling specification is created. Due toAerieMerlin
andAerieScheduler
being separate databases, it is impossible forduplicate_plan
to create this scheduling specification or forscheduling_specification
to "watch"plan
and create a new specification upon anINSERT
intoplan
without using additional Postgres modules, for example, Postgres Foreign Data Wrapper.@Twisol and @patkenneally, if you could share any reasoning behind the current database architecture that you remember (or of any places where that reasoning was previously documented), that would be helpful.
Beta Was this translation helpful? Give feedback.
All reactions