How to ensure data consistency in a distributed system
0
votes
1
answer
230
views
I'm developing a distributed system with microservices with only one write-only database and the rest read-only in logical replication
My challenge is to have consistency in the data, especially in the balance that the client has in the account
Since my business model necessarily requires microservices to carry out updates to the database tables, and depending on the situation, a balance is added to the customer's account.
My question is, how to guarantee consistency of the customer's balance if he carries out some process that reduces his account balance at the same time that some microservice is also manipulating his account balance
I thought about creating a transaction in the database and immediately using this transaction to change its balance while the system finishes processing updates in other tables that are part of the process, as this blocks the reading of that customer's balance while the transaction is not completed. finished, is this the most correct way?
Asked by Miqueias Kevison
(750 rep)
Jan 2, 2024, 08:24 PM
Last activity: Feb 9, 2024, 11:52 AM
Last activity: Feb 9, 2024, 11:52 AM