A high-throughput FinTech payment platform experienced severe cascading failures during real-world transaction spikes. Immediate symptoms included thread starvation, database connection pool exhaustion, rapidly increasing latency, and transaction timeouts. Forensic analysis showed that the underlying problem was not insufficient infrastructure. The concurrency model itself had become the bottleneck.
SOLUTION
SWARCS redesigned the transaction write path around deterministic ownership rather than distributed lock arbitration. Transactions were keyed by account_id and routed through Kafka so that operations belonging to the same account were assigned to the same partition and processed in partition order by the consumer responsible for that partition. The redesigned flow combined partitioned event processing, in-memory state validation, and append-only persistence. This removed distributed lock operations from the transaction write path and changed the system from coordinating competing writers to routing related work through a deterministic processing path. The platform could therefore sustain substantially higher transaction volume without the cascading resource exhaustion observed in the original design.
CORE ARCHITECTURAL SHIFT
FROM
many distributed nodes competing for ownership
→
TO
deterministic routing to a single processing path
CONCLUSION
The concurrency model changed from coordinating concurrent execution through distributed locking to making conflicting concurrent execution unnecessary for operations belonging to the same account. Measured results included p99 latency decreasing from 4,500 ms to 18 ms, stable throughput increasing from 3,200 TPS to 18,500+ TPS, transaction timeout rate decreasing from 8.5% to 0.0%, and database connection pressure decreasing from 100% to 26% under the tested target-load conditions.
ARCHITECTURAL ANALYSIS
CONTEXT & BUSINESS IMPACT
The platform processes real-time FinTech payment transactions that affect account balances and ledger state across thousands of concurrent accounts. Its target workload includes transaction spikes reaching approximately 15,000 TPS.
The challenge was to sustain transaction processing under concurrency without allowing coordination overhead to undermine throughput, latency, or state consistency.
THE ROOT CAUSE: DISTRIBUTED LOCK CONTENTION
The legacy architecture used Redis through Redisson to enforce mutual exclusion when multiple application nodes attempted to update the same account state. As transaction concurrency increased, distributed lock acquisition and waiting became a bottleneck in the transaction path.
More traffic
|
v
More lock contention
|
v
More blocked workers
|
v
More connection pressure
|
v
Higher latency
|
v
More timeouts
|
v
More retries
|
v
More traffic
Client-side retries amplified the load on an already degraded processing path. Additional infrastructure capacity or different lock timeout settings could change when degradation occurred, but neither would remove distributed arbitration from the transaction path.
ARCHITECTURAL INSIGHT
DETERMINISTIC OWNERSHIP
account_id
|
v
Deterministic Partition
|
v
Single Processing Path
|
v
Sequential Account State Transition
The key change is where concurrency is controlled. Instead of arbitrating ownership through distributed locks, the system routes transactions for the same account to the same Kafka partition and processes its records sequentially. Different partitions can progress concurrently, while unrelated accounts assigned to the same partition share its processing boundary.
ARCHITECTURAL EVOLUTION
LEGACY MODEL
+-------------------+
| Transaction |
+---------+---------+
|
v
+-------------------+
| Spring Boot Node |
+---------+---------+
|
v
+-------------------+
| Redis / Redisson |
| Distributed Lock |
+---------+---------+
|
+----+----+
| |
v v
WAIT EXECUTE
| |
+----+----+
|
v
Database Update
Kafka records are keyed by account_id, routing records for the same account to the same partition under the configured partitioning scheme. Records are processed sequentially within a partition, preserving their partition order. A consumer group assigns a partition to one consumer instance at a time, although assignments can change during rebalancing. Parallel processing occurs across partitions, not between records sharing the same partition's processing boundary.
STATE MANAGEMENT & PERSISTENCE
A Caffeine-backed in-memory layer keeps frequently accessed account state close to the processor, supporting transaction validation without repeatedly reconstructing active state through blocking database reads. Immutable state records and explicit enum-driven logic make state transitions explicit.
Persistence changed from competing updates to mutable account rows to an append-only account-event model.
The state transition and durable event write are covered by the same atomic database transaction. This establishes their atomicity within the database transaction; it does not imply atomic coordination with the in-memory cache or Kafka offset management.
The composite index supports account-scoped event lookup and access to ledger history by sequence number. The index alone does not establish how sequence numbers are assigned or guarantee a particular recovery procedure.
KEY ENGINEERING DECISIONS
Deterministic Message Routing: use account_id as the Kafka partition key so that records for the same account follow the same ordered processing path.
Remove Distributed Locks from the Write Path: eliminate Redis/Redisson lock operations from the critical transaction path rather than tuning the contention mechanism.
Keep Active State Close to Processing: use Caffeine-backed account state for transaction validation, with immutable state records and explicit enum-driven transitions.
Persist Immutable Events: replace competing mutable-row updates with append-only account events, writing each state transition and its durable event within the same atomic database transaction.
Validate the Complete Processing Path: evaluate throughput, p99 latency, timeout rate, and HikariCP pool utilization together to assess the effect of the architectural change.
ARCHITECTURAL OUTCOME
The redesign changed the concurrency model rather than merely replacing Redis with Kafka. Related transactions now follow a deterministic, ordered processing path, and durable transaction events are appended instead of competing updates being applied to the same mutable account row.
This places the processing boundary in the routing model and allows independent partitions to progress concurrently. The measured results demonstrate the improvement under the tested workload without implying that every possible timeout or operational failure has been eliminated.
QUANTIFIED RESULTS
p99 Latency
BEFORE
4,500 ms
AFTER
18 ms
99.6% reduction
Stable Throughput
BEFORE
3,200 TPS
AFTER
18,500+ TPS
~5.8× stable throughput
Transaction Timeout Rate
BEFORE
8.5%
AFTER
0.0%
None observed under tested load
HikariCP Pool Utilization
BEFORE
100%
AFTER
26%
74% reduction
Distributed Lock Operations
BEFORE
Continuous
AFTER
0 on write path
Removed
The target workload included transaction spikes of approximately 15,000 TPS; this target is distinct from the measured stable throughput.
The configured HikariCP maximum remained at 50 connections per application node.
The 0.0% timeout rate describes the tested load and does not establish that timeouts are impossible under all operating conditions.
Across the measured workload, the redesign combined higher stable throughput with substantially lower tail latency and connection-pool utilization. The timeout result provides additional evidence of improved behavior under those conditions, while the removal of distributed lock operations confirms the underlying architectural change.
Deterministic routing changed how transaction concurrency was controlled: related work followed an ordered processing path without distributed lock operations on the write path. Under the tested workload, the measured results show improved throughput, tail latency, observed timeout behavior, and connection-pool utilization.
ENGINEERING CONTRIBUTION
SWARCS performed architectural forensics on the transaction processing path, identified distributed lock contention as a central bottleneck, and redesigned processing around deterministic account routing. The work addressed the interaction between lock waiting, worker availability, database connection pressure, latency, and client retries rather than treating these symptoms independently.
RESPONSIBILITIES
Investigated the transaction path to identify the source of contention under high concurrency
Traced the relationship between blocked workers, HikariCP utilization, latency, timeouts, and retries
Redesigned transaction routing around account_id-based Kafka partitioning
Removed Redis/Redisson distributed lock operations from the transaction write path
Introduced Caffeine-backed in-memory account-state validation and explicit state-transition logic
Changed persistence from competing mutable-row updates to append-only account events
Used account_id and sequence_num indexing to support account-scoped event-history access
Evaluated the redesigned processing path using throughput, p99 latency, timeout, and connection-pool measurements
KEY TAKEAWAY
STOP COMPETING FOR OWNERSHIP. MAKE OWNERSHIP DETERMINISTIC.
Route related transactions by account_id
Process records sequentially within each partition
Preserve parallelism across independently processed partitions
Remove distributed locks from the transaction write path
Separate in-memory active state from durable event history
Measure the behavior of the complete transaction path under load
The central improvement was a change in concurrency control, not merely a change of infrastructure components. Deterministic routing established where related transactions are processed, while append-only persistence established how their durable events are recorded.
The resulting architecture reduced contention in the transaction path while preserving the opportunity for parallel processing across partitions.