Backend Development 27 min read

Load Balancing ASR Services in Ctrip Call Center: Architecture and Implementation with FreeSWITCH and OpenSIPS

This article details the design, evolution, and best‑practice implementation of load‑balancing for ASR (speech‑recognition) services in Ctrip's massive call‑center, covering component architecture, MRCP integration, challenges with traditional balancers, and two practical solutions using FreeSWITCH distributor and OpenSIPS.

Ctrip Technology
Ctrip Technology
Ctrip Technology
Load Balancing ASR Services in Ctrip Call Center: Architecture and Implementation with FreeSWITCH and OpenSIPS

Ctrip operates a call‑center handling over a million daily calls across multiple product lines; to provide intelligent voice‑bot services it relies on ASR (Automatic Speech Recognition) accessed via MRCP over SIP/UDP/TCP. The underlying platform includes components such as CC‑Gateway, SBC, REG, SM, RS, CM (FreeSWITCH), and ASR servers.

Because third‑party ASR vendors do not supply load‑balancing, Ctrip must distribute ASR traffic across several clusters (self‑developed, Baidu, Alibaba, Microsoft) deployed in multiple IDC locations. The goal is to achieve uniform request distribution, IDC‑aware routing, and automatic health‑checking.

Two solution paths were explored:

Solution A : Use FreeSWITCH's mod_distributor to balance MRCP requests directly. This requires configuring separate MRCP profiles for each server, defining gateways, and setting equal weights in a distributor list.

Solution B : Insert OpenSIPS as an intermediate load‑balancer. FreeSWITCH sends SIP INVITE to OpenSIPS, which then dispatches to MRCP servers using either the load_balancer or dispatcher module, selected per‑cluster.

Both approaches were evaluated; traditional hardware (A10, F5, NetScaler) and software (LVS, Nginx) balancers could not evenly distribute MRCP traffic because the SIP four‑tuple remains constant for a given call.

Implementation details for Solution A include:

<include>
  <profile name="mrcp1" version="2">
    <param name="client-ip" value="192.168.1.99"/>
    <param name="client-port" value="client-port-1"/>
    <param name="server-ip" value="server-ip-1"/>
    <param name="server-port" value="8060"/>
    <param name="sip-transport" value="tcp"/>
    <param name="rtp-ip" value="192.168.1.99"/>
    <param name="rtp-port-min" value="min-port-1"/>
    <param name="rtp-port-max" value="max-port-1"/>
    <param name="ua-name" value="FreeSWITCH"/>
  </profile>
</include>

Corresponding gateway configuration and distributor.conf.xml assign equal weights to mrcp1 and mrcp2 . Runtime commands such as sof ia profile external gwlist down and expand eval ${distributor mrcp ${sofia profile external gwlist down}} demonstrate dynamic selection.

Solution B adds OpenSIPS scripts that inspect the SIP User‑Agent header (e.g., ASR_MRCP_CLIENT_FS ) or the SDP m=application line to identify ASR requests, then routes them via load_balancer (resource‑aware) or dispatcher (round‑robin, hash) modules. Example routing logic:

route{
    if (is_method("INVITE")) {
        if ($ua == "ASR_MRCP_CLIENT_FS") {
            $var(dlgPingTag) = "";
        }
        if (!create_dialog("$var(dlgPingTag)")) { ... }
        if ($ua =~ "^ASR_MRCP_CLIENT_CTRIP_FS*") {
            dp_translate("90", "$ua/$avp(dest)", "$var(attrs)");
            route(exeLb, $(var(attrs){s.int}), "pstn", $(var(attrs){s.select,1,:}), $(var(attrs){s.select,2,:}));
        }
    }
}

route[exeLb]{
    $var(lbRst) = ($var(lb_method) == "DS") ? ds_select_dst("$var(lb_group_id)", "4") : lb_start_or_next("$var(lb_group_id)", "$var(resource_type)", "s");
    if ($var(lbRst) > 0) { route(relay); } else { t_reply("480", "$var(node_type) Unavailable"); }
}

Database tables ( dialplan , dispatcher , load_balancer ) store routing attributes, IDC preferences, and resource limits, enabling automatic fail‑over and IDC‑priority selection.

Testing shows that when one MRCP node fails, the balancer redirects traffic to the remaining nodes, and when an entire IDC becomes unavailable, traffic is rerouted to the secondary IDC, preserving service continuity.

The combined approach—FreeSWITCH distributor for local load distribution and OpenSIPS for cluster‑wide balancing—delivers IDC‑aware, health‑checked, multi‑vendor ASR provisioning, significantly improving reliability and user experience in Ctrip's intelligent voice‑bot ecosystem.

In conclusion, although ASR load balancing represents a small component of the overall call‑center platform, its proper design and implementation are essential for stable, high‑throughput voice services.

load balancingASRcall centerFreeSWITCHtelephonyMRCPOpenSIPS
Ctrip Technology
Written by

Ctrip Technology

Official Ctrip Technology account, sharing and discussing growth.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.