Get the latest tech news
Distributed transactions in Go: Read before you try
In the previous post, I looked into running transactions in a layered architecture. Now, let’s consider transactions that need to span more than one service. If you work with microservices, a time may come when you need a transaction running across them. Especially if the way they are split was an afterthought (the unfortunate but likely scenario). Service A calls service B, which calls service C, and if something goes wrong at the end, the system becomes inconsistent.
The best we can do is log the error and fire an alert so someone on-call can manually add the discount for the annoyed customer. If in doubt, stick to a single service and decouple your code using modules — the modular monolith approach. The idea is that the data (the user’s points and applied discount in our example) stays consistent but no longer within a single transaction.
Or read this on Hacker News