How we taught our Smart Routing to stop doing extra push-ups

Nov. 24, 2025, 6:04 p.m.
How we taught our Smart Routing to stop doing extra push-ups

Open Workout Challenge: Smart Routing Optimization

How we tackled a hefty flow of transactions, dozens of restrictive rules, and synchronous operation, teaching Smart Routing to avoid unnecessary ‘push-ups.’


Background: The 30-Second Rule

In our system, a default timeframe of 30 seconds is allocated for a transaction to start and finish, meaning it should obtain a final status of “Success” or “Declined.” The entire process—from the moment the API request enters our system to receiving the final response from the ultimate acquirer or PSP—is allotted these 30 seconds.

These 30 seconds are necessary to avoid creating queues in synchronous integration mode. While awaiting a response from the acquirer or PSP, we maintain a network connection with them.

Synchronous Mode

We establish a network connection and keep it open from the first request until the final result. Since simultaneous connections are limited by hardware, if the limit is reached, new requests face service denial.

Asynchronous Mode

Optimized for high loads. We send a request and terminate the connection immediately. We then wait for a callback (notification) with the result, freeing up resources for other requests in the meantime.

Usually, 30 seconds in synchronous integration mode is more than enough. However, if the acquirer takes a long time to respond, and we cannot obtain the final status within 30 seconds, the transaction remains "Incomplete."

The Problem

Our tenant faced an issue with a PSP that did not support asynchronous mode. A major merchant interpreted our “Incomplete” statuses as “Declined” and cascaded transactions to a second acquirer. This caused double debiting because the first transaction was actually successful—our system just timed out before receiving the confirmation.

We discovered that our tenant’s system had created 30 aggregative rules at the PSP level. These rules applied to every transaction and checked limits for 30 different currencies.

“If the transaction amount is greater than N for the current month where: transaction currency = A, transaction type = payment, transaction status = success, then decline.”

The Flaw: The system performed calculations for all 30 currencies for every single transaction, regardless of the transaction's actual currency. Because the merchant had over a million transactions, accessing the database 30 times to aggregate monthly totals for every new request took 12+ seconds. Combined with the PSP's 18-second response, this exceeded the 30-second limit.

The Solution

To address this, we added the ability to set a precondition for a rule in Smart Routing. The system can now determine whether to execute a specific rule (and trigger the heavy calculations) or skip it entirely.

Optimized Logic
Currency Matching Precondition

The system now looks at the transaction currency in the precondition of the rule and compares it with the incoming transaction.

  • Match Found: The calculation of aggregated values is triggered only for that specific currency.
  • No Match: The rule is skipped, and no database calculation is performed.

Now, out of 30 rules, only one is effectively triggered. Smart Routing processes all aggregative limiting rules in less than a second, as expected.

In Conclusion

We discovered this problem because a series of circumstances coincided:

  1. High Transaction Volume
    A large flow of payment transactions for our tenant.
  2. System-Wide Limiting Rules
    Dozens of limiting rules applied at the PSP level. With fewer rules, Smart Routing would have finished in 1-2 seconds.
  3. Slow External Response
    A long response from the acquirer or PSP (more than 15 seconds).
  4. Synchronous Interaction
    If communication had been asynchronous, we would have completed the transaction in 35-40 seconds without issues.

Respectfully, eComCharge Team

eComCharge develops and delivers the PCI DSS Level 1 certified White Label Payment Platform beGateway for Payment Service Providers and Acquirers.

Relevant articles

Set up your payment processing system

in a few days, not a year
Request demo