This page is for discussing ways in which we can accommodate multiple projects using same sensors without duplicating data.
Approach 1- Aggregation and Filtering on backend
- Have the backends make requests between them and filter the data in the backend before returning to geodashboard.
- The api returns aggregated data from own database and data recieved from API requests to other projects
...
draw.io Diagram |
---|
border | true |
---|
diagramName | Approach A |
---|
simpleViewer | false | width |
---|
links | auto |
---|
tbstyle | top |
---|
lbox | true |
---|
diagramWidth | 491 |
---|
revision | 1 |
---|
|
...
draw.io Diagram |
---|
border | true |
---|
diagramName | Approach B |
---|
simpleViewer | false |
---|
width | links | auto |
---|
tbstyle | top |
---|
lbox | true |
---|
diagramWidth | 411 |
---|
revision | 2 |
---|
|
...
draw.io Diagram |
---|
border | true |
---|
diagramName | Approach C |
---|
simpleViewer | false |
---|
width | links | auto |
---|
tbstyle | top |
---|
lbox | true |
---|
diagramWidth | 481 |
---|
revision | 3 |
---|
|
How:
Scenario: Project A needs to show all datapoints of a source in Project B.
- Partition the Project B database tables on sources. i.e. datapoints is partitioned into datapoints_sourceX, datapoints_sourceY.
- Queries can still be run on the main datapoints table returning data for all the sources
- Create a partition table in Project A's database `datapoints_sourceX`.
- Use foreign data wrapper to connect `datapoints_sourceX` partition table to Project B's datapoints_sourceX table.
- Now, all the data of datapoints_sourceX will be available in datapoints table on Project A as well without it being copied into Project A database.
Drawbacks:
- Will require restructuring the database schema.
- The databases on each machine will have to be exposed so that they can communicate. Currently, they are only accessible on the machines locally.
Link for more information:
https://www.percona.com/blog/2019/05/24/an-overview-of-sharding-in-postgresql-and-how-it-relates-to-mongodbs/
https://pgdash.io/blog/postgres-11-sharding.html