Learn how to design and scale your Formance Ledger implementation for optimal performance
O(N) + W
. Let’s consider the following example:
@payments:1234
by $99.00, sourcing the funds from three user accounts before defaulting @world
as the source of last resort. Let’s break down the operations that will be performed:
@users:1234:main
@users:1234:main
was less than $99.00, read the balance of @users:1234:vouchers
@users:1234:creditcard
@users:1234:main
O(1) + W
and at most O(3) + W
. This is because the transaction will need to read the balance of at least one account, and at most three accounts, and then commit the computed transaction to the ledger.
When optimizing for write throughput, it is important to keep in mind this cost breakdown and to design your transactions accordingly.
users:1234_main
Implemented instead as users:1234:main
, the latter will enable the ledger to efficiently query all accounts of a given user by using the users:1234:*
wildcard or all accounts of all users of a given type by using the users:*:main
wildcard.