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.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of transactions

transactions

Related news:

News photo

Europe's largest city council: Oracle ERP allocated £2B in transactions to wrong year

News photo

DOJ says Apple’s ‘complete control’ over tap-to-pay transactions stops innovation, cements its monopoly

News photo

iPhone budgeting apps can now automatically import your Apple Card and Cash transactions