- A → N: one source balance funds many destination balances at the same time.
- N → A: many source balances fund one destination balance at the same time.
- A → B and B → A: the same two balances move funds back and forth at the same time.
- Using the queue
- Coalescing
- Lock wait timeout
- Hot-lane routing
Using the queue
For high traffic or overlapping balances, we recommend using the default queue-based flow (skip_queue: false).
The queue helps Blnk handle contention more effectively and reduces the chance of lock errors by allowing retries, hot-lane routing, and coalescing. Learn more: How Queueing Works.
Note: Lock contention can still happen in queued processing. Workers also acquire distributed balance locks when applying transactions.The difference is that the queue gives Blnk more ways to manage that contention and lower the likelihood of lock-related failures.
Coalescing
Available in version 0.14 and later.
A → N or N → A.
With Coalescing, Blnk identifies the queued transactions based on if they share the same source, destination, and currency, batches them in-memory, and applies them in a single commit.
This reduces the number of balance lookups and commits required, improving throughput and performance overall.
Please note: Coalescing only works when
skip_queue=false. It doesn’t apply when you skip the queue.How to use
To enable Coalescing, update your Blnk configuration file to include the following settings:.env
| Settings | Description |
|---|---|
BLNK_TRANSACTION_ENABLE_COALESCING | Turns queued coalescing on or off. |
BLNK_TRANSACTION_BATCH_SIZE | Controls how many transactions Blnk will try to coalesce in one batch. |
When to use
As a rule of thumb, choose Coalescing when you have traffic bursts with repeated balance overlap and want the queue to drain more efficiently. It is a good fit when:- It takes too long for your queue to finish processing the transactions.
- You see repeated contention on the same balance pair, source, or destination.
- Your system experiences frequent bursts, with many similar transactions happening at the same time.
- You want to reduce repeated lock contention errors in the queue and improve throughput.
- Traffic is low-volume and spread across many balances.
- You use
skip_queue: trueto process transactions immediately.
Lock wait timeout
Available in version 0.14 and later.
skip_queue: true), it affects how long the request waits in the request path before failing.
This is especially important for immediate processing. If no timeout is set, a lock conflict can fail the request immediately. Setting a timeout gives the lock time to clear, which can reduce lock errors, but it also means the caller may wait longer for a response.
Note: A shorter timeout keeps requests more responsive, but makes lock errors more likely during contention, while a longer timeout gives contention more time to clear, but increases request latency and how long the caller may remain blocked.
How to use
To configure lock wait timeout, update your Blnk configuration with:.env
| Settings | Description |
|---|---|
BLNK_TRANSACTION_LOCK_WAIT_TIMEOUT | Controls how long Blnk will wait for locks before failing the transaction with a lock error, in integer seconds. |
When to use
This setting matters most when you want to control how long Blnk waits to acquire a lock before failing. Use it when you need to tune lock wait behavior across your deployment, especially if you expect occasional contention. It is a good fit when:- you use
skip_queue: trueand want a bounded wait time before returning a lock error - you want requests to survive short contention spikes
- lock waits are usually brief and predictable
- slightly higher latency is acceptable in exchange for fewer lock errors
Hot-lane routing
Available in version 0.14 and later.
A → B and B → A.
With hot-lane routing, Blnk identifies queued transactions for a specific source, destination, and currency pair that is showing repeated lock contention, and routes new traffic for that exact pair into a dedicated hot queue.
This helps isolate the hottest balance pairs from the rest of your queued traffic, so they stop disturbing normal queue processing.
Please note: Hot-lane routing only works when
skip_queue=false. It doesn’t apply when you skip the queue.How to use
To enable hot-lane routing, update your Blnk configuration file to include the following settings:.env
| Settings | Description |
|---|---|
BLNK_QUEUE_ENABLE_HOT_LANE | Turns hot-lane routing on or off. |
When to use
Choose hot-lane routing when contention is concentrated around a small number of balance pairs and you want to isolate that traffic from the rest of the queue. It is a good fit when:- A few specific balance pairs repeatedly cause lock contention.
- A small number of hot pairs are slowing down otherwise healthy queue traffic.
- You want to isolate the worst offenders without changing correctness behavior.
- Your normal queue works well overall, but certain balance pairs keep colliding.
- Traffic is broadly distributed with no clear hot pairs.
- Your main issue is overall worker throughput rather than localized contention. Use Coalescing instead.
- Most of your traffic is synchronous and bypasses the queue. Consider Lock wait timeout instead.