Announcing new features for real-time, AI-assisted reconciliation. Learn more →

Learn

What is Concurrency Control?

Welcome to Learn, where we provide straightforward, easy-to-understand definitions of the payments industry.

Follow us

Concurrency, as defined by Merriam Webster, is two or more things capable of “operating or occurring at the same time.” In the context of software, concurrency control is the ability for different parts of a program or algorithm to complete simultaneously without conflict. Concurrency controls in a database ensure that simultaneous transactions will be parsed appropriately.

How Does Concurrency Control Work?

To look at a real-world example, imagine that Sally and Jenna are both shopping for the same dress. Sally lives in South Africa and Jenna lives in Canada, but they can both visit the same website at the same time–neither will be unable to visit the website simply because the other is looking at it, too. Sally and Jenna are also both able to view the exact same dress at the same time, put the same dress into both of their carts, and even check out and purchase the dress simultaneously.

The website is able to support both Sally and Jenna viewing the dress, carting the dress, and can also check inventory to ensure there is enough stock for them to both purchase the dress, concurrently and in real-time. If, however, there was only one dress left in stock, concurrency controls on the website would only allow the buyer who completed the transaction first to purchase the dress. Without concurrency controls on the website, it would be possible for an oversell to occur in the case that both Sally and Jenna tried to buy the only dress left in stock at the same time.

While this is an oversimplified metaphor for concurrency controls, it provides the general idea: multiple functions in a program need to be able to happen simultaneously without interfering with each other.

Why Does Concurrency Control Matter?

When using a database, concurrency control is important to ensure that more than one call can be made to the database at the same time without any adverse effects. In terms of companies using a financial ledger database, concurrency control is even more significant because it allows for multiple different financial transactions to occur at once.

Let's say we run a peer-to-peer payment app like Venmo, as an example. In this example, we’ll use Modern Treasury’s Ledgers API as a database for recording financial transactions.

If Lucy Ledger was to transfer $50 to John Journal, we'd create a ledger transaction to debit Lucy's account and credit John's. Ledgers uses double-entry accounting to ensure that Lucy's balance decreases by the same $50 that John's increases.

In this instance this is a straightforward transaction to track, since there was only one request to debit Lucy. But what if we had a situation where there were multiple, concurrent requests to debit Lucy's account? How can we ensure that her balance doesn't go negative?

A less direct solution would be to fetch the balance of Lucy's account to check whether there is a sufficient balance before actually attempting the debit.

Below are two examples of balance requests before attempting the $50 debit:

Examples of balance requests to demonstrate concurrency control

This solution works, provided that we can guarantee that a request to debit the account doesn't happen in between these requests. But there is no real way to make that guarantee.

To solve the problem of overdrawing Lucy’s account, we’d need to implement some kind of concurrency control method. (For a more detailed look at how Modern Treasury, specifically, prevents Lucy’s account from being overdrawn, read this article.)

To learn more about Ledgers, check out these additional resources:

Try Modern Treasury

See how smooth payment operations can be.

Talk to sales
More from

Learn

Learn topic image

Ledgers are foundational to any company that moves money at scale. Explore the accounting fundamentals behind the ledgering process, the differences between application ledgers and general ledgers, and more.

A chart of accounts (COA) is an index of all the different accounts within a company’s ledger.

Read more

A digital wallet (also sometimes called an electronic wallet) is an application that securely stores digital payment information and password data for a user.

Read more

A Ledger Database is a database that stores accounting data. More specifically, a ledger database can store the current and historical value of a company’s financial data.

Read more

Learn the difference between Single-Entry Accounting and Double-Entry Accounting

Read more

Data immutability is the idea that information within a database cannot be deleted or changed. In immutable—or append-only—databases, data can only ever be added.

Read more

In the context of software, concurrency control is the ability for different parts of a program or algorithm to complete simultaneously without conflict. Concurrency controls in a database ensure that simultaneous transactions will be parsed appropriately.

Read more

An API call is idempotent if it has the same result, regardless of how many times it is applied. Inadvertent duplicate API calls can cause unintended consequences for a business, idempotency helps provide protection against that.

Read more

A ledger API allows companies who need to move money at scale quickly and easily access, track, audit, and unify all of their financial data in one place.

Read more

The ledger balance, also called the current balance, is the opening amount of money in any checking account every morning. The ledger balance should remain the same for the duration of the day.

Read more

A ledger (also called a general ledger, accounting ledger, or financial ledger) is a record-keeping system for a company’s financial transaction data.

Read more

A subsidiary ledger is used to keep track of the details for a specific control account within a company’s general ledger.

Read more

Subscribe to Journal updates

Discover product features and get primers on the payments industry.

Subscribe

Products

Platform

Modern Treasury For

Case Studies

Insights

Documentation

Company

Legal


Popular Integrations

© Modern Treasury Corp.