Reduced database load by batch update of balances

Link copied to clipboard

If you have customers that generate numerous transactions per second, like large call centers or IoT customers with tens of thousands of IoT SIM cards, you can configure the PortaBilling system to accumulate changes to each customer, reseller, or vendor balances over a specific interval, such as 5 seconds, before updating balances in the database. Alongside the balance update, PortaBilling also accumulates changes to customers' and resellers' bundle counters (minutes, SMS, data) and stores them in the database in a single transaction.

This approach consolidates balance updates and bundle usage into a single operation at the end of the interval, thereby reducing their frequency. Previously, the system would immediately update a customer’s, reseller’s, or vendor’s balance after each transaction, such as a call completion, and update a bundle counter after every event. This frequent updating could result in tens or even hundreds of balance or bundle counter update transactions per second for the same database record, leading to database locks and delays.

EXAMPLE
This feature is enabled for a customer that generates ten thousand calls, each costing $0.10. The system generates ten thousand xDRs but retains each charge in the server memory for 5 seconds. Following the delay, the customer balance is updated only once by $1000 (10.000 calls multiplied by $0.10 each). Otherwise, for the customer with this feature disabled (default) the system would generate ten thousand xDRs and update their balance ten thousand times, each time by $0.10
Benefit

Service providers can avoid investing in more expensive hardware due to reduced database load.

Configuration

Link copied to clipboard

For the system to update balances in batches, open a specific customer, reseller, or vendor record, navigate to the General info panel, and enable the Batch balance updates for usage charges toggle. Note that for customers and resellers, this setting also enables batch updates for bundle counters.

Batch balance updates for usage charges toggle on the customer page

By default, when this feature is disabled, the system immediately updates a customer’s, reseller’s, or vendor’s balance after each transaction, such as a call completion.

Enable this feature only if you know that a specific customer, reseller, or vendor generates high transaction volumes, whether from numerous accounts or just a few, only in this case this feature is helpful to prevent potential downtime.

By default, when this feature is enabled, the system accumulates a customer’s, reseller’s, or vendor’s balance changes, and a customer’s or reseller’s bundle counters after each transaction or event (e.g., a call completion). To change the default period (5 seconds), go to the Configuration web server interface, and specify the value for the Rating.PendingBalanceUpdateIntervalCustomer option for customers and resellers, and Rating.PendingBalanceUpdateIntervalVendor option for vendors.

The Rating.PendingBalanceUpdateInterval options

Batch balance updates are not applied while a site-redundant system is running in stand-alone mode. During that time, the balances and bundle counters for customers, resellers, or vendors are recorded on the secondary site as individual delta records rather than being accumulated into batches. The longer the main site remains unavailable, the more delta records accumulate on the secondary site, increasing the time required to merge them once the main site is restored.

On this page

Docs for
What's new
Admin manuals
Handbooks
UI help
Developers documentation