> What are the dual writes? I still don’t get t...
# platform-stories
r
What are the dual writes? I still don’t get the main point of it.
That’s a great one Dual-writes tend to be an “invisible” problem, until you see it, then you see it everywhere! Dual-writes means writing something twice, so let’s say you do an operation on the database, and then you have to send a message to a broker, or make an API call, etc. This process can look simple, however, if the second operation has to be data consistent with the first one, then how do you guarantee that? It’s oftentimes a second thought, but if you store to the DB and then the API call fails, do you rollback the transaction? And what if the application crashes in between the DB transaction and the API call? If you put them in the same transaction would you be creating an “idle in transaction” issue in your infrastructure? dual-writes can also be see as an “unknown cause for data inconsistency” It’s common we want thing to be consistent, and dual-writes is an invisible problem that might be causing data inconsistency in your platform, that’s a very common and dangerous one.
s
Okay, so the only matter here is the data inconsistency?
r
Yes, but this is an “umbrella” term, in reality it could mean: Item sold but stock is not updated Order is canceled but refund not emitted Data is stored but email never sent etc etc, anytime you need more than one system/store to cooperate you can suffer from it, so in many situations this could be a massive loss to the business
s
Thanks for your insights. Btw, a great article you shared
🙌 1