_Docs/
Get StartedModulesPlatformDeployCookbookChangelogReference
_Stack
_Modules
  • Ledger
    • Quick Start
    • Core Concepts
      • Accounts
      • Transactions
      • Constraints
      • Source/destination
      • Designing a Chart of Accounts
    • Working with the Ledger
      • Assets & Currency conversion
      • Bi-temporality
      • Bulk processing
      • Filtering queries
      • Idempotency
      • Data isolation with buckets
      • From credit/debit to source/destination
      • Streaming to analytics systems
      • Ledger Schema
    • Advanced Topics
      • Architecting for scale
      • Events Publishers
      • Performance model
  • Numscript
  • Connectivity
  • WalletsEE
  • FlowsEE
  • ReconciliationEE
  1. Modules
  2. Ledger
  3. Advanced Topics
  4. Performance model
Ledger

Performance model

When building an application on top of Formance Ledger that is set out for scale, it is important to understand the performance characteristics of the ledger. This document summarizes the cost model for each type of ledger operation.

Costs breakdown#

Request pattern (Ledger v1)Complexity model
Transaction commitO(N) + W
Aggregation • balancesO(Log(N)*M)
Point query • accountsO(1)
Range query • accountsO(Log(N))
Point query • transactionsO(1)
Range query • transactionsO(Log(N))

The complexity model is based on the in-process cost, and doesn't take into account the networking cost.

Data volume#

In the architecting for scale section, we outline different strategies to handle a growing volume of ledger data, with a focus on efficient usage of multiple ledgers.

Large Integer Values#

Formance supports storing very large integer values, which is particularly useful when working with cryptocurrencies or other high-precision numerical data.

Storage Capacity#

The Formance Ledger can store integers up to 131,072 digits in length. This is more than sufficient for handling cryptocurrency amounts like ETH or other use cases requiring high numerical precision.

JavaScript Integration Considerations#

While the Formance API and database can handle very large integers, you may encounter display or processing limitations when working with these numbers in JavaScript-based applications or tools. This is due to JavaScript's inherent number precision limitations.

If you're building integrations that handle large integers, you should either:

  • Use BigInt in JavaScript when available
  • Process the numbers as strings

API String Representation#

To handle large integers in various tools and SDKs, Formance provides an option to receive large integer values as strings instead of numbers in the API responses, using the Formance-Bigint-As-String: true request header.

The underlying data storage remains the same — this is purely a presentation layer option to ensure compatibility with different tools and frameworks.

Benchmarking#

Formance Ledger releases are tested against our load testing suite. The suite can be run locally by following the instruction in the repository.

Should you venture out common patterns and ledger architectures, you can customize the suite to have it fit the best your use case and bring the ledger into the least favorable cost-wise conditions.

Events PublishersNumscript
On This Page
  • Costs breakdown
  • Data volume
  • Large Integer Values
  • Storage Capacity
  • JavaScript Integration Considerations
  • API String Representation
  • Benchmarking