alkoofi
alkoofi

Reputation: 43

Synchronization across different systems

I have 2 systems let's call them i and j. Each have it's own database.

Each have a registration page, where a user is inserted in a user table.

What is the best way to synchronize both tables, where if any user registers at system i it will be also registered at system j.

Notes:

  1. I cannot read from each other databases directly.
  2. I can do small changes in the code if needed and it will not affect the system performance or natural behavior.
  3. I can create API's for both systems if needed.
  4. I can add any tables or fields if needed.
  5. I can create any cron jobs unless it will affect the performance of the system or server.
  6. I'm using cPanel.

Technologies:

  1. MySQL
  2. PHP
  3. REST API's

Upvotes: 0

Views: 37

Answers (1)

O. Jones
O. Jones

Reputation: 108706

The fact that you list as a technology shows you're working with an inflexible budget hosting vendor. So it's unlikely they'll cooperate in setting up background tasks (cron jobs) to merge your user tables behind the scenes. (cpanel isn't a technology: it's a system administration user interface provided by hosting vendors who don't trust their customers' skills.)

So. you should design and implement a REST API in the code of both your apps to perform user registration and authentication tasks. You didn't show us the details of your app, so it's hard to design it for you. Still it seems likely you'll have to implement these operations:

  • PUT user
  • DELETE user
  • GET user
  • POST user to validate a user's password, etc. (Don't use GET to pass secret information: GET request parameters go into server logs.)
  • PATCH to update details of a user.

If you get the API working, whenever you create/retrieve/update/delete user information in one app, you'll use the API to change it in the other.

Your best bet would be to create a third app just for user management, and have both your existing apps use it. That way you're sure to have one coherent source of truth about users. But you can do it just within two apps.

Upvotes: 2

Related Questions