Answer the question
In order to leave comments, you need to log in
Am I designing the distributed system correctly?
Greetings colleagues. I want to take your design experience.
Now there is a DB, users and the data. Everything is stored in one place. Authorization and all functionality proceed as usual... Suppose there is a user., there is a notebook, there are entries in the user's notebook., there are categories of the notebook. The administrator can see (or maybe not, just an abstraction) all records in the system
. The customer wants to enter the New Market, where there is a requirement to store data on the servers of the country where the project will be launched.
In order not to violate the integrity of the project, and the control of the owners over the project, it is necessary that it be centralized, and the data in different countries should be nodes, but for the user and the owner it would look like an integral monolith.
There are two options:
First- run the existing project on a server in the country in which it will be launched. Then everything is simple., but it is already difficult to administer several such projects.
Add access control to this system to the server API (paid on / off), and several API endpoints for counting and statistics.
Second option. , Categorize users by project., using an identifier that will serve as a prefix of the Table in which the extended data will be stored. Add remote tables to the system from the north of the country where these tables will be stored (Postgres/ssh/hosting api)
I.e. When adding a user to the database from a new country, an empty user will be created, marked with a prefix in the main users table(e.g. gb). , also Tables (gb_users) will be added to the database, which will contain user data from another country, then the main admin will see the user with which access can be restricted, but the user data will be confidential and stored in an additional table (in another country).
When such a user enters the system, he will have a single near authorization., And the system, having seen the prefix, will know where to look for his data simply by substituting it when requested.
So I think to solve the problem of a single authorization system so as not to put them all in different databases, for this option.
About the same way to store data about the categories of notebooks and the entries themselves in notebooks.
Another moment when it will be necessary to calculate how many users are in the system, and how many notebooks they have, you will need to get all the prefixes in the system and generate a query that counts all users, all their categories and entries in the notebooks in the system according to tables with previously received prefixes.,
Colleagues., who had a similar case in design and development? Please evaluate if I am in the right direction, or direct me to the right term so that I can look somewhere else?
Thank you for understanding!
Answer the question
In order to leave comments, you need to log in
At the moment, it was decided to connect the tables hosted on the server of another country in postgres as a remote table (postgres_fdw)
). And through sharding by condition, add a certain label to existing tables. Then the main data will be stored as it should be, and the client data from a specific country will be stored in tables in the desired geo.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question