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 operates in FinTech / Payment Processing, handling real-time financial transactions that affect account balances and ledger state across thousands of concurrent accounts.
Domain: FinTech / Payment Processing
Target workload: transaction spikes reaching approximately 15,000 TPS
Real-time transactions affect account balances and ledger state across thousands of concurrent accounts
A critical characteristic of the original system was nonlinear degradation. More traffic produced more contention; contention exhausted shared resources; resource exhaustion generated further failures and retries; and those retries increased traffic again.
NONLINEAR DEGRADATION
More traffic
|
v
More contention
|
v
Shared resource exhaustion
|
v
More failures and retries
|
v
More traffic
THE ROOT CAUSE: DISTRIBUTED LOCK CONTENTION
The legacy architecture used a central Redis deployment through Redisson for mutual exclusion whenever multiple application nodes attempted to update the same account state. The approach was functionally correct under moderate load, but it became a coordination bottleneck as transaction concurrency increased significantly.
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
Increasing infrastructure capacity was not a solution to the underlying architectural condition. More Redis capacity or changes to lock timeout parameters could move the degradation point, but synchronous distributed arbitration would remain part of the transaction path.
ARCHITECTURAL INSIGHT
DETERMINISTIC OWNERSHIP
account_id
|
v
Deterministic Partition
|
v
Single Processing Path
|
v
Sequential Account State Transition
The original architecture attempted to make concurrent execution safe through distributed locking. The redesigned architecture determines the processing path before execution, so operations for the same account do not need to compete for a distributed lock. Serialization is applied where account-level state ordering requires it. Accounts assigned to different partitions can be processed concurrently, while accounts assigned to the same partition share its processing and serialization boundary.
ARCHITECTURAL EVOLUTION
LEGACY MODEL
+-------------------+
| Transaction |
+---------+---------+
|
v
+-------------------+
| Spring Boot Node |
+---------+---------+
|
v
+-------------------+
| Redis / Redisson |
| Distributed Lock |
+---------+---------+
|
+----+----+
| |
v v
WAIT EXECUTE
| |
+----+----+
|
v
Database Update
Transactions are keyed by account_id. Kafka therefore routes transactions with the same account key to the same partition, where the corresponding records are consumed in partition order. With sequential processing of records within each assigned partition, operations for the same account are applied in partition order. This preserves the required ordering without distributed lock arbitration, while allowing different partitions to be processed concurrently.
ACCOUNT ROUTING PROPERTY
Same Account
|
v
Same Partition
|
v
Same Processing Path
|
v
Sequential State Transitions
Within a consumer group, a partition is assigned to one consumer instance at a time. When that consumer processes the partition's records sequentially, operations for the same account are applied in partition order. Different partitions can be processed concurrently, but accounts assigned to the same partition share its serialization boundary.
STATE MANAGEMENT & PERSISTENCE
Frequently accessed account state is maintained in memory
Transaction validation is performed close to the processing path
State transitions are explicitly represented through immutable state records
Enum-driven transition logic makes state changes explicit
Unnecessary synchronization is reduced
The hot transaction path avoids repeatedly reconstructing active state through blocking database reads
The redesigned persistence model changes the database interaction from competing updates against mutable account rows to append-only transaction events.
Previous persistence pattern:
Redesigned persistence pattern:
Each transaction becomes an append operation instead of a competing update against the same mutable account row. This removes the previous dependency on relational row-level update coordination from the transaction processing model and provides a durable event trail for account state changes.
The ledger index supports efficient retrieval and reconstruction of account history while preserving the append-oriented persistence model.
KEY ENGINEERING DECISIONS
Deterministic Message Routing: account_id -> Kafka partition -> processing owner. Related transactions are placed in the same partition and, with sequential partition processing, applied in partition order. Different partitions can be processed concurrently, while accounts sharing a partition also share its serialization boundary. Dynamic distributed ownership arbitration is replaced by deterministic routing.
Remove Distributed Locks from Write Path: Redis/Redisson is removed from the critical transaction coordination path. The transaction flow no longer depends on acquiring and renewing a distributed lease before each account update, removing cross-node synchronization overhead and associated failure modes.
Serialize Where Serialization Is Actually Required: financial state transitions for one account require ordering, so serialization is applied at the account processing path. Global concurrency is preserved across independently processed partitions, while records within each partition share its serialization boundary.
Keep Hot State Close to Processor: frequently accessed account state is maintained in Caffeine so active account state can be validated and transitioned without unnecessary blocking reads.
Persist Immutable Events: the database becomes an append-oriented durable event store rather than the primary synchronization mechanism for concurrent account updates. State transition ordering is separated from durable event persistence.
Isolate Resource Consumption: partition processing provides a predictable execution model and avoids unbounded request concurrency competing for shared Redis, JVM, and database resources. Processing paths have controlled execution and explicit ownership.
ARCHITECTURAL OUTCOME
BEFORE
Concurrent Writers
|
v
Shared Distributed State
|
v
Distributed Lock Arbitration
|
v
Resource Contention
|
v
Cascading Degradation
AFTER
Concurrent Transactions
|
v
Deterministic Account Routing
|
v
Single Processing Owner
|
v
Sequential Account State Transitions
|
v
Append-Only Persistence
The key architectural distinction is that the redesign should not be described simply as "Redis was replaced by Kafka."
The result is a transaction pipeline that moves from a contention-driven execution model to a deterministic processing model with explicit ownership and controlled resource consumption.
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.8x capacity
Transaction Timeout Rate
BEFORE
8.5%
AFTER
0.0%
None observed under tested load
DB Connection Pressure
BEFORE
100%
AFTER
26%
74% reduction
Distributed Lock Ops
BEFORE
Continuous
AFTER
0 on write path
Removed
3,200 TPS represented the previous failure boundary
18,500+ TPS represented stable sustained processing after the redesign
p99 latency decreased from 4,500 ms to 18 ms
Database connection pressure dropped from saturation to approximately 26% under comparable peak-load conditions
The database result was not achieved by increasing the database connection pool
The reduction resulted from removing the blocking coordination pattern that consumed shared resources
Observed transaction timeout rate fell from approximately 8.5% during high-volume windows to 0% under the tested target load
The retry amplification loop was removed from the critical failure scenario rather than merely pushed to a higher traffic threshold
The redesigned system therefore changed the failure boundary itself: higher transaction volume no longer reproduced the original chain of distributed lock contention, resource exhaustion, timeouts, and retry amplification under the tested target load.
The redesign transformed transaction processing from a contention-driven concurrency model into deterministic processing based on account ownership. The measured outcome was a p99 latency reduction from 4,500 ms to 18 ms, stable throughput growth from 3,200 TPS to 18,500+ TPS, transaction timeout rate reduction from 8.5% to 0.0% under the tested target load, database connection pressure reduction from 100% to 26%, and removal of distributed lock operations from the transaction write path. The architectural value was not merely increased capacity. The platform acquired a fundamentally different failure boundary by removing the distributed coordination pattern responsible for cascading degradation.
ENGINEERING CONTRIBUTION
SWARCS performed architectural forensics on the platform's behavior under failure and peak concurrency, identified the concurrency bottleneck, and redesigned transaction processing around deterministic partition ownership. The engagement focused on the underlying system behavior rather than treating individual symptoms in isolation. The critical architectural change was to remove the need for distributed synchronization instead of attempting to make the existing locking model scale indefinitely.
RESPONSIBILITIES
Performed architectural forensics of the transaction processing path
Identified distributed lock contention as the concurrency bottleneck
Analyzed thread starvation, database connection pressure, latency, timeouts, and retry amplification as parts of the same failure loop
Redesigned transaction routing around deterministic account_id partition ownership
Introduced Kafka-based partitioned event processing for ordered same-account operations
Removed Redis/Redisson distributed synchronization from the transaction write path
Designed in-memory account-state validation using Caffeine
Introduced immutable state records and enum-driven state transitions
Redesigned persistence around append-only account events
Established account_id and sequence_num ledger indexing for account history retrieval and reconstruction
Separated state-transition ordering from durable event persistence
Designed controlled processing paths to isolate shared-resource consumption
Validated the resulting behavior under high-volume target transaction load
KEY TAKEAWAY
STOP COMPETING FOR OWNERSHIP. MAKE OWNERSHIP DETERMINISTIC.
Partition related transactions by account_id
Route the same account through the same processing path
Serialize state transitions where business ordering requires it
Keep hot state close to the processor
Remove distributed locks from the write path
Use append-only persistence for durable event storage
Separate state transition ordering from durable event persistence
Treat shared-resource contention as an architectural concern
The architectural improvement was not simply replacing Redis with Kafka.
It was replacing distributed coordination with deterministic ownership.
By routing each account to a single processing path, the system removed
lock contention from the transaction hot path while preserving concurrency
across independently processed partitions.
The result was not merely a faster system, but a fundamentally different
concurrency model and failure boundary.