Typical implementations of payment processing and related security issues
I had the experience of being part of a team in 2020 doing performance and safety analysis on Mojaloop [1], the open-source payments switch. The emphasis was mostly on identifying performance bottlenecks. For example, graphing waterfalls of database queries, estimating expected vs actual concurrency, digging into latency spikes, surprising timeout interactions, and missed group commit opportunities.<p>However, on the safety front, one of the most challenging issues was guaranteeing the rollback of funds in the event of failure as part of the two-phase commit protocol for moving money—coordinating this across multiple SQL queries, database transactions, Kafka queues, even multiple code repositories, especially as different systems experience clock drift or as disks or machines fail.<p>You want to ensure that the money either moves, or doesn&#x27;t move, that it doesn&#x27;t get lost somewhere in between. Yet most payment systems re-implement all this business logic on an ad hoc basis, again and again.<p>We therefore extracted these primitives from Mojaloop “once and for all” to create TigerBeetle [2], an open-source financial accounting database, that provides multi-AZ replication, automated leader election, and two-phase payments out-of-the-box.<p>Moving this business logic to the financial database layer opened up three orders of magnitude more performance, with TigerBeetle able to process a million transactions a second, all with an extremely high safety standard. For example, we do FoundationDB-style deterministic simulation testing, but with automated storage fault injection, such as 30% corruption on all replicas including the leader. Design docs, and links to talks are all in the GitHub repo [2].<p>Happy to answer questions from our experience, or chat if you&#x27;re working on similar systems!<p>[1] <a href="https:&#x2F;&#x2F;mojaloop.io" rel="nofollow">https:&#x2F;&#x2F;mojaloop.io</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;coilhq&#x2F;tigerbeetle" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;coilhq&#x2F;tigerbeetle</a> (Zig)