2 ms·
You can use event logs and eventual consistency to solve this problem. Basically you make the transfer of money an event that is then atomically committed to a
by ah- 10y ago
You can use event logs and eventual consistency to solve this problem.
Basically you make the transfer of money an event that is then atomically committed to an event log.
The two bank accounts then eventually incorporate that state.
See http://www.grahamlea.com/2016/08/distributed-transactions-microservices-icebergs/ http://www.grahamlea.com/2016/08/distributed-transactions-mi...
But I agree that often life is easier if you just keep things simpler. If you require strong consistency like with the user/profile don't make that state distributed. If you do make it distributed you need to live with less consistency.
- erikpukinskis 10y agoIf we're talking about user created event, I think you should have a permanent log anyway. Otherwise if there is any kind of bug or any kind of weirdness in your data, how are you supposed to figure out what the heck happened? You can try to outwit chaos by prevent all inconsistency and bad data, but that'd a game you will eventually lose. From a more religious perspective, every action a user takes is sacred data that you should not lose, unless you deliberately want to lose it for privacy reasons. You can rely on your software to have no bugs and never confuse your user, but again that's a game you eventually use. I would rather keep that action log so I have a place to rebuild from when things are lost. Otherwise your only choice is to reverse engineer your data. Data which, if not technically corrupt, is corrupted from a human standpoint. And if you want undo you need a log and playback anyway. To me data consistency at the database level is not a real solution to the problem. It is a good tool, but it only solves a very narrow slice of predictable bugs. It doesn't help at all with the inevitable bugs you can't predict. A log based approach gives you a powerful tool in all kinds of tough situations.