SIP Balancer User Guide
SIP Balancer User Guide
Preface ............................................................................................................................. v
1. Document Conventions .......................................................................................... v
1.1. Typographic Conventions ............................................................................ v
1.2. Pull-quote Conventions .............................................................................. vii
1.3. Notes and Warnings .................................................................................. vii
1. Load Balancer ............................................................................................................. 1
1.1. SIP Load Balancer: Installing, Configuring and Running ........................................ 2
1.1.1. Pre-Install Requirements and Prerequisites ................................................ 2
1.1.2. Downloading ............................................................................................ 2
1.1.3. Installing .................................................................................................. 2
1.1.4. Configuring .............................................................................................. 2
1.1.5. Running ................................................................................................... 9
1.1.6. Testing .................................................................................................. 10
1.1.7. Stopping ................................................................................................ 11
1.1.8. Uninstalling ............................................................................................ 11
1.2. SIP Load Balancing Basics ............................................................................... 11
1.3. HTTP Load Balancing Basics ............................................................................ 12
1.4. Pluggable balancer algorithms ...........................................................................
1.5. Distributed load balancing .................................................................................
1.6. Implementation of the Mobicents Load Balancer .................................................
1.7. SIP Message Flow ............................................................................................
A. Revision History ..........................................................................................................
12
13
14
15
17
iii
iv
Preface
1. Document Conventions
This manual uses several conventions to highlight certain words and phrases and draw attention
to specific pieces of information.
In PDF and paper editions, this manual uses typefaces drawn from the Liberation Fonts [https://
fedorahosted.org/liberation-fonts/] set. The Liberation Fonts set is also used in HTML editions if
the set is installed on your system. If not, alternative but equivalent typefaces are displayed. Note:
Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default.
Used to highlight system input, including shell commands, file names and paths. Also used to
highlight key caps and key-combinations. For example:
To see the contents of the file my_next_bestselling_novel in your current
working directory, enter the cat my_next_bestselling_novel command at the
shell prompt and press Enter to execute the command.
The above includes a file name, a shell command and a key cap, all presented in Mono-spaced
Bold and all distinguishable thanks to context.
Key-combinations can be distinguished from key caps by the hyphen connecting each part of a
key-combination. For example:
Press Enter to execute the command.
Press Ctrl+Alt+F1 to switch to the first virtual terminal. Press Ctrl+Alt+F7 to
return to your X-Windows session.
The first sentence highlights the particular key cap to press. The second highlights two sets of
three key caps, each set pressed simultaneously.
If source code is discussed, class names, methods, functions, variable names and returned values
mentioned within a paragraph will be presented as above, in Mono-spaced Bold. For example:
File-related classes include filesystem for file systems, file for files, and dir
for directories. Each class has its own associated set of permissions.
Proportional Bold
This denotes words or phrases encountered on a system, including application names; dialogue
box text; labelled buttons; check-box and radio button labels; menu titles and sub-menu titles.
For example:
Preface
Choose System > Preferences > Mouse from the main menu bar to launch
Mouse Preferences. In the Buttons tab, click the Left-handed mouse check
box and click Close to switch the primary mouse button from the left to the right
(making the mouse suitable for use in the left hand).
To insert a special character into a gedit file, choose Applications >
Accessories > Character Map from the main menu bar. Next, choose Search
> Find from the Character Map menu bar, type the name of the character in the
Search field and click Next. The character you sought will be highlighted in the
Character Table. Double-click this highlighted character to place it in the Text
to copy field and then click the Copy button. Now switch back to your document
and choose Edit > Paste from the gedit menu bar.
The above text includes application names; system-wide menu names and items; applicationspecific menu names; and buttons and text found within a GUI interface, all presented in
Proportional Bold and all distinguishable by context.
Note the > shorthand used to indicate traversal through a menu and its sub-menus. This is to
avoid the difficult-to-follow 'Select Mouse from the Preferences sub-menu in the System menu
of the main menu bar' approach.
Mono-spaced Bold Italic or Proportional Bold Italic
Whether Mono-spaced Bold or Proportional Bold, the addition of Italics indicates replaceable or
variable text. Italics denotes text you do not input literally or displayed text that changes depending
on circumstance. For example:
To connect to a remote machine using ssh, type ssh [email protected]
at a shell prompt. If the remote machine is example.com and your username on
that machine is john, type ssh [email protected].
The mount -o remount file-system command remounts the named file
system. For example, to remount the /home file system, the command is mount
-o remount /home.
To see the version of a currently installed package, use the rpm -q package
command. It will return a result as follows: package-version-release.
Note the words in bold italics above username, domain.name, file-system, package, version and
release. Each word is a placeholder, either for text you enter when issuing a command or for text
displayed by the system.
Aside from standard usage for presenting the title of a work, italics denotes the first use of a new
and important term. For example:
When the Apache HTTP Server accepts requests, it dispatches child processes
or threads to handle them. This group of child processes or threads is known as
vi
Pull-quote Conventions
a server-pool. Under Apache HTTP Server 2.0, the responsibility for creating and
maintaining these server-pools has been abstracted to a group of modules called
Multi-Processing Modules (MPMs). Unlike other modules, only one module from
the MPM group can be loaded by the Apache HTTP Server.
books
books_tests
Desktop
Desktop1
documentation
downloads
drafts
images
mss
notes
photos
scripts
stuff
svgs
svn
Source-code listings are also set in Mono-spaced Roman but are presented and highlighted as
follows:
package org.jboss.book.jca.ex1;
import javax.naming.InitialContext;
public class ExClient
{
public static void main(String args[])
throws Exception
{
InitialContext iniCtx = new InitialContext();
Object
ref = iniCtx.lookup("EchoBean");
EchoHome
home = (EchoHome) ref;
Echo
echo = home.create();
System.out.println("Created Echo");
System.out.println("Echo.echo('Hello') = " + echo.echo("Hello"));
}
}
vii
Preface
Note
A note is a tip or shortcut or alternative approach to the task at hand. Ignoring a
note should have no negative consequences, but you might miss out on a trick that
makes your life easier.
Important
Important boxes detail things that are easily missed: configuration changes that
only apply to the current session, or services that need restarting before an update
will apply. Ignoring Important boxes won't cause data loss but may cause irritation
and frustration.
Warning
A Warning should not be ignored. Ignoring warnings will most likely cause data
loss.
viii
Chapter 1.
Load Balancer
A JAIN SIP HA-enabled application server such as Mobicents JAIN SLEE or Mobicents SIP
Servlets is required.
Running the SIP Load Balancer requires at least two instances of the application server as
cluster nodes nodes. Therefore, before configuring the SIP Load Balancer, we should make
sure we've installed a the SIP application server first. The Mobicents SIP load balancer will
work with a SIP Servlets-enabled JBoss Application Server or a JAIN SLEE application server
with SIP RA.
SIP Servlets containers based on Tomcat are also supported but the session replication is
not available there, thus mid-call failover will not work.
1.1.2. Downloading
The load balancer is located in the sip-balancer top-level directory of the Mobicents distribution.
You will find the following files in the directory:
1.1.3. Installing
The SIP load balancer executable JAR file can be extracted anywhere in the file system. It is
recommended that the file is placed in the directory containing other JAR executables, so it can
be easily located in the future.
1.1.4. Configuring
Configuring the SIP load balancer and the two SIP Servlets-enabled Server nodes is described
in Configuring the Mobicents SIP Load Balancer and SIP Server Nodes.
Configuring
Procedure 1.1. Configuring the Mobicents SIP Load Balancer and SIP Server
Nodes
1.
# The binding address of the load balancer. This also specifies the
# default value for both internalHost and externalHost if not specified separately.
host=127.0.0.1
# The binding address of the load balancer where clients should connect (if the host property
is not specified)
#externalHost=127.0.0.1
# The SIP port from where servers will receive messages
# delete if you want to use only one port for both inbound and outbound)
internalPort=5065
# The SIP port used where clients should connect
externalPort=5060
# The binding address of the load balancer where SIP application servers should connect (if
the host property is not specified)
#internalHost=127.0.0.1
# The RMI port used for heartbeat signals
rmiRegistryPort=2000
# The HTTP port for HTTP forwarding
# if you like to activate the integrated HTTP load balancer, this is the entry point
httpPort=2080
#If no nodes are active the LB can redirect the traffic to the unavailableHost specified in this
property,
#otherwise, it will return 503 Service Unavailable
#unavailableHost=google.com
# If you are using IP load balancer, put the IP address and port here
#externalIpLoadBalancerAddress=127.0.0.1
#externalIpLoadBalancerPort=111
# Requests initited from the App Servers can route to this address (if you are using 2 IP load
balancers for bidirectional SIP LB)
#internalIpLoadBalancerAddress=127.0.0.1
#internalIpLoadBalancerPort=111
# The addresses in the SIP LB Via headers can be either the real addresses or those specified
in the external and internal IP LB addresses
useIpLoadBalancerAddressInViaHeaders=false
# Designate extra IP addresses as serer nodes
#extraServerNodes=222.221.21.12:21,45.6.6.7:9003,33.5.6.7,33.9.9.2
# Call-ID affinity algortihm settings. This algorithm is the default. No need to uncomment it.
#algorithmClass=org.mobicents.tools.sip.balancer.CallIDAffinityBalancerAlgorithm
# This property specifies how much time to keep an association before being evitcted.
# It is needed to avoid memory leaks on dead calls. The time is in seconds.
#callIdAffinityMaxTimeInCache=500
#The following attribute specified the policy after failover. If set to true all calls from the failed
node
#will go to a new healthy node (all calls to the same node). If set to false the calls will go to
random new nodes.
#callIdAffinityGroupFailover=false
# Uncomment to enable the consistent hash based on Call-ID algorithm.
#algorithmClass=org.mobicents.tools.sip.balancer.HeaderConsistentHashBalancerAlgorithm
# This property is not required, it defaults to Call-ID if not set, cna be "from.user" or "to.user"
when you want the SIP URI username
#sipHeaderAffinityKey=Call-ID
#specify the GET HTTP parameter to be used as hash key
#httpAffinityKey=appsession
# Uncomment to enable the persistent consistent hash based on Call-ID algorithm.
#algorithmClass=org.mobicents.tools.sip.balancer.PersistentConsistentHashBalancerAlgorithm
# This property is not required, it defaults to Call-ID if not set
Configuring
#sipHeaderAffinityKey=Call-ID
#specify the GET HTTP parameter to be used as hash key
#httpAffinityKey=appsession
#This is the JBoss Cache 3.1 configuration file (with jgroups), if not specified it will use default
#persistentConsistentHashCacheConfiguration=/home/config.xml
# Call-ID affinity algortihm settings. This algorithm is the default. No need to uncomment it.
#algorithmClass=org.mobicents.tools.sip.balancer.CallIDAffinityBalancerAlgorithm
# This property specifies how much time to keep an association before being evitcted.
# It is needed to avoid memory leaks on dead calls. The time is in seconds.
#callIdAffinityMaxTimeInCache=500
# Uncomment to enable the consistent hash based on Call-ID algorithm.
#algorithmClass=org.mobicents.tools.sip.balancer.HeaderConsistentHashBalancerAlgorithm
# This property is not required, it defaults to Call-ID if not set, cna be "from.user" or "to.user"
when you want the SIP URI username
#sipHeaderAffinityKey=Call-ID
#specify the GET HTTP parameter to be used as hash key
#httpAffinityKey=appsession
# Uncomment to enable the persistent consistent hash based on Call-ID algorithm.
#algorithmClass=org.mobicents.tools.sip.balancer.PersistentConsistentHashBalancerAlgorithm
# This property is not required, it defaults to Call-ID if not set
#sipHeaderAffinityKey=Call-ID
#specify the GET HTTP parameter to be used as hash key
#httpAffinityKey=appsession
#This is the JBoss Cache 3.1 configuration file (with jgroups), if not specified it will use default
#persistentConsistentHashCacheConfiguration=/home/config.xml
#If a node doesnt check in within that time (in ms), it is considered dead
nodeTimeout=5100
#The consistency of the above condition is checked every heartbeatInterval milliseconds
heartbeatInterval=150
host
Local IP address, or interface, on which the SIP load balancer will listen for incoming
requests.
externalPort
Port on which the SIP load balancer listens for incoming requests from SIP User Agents.
internalPort
Port on which the SIP load balancer forwards incoming requests to available, and healthy,
SIP Server cluster nodes.
rmiRegistryPort
Port on which the SIP load balancer will establish the RMI heartbeat connection to the
application servers. When this connection fails or a disconnection instruction is received,
an application server node is removed and handling of requests continues without it by
redirecting the load to the lie nodes.
httpPort
Port on which the SIP load balancer will accept HTTP requests to be distributed across
the nodes.
internalTransport
Transport protocol for the internal SIP connections associated with the internal SIP port
of the load balancer. Possible choices are UDP, TCP and TLS.
externalTransport
Transport protocol for the external SIP connections associated with the external SIP port
of the load balancer. Possible choices are UDP, TCP and TLS. It must match the transport
of the internal port.
externalIpLoadBalancerAddress
Address of the IP load balancer (if any) used for incoming requests to be distributed in
the direction of the application server nodes. This address may be used by the SIP load
Configuring
balancer to be put in SIP headers where the external address of the SIP load balancer
is needed.
externalIpLoadBalancerPort
The port of the external IP load balancer. Any messages arriving at this port should be
distributed across the external SIP ports of a set of SIP load balancers.
internalIpLoadBalancerAddresst
Address of the IP load balancer (if any) used for outgoing requests (requests initiated
from the servers) to be distributed in the direction of the clients. This address may be
used by the SIP load balancer to be put in SIP headers where the internal address of
the SIP load balancer is needed.
internalIpLoadBalancerPort
The port of the internal IP load balancer. Any messages arriving at this port should be
distributed across the internal SIP ports of a set of SIP load balancers.
extraServerNodes
Comma-separated list of hosts that are server nodes. You can put here alternative
names of the application servers here and they will be recognized. Names are important,
because they might be used for direction-analysis. Requests coming from these server
will go in the direction of the clients and will not be routed back to the cluster.
algorithmClass
The fully-qualified Java class name of the balancing algorithm to be used. There are
three algorithms to choose from and you can write your own to implement more complex
routing behaviour. Refer to the sample configuration file for details about the available
options for each algorithm. Each algorithm can have algorithm-specific properties for finegrained configuration.
nodeTimeout
In milliseonds. Default value is 5100. If a server node doesnt check in within this time (in
ms), it is considered dead.
heartbeatInterval
In milliseconds. Default value is 150 milliseonds. The hearbeat interval must be much
smaller than the interval specified in the JAIN SIP property on the server machines org.mobicents.ha.javax.sip.HEARTBEAT_INTERVAL
Note
The remaining keys and properties in the configuration properties file
can be used to tune the JAIN SIP stack, but are not specifically
required for load balancing. To assist with tuning, a comprehensive list
of implementing classes for the SIP Stack is available from the Interface
SIP Stack page on nist.gov [http://snad.ncsl.nist.gov/proj/iptel/jain-sip-1.2/
2.
Configure logging
The SIP load balancer uses Java Logging [http://java.sun.com/j2se/1.4.2/docs/guide/
util/logging/overview.html] as a logging mechanism. You can configure it through a
property file and specify the property file to be used by using the following command
-Djava.util.logging.config.file=./lb-logging.properties. Please refer to JDK
logging for more informationon how to configure the Java logging.
Running
Figure 1.2. Ensuring SIP and HTTP requests are being grouped by common
affinity value.
1.1.5. Running
Procedure 1.2. Running the SIP Load Balancer and SIP Server Nodes
1.
Executing the SIP load balancer produces output similar to the following example:
home]$ java -jar sip-balancer-jar-with-dependencies.jar lbconfiguration.properties
Oct 21, 2008 1:10:58 AM
org.mobicents.tools.sip.balancer.SIPBalancerForwarder start
INFO: Sip Balancer started on address 127.0.0.1, external port : 5060,
port : 5065
The output shows the IP address on which the SIP Load Balancer is listening, as well as the
external and internal listener ports.
2.
3.
1.1.6. Testing
To test load balancing, the same application must be deployed manually on each node, and two
SIP Softphones must be installed.
Deploy an Application
Ensure that for each node, the DAR file location is specified in the server.xml file.
Deploy the Location service manually on both nodes.
2.
3.
4.
10
Stopping
Initiate a second call using the same SIP address, and tear down the call once completed.
Notice that the call is handled by the second node.
Procedure 1.4. Testing Load Balancing with JAIN SLEE and SIP RA
1.
Deploy SIP RA
2.
Configure the JAIN SIP HA properties for load balancing according to the JAIN SLEE User
Guide
3.
4.
Run the sample scenario for the application using the SIP Load Balancer
1.1.7. Stopping
Assuming that you started the JBoss Application Server as a foreground process in the Linux
terminal, the easiest way to stop it is by pressing the Ctrl+C key combination in the same terminal
in which you started it.
This should produce similar output to the following:
^COct 21, 2008 1:11:57 AM
org.mobicents.tools.sip.balancer.SipBalancerShutdownHook run
INFO: Stopping the sip forwarder
1.1.8. Uninstalling
To uninstall the SIP load balancer, delete the JAR file you installed.
11
The SIP Load Balancer is also able to failover requests mid-call from unavailable nodes
to available ones, thus increasing the reliability of the SIP service or application. The Load
Balancer increases throughput and reliability by dynamically provisioning SIP service requests
and responses across responsive nodes in a cluster. This enables SIP applications to meet the
real-time demand for SIP services.
session ID assigned; the apache routes the request to a random application server node.
When the node responds it assigns a session ID and jvmRoute to the response of the request
in a HTTP cookie. This response goes back to the client through apache, which keeps track of
which node owns each jvmRoute. Once the very first request is served this way, the subsequent
requests from this session will carry the assigned cookie, and the apache load balancer will always
route the requests to the node, which advertised itself as the jvmRoute owner.
Instead of using apache, an integrated HTTP Load Balancer is also available. The SIP Load
Balancer has a HTTP port where you can direct all incoming HTTP requests. The integrated HTTP
load balancer behaves exactly like apache by default, but this behavior is extensible and can be
overridden completely with the pluggable balancer algorithms. The integrated HTTP load balancer
is much easier to configure and generally requires no effort, because it reuses most SIP settings
and assumes reasonable default values.
Unlike the native apache, the integrated HTTP Load Balancer is written completely in Java, thus a
performance penalty should be expected when using it. However, the integrated HTTP Balancer
has an advantage when related SIP and HTTP requests must stick to the same node.
12
Note
Users must be aware that by default requests explicitly addressed to a live server
node passing through the load balancer will be forwarded directly to the server
node. This allows for pre-specified routing use-cases, where the target node is
known by the SIP client through other means. If the target node is dead, then the
node selection algorithm is used to route the request to an available node.
20.20.20.20,
The nodes specified in a group do not have to alive and nodes that are not specified are still
allowed to join the cluster. Otherwise the algorthim behaves exactly as the default Call-ID
affinity algorthim.
13
balancers based on some IP rules or round-robin. With consistent hash and jvmRoute-based
balancer algorithms it doesn't matter which SIP/HTTP load balancer will process the request,
because they would all make the same decisions based on information in the requests (headers,
parameters or cookies) and the list of available nodes. With consistent hash algorithms there is
no state to be preserved in the SIP/HTTP balancers.
14
then selects a node to which it forwards the SIP requests. The Load Balancer forwards all samesession requests to the first node selected to initiate the session, providing that the node is healthy
and available.
15
16
17
18