Load Balancing

  1. Home
  2. Programmable Voice
  3. WebRTC
  4. Load Balancing

Load Balancing

Since port densities are limited by Voice Elements (VE) Platform servers, you may desire to load balance connections between a cluster of VE servers. A good WebRTC server can only manage about 500 concurrent client connections at once – so it is very good practice to implement load balancing in your client javascript.

Inventive Labs has implemented a REST service to help you load balance your connections.

How it works

In your javascript, you will call our REST api as follows:

    • https://ivlrest.voiceelements.com/rtcloadbalance

The REST service will return a WebRTC connection string such as:

    • ws://

Your javascript will use that connection string to connect directly to the appropriate VE Server.



You can pass several parameters on the URL as follows:

    • cluster=[name] – this is the name of the bank of servers you wish to load balance to (default=IVL)
    • machine=[machine name] – if you know the exact machine name in the cluster that you wish to connect to, then specify this parameter. This may be useful if you know you will be conferencing with other parties and want to make sure all the parties end up on the same server.
    • secure=[true/false] – if you are working in a secure website environment and want to connect securely as well then set this parameter as true. It will return something like this: wss://

Here is an example of a request with all the parameters being used:

    • https://ivlrest.voiceelements.com/rtcloadbalance?cluster=IVL&machine=WebRTCVM1&secure=true

Example Javascript

// Create a new XMLHttpRequest Object 
var xHttp = new XMLHttpRequest();

// It's simplest to send a GET Command. Make sure to pass any parameters, in your URL string
// The cluster type is a collection of machines that will be running your application. 
// The IsSecure Flag sets whether or not we want it to return a secure web socket or not.
// The third parameter of the Open command determines if we make an asynchronous request. 
// We want to make a synchronous request to get the result back, so we pass in "false".
xHttp.open("GET", "https://ivlrest.voiceelements.com/rtcloadbalance?cluster=IVLTEST&IsSecure=false", false);

// Send the command

// The responseText contains the connection string that we will pass to the IVLConnect method
var connectString = xHttp.responseText;

// Check to see if the response contains an error. If there is we will return
if (connectString.length >= 6 && connectString.substring(0, 6).toUpperCase() == "ERROR:") {
    alert('There was an error connecting!');

// Connect to the server that was returned back to us.
Was this article helpful to you? No Yes 11

How can we help?