Skip to content

Commit d047271

Browse files
committed
changes doc issue #59 (Support Graceful Shutdown)
1 parent 5a80728 commit d047271

File tree

3 files changed

+228
-6
lines changed

3 files changed

+228
-6
lines changed

docs/sources-asciidoc/src/main/asciidoc/concept-section-SS_Load_Balancer.adoc

Lines changed: 228 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ http://docs.google.com/present/view?id=dc5jp5vx_89cxdvtxcm-->
352352
<heartbeatInterval>150</heartbeatInterval>
353353
<statisticPort>2006</statisticPort>
354354
<jmxHtmlAdapterPort>8000</jmxHtmlAdapterPort>
355+
<shutdownTimeout>10000<shutdownTimeout>
355356
</common>
356357
<sip>
357358
<publicIp></publicIp>
@@ -560,6 +561,10 @@ rmiRegistryPort::
560561
rmiRemoteObjectPort::
561562
Port on which the {this-platform} Load Balancer will use to export the RMI Remote Object.
562563

564+
shutdownTimeout::
565+
Time after which LB will shutdown completely after getting request
566+
http://ip:statisticPort/lbstop
567+
563568
httpPort::
564569
Port on which the {this-platform} Load Balancer will accept HTTP requests to be distributed across the nodes.
565570

@@ -855,12 +860,11 @@ If you use
855860
link:http://www.keepalived.org/[keepalived] for maintaining active and standby
856861
Load balancers as it was described
857862
link:http://documentation.telestax.com/core/tutorials/high-availability/Load-Balancer_failover-keepalived.html[here]
858-
then you can gracefully shutdown active Load balancer by using http request
859-
http://host:statisticPort/lbstop for upgrades without loosing calls
860-
and redirect new calls to another active LB. The request will turn off the
861-
statistic port. The keepalived utility checks the statistic port and then
862-
switches traffic to the standby Load balancer if the statistic port is turned off.
863-
After two seconds the Load balancer finally stops.
863+
then you can shutdown active Load balancer by using http request
864+
http://host:statisticPort/lbstop for upgrades and redirect new calls to another LB.
865+
The request will turn off the statistic port. The keepalived utility checks the
866+
statistic port and then switches traffic to the standby Load balancer if the statistic
867+
port is turned off. After two seconds the Load balancer finally stops.
864868
.
865869

866870
This should produce similar output to the following:
@@ -1369,3 +1373,221 @@ and you can see next line:
13691373

13701374
Now you can send outbound and inbound messages. How to send messages you can find
13711375
link:http://documentation.telestax.com/connect/configuration/Restcomm%20-%20Connecting%20SMPP%20Endpoint%20through%20Nexmo.html[here]
1376+
1377+
== Active-Active setup and Graceful Upgrades of Load Balancer
1378+
1379+
link:http://www.keepalived.org/[Keepalived service] provides possibility graceful
1380+
shutdown of the Load balancer using health-checks and using virtual IP
1381+
on which client/server from external/internal side sends message. The Load balancer
1382+
gets this message on its real IP and transfer forward. So we can use two LBs in same
1383+
time which controlled one keepalived service.
1384+
1385+
.Active-Active Load balancer diagram
1386+
image::images/Active-Active.png[]
1387+
1388+
If LB2 will be gracefully shutdown via http request
1389+
http://ipLoadbalancer:statisticPort/lbstop (http://10.0.0.20:2006/lbstop), than the keepalived service
1390+
will switch virtual IPs 10.0.0.200 and 172.21.0.200 of second load balancer (LB2)
1391+
to other active (LB1) and all traffic which client will send to virtual IP 10.0.0.200
1392+
will be redirected to LB1.
1393+
1394+
.The graceful shutdown of Load balancer diagram
1395+
image::images/Active-Active-Graceful-Shutdown.png[]
1396+
1397+
For configuring of Load balancer you need setup keepalived service and set
1398+
additional properties in lb-configuration.xml file.
1399+
1400+
First you need install keepalived service on your machines on which you have
1401+
the Load balancers.
1402+
1403+
sudo apt-get install keepalived
1404+
1405+
The service looks for its configuration files in the /etc/keepalived directory.
1406+
Create that directory and file on both etc/keepalived/keepalived.conf.
1407+
1408+
keepalived.conf on machine with LB1:
1409+
1410+
vrrp_script chk_lb_ext {
1411+
script "/home/user/lbhealthcheck.sh"
1412+
interval 1
1413+
fall 1
1414+
rise 1
1415+
}
1416+
vrrp_script chk_lb_int {
1417+
script "/home/user/lbhealthcheck.sh"
1418+
interval 1
1419+
fall 10
1420+
rise 1
1421+
}
1422+
vrrp_instance VI_1 {
1423+
state MASTER
1424+
interface eth0
1425+
virtual_router_id 51
1426+
priority 150
1427+
advert_int 1
1428+
authentication {
1429+
auth_type AH
1430+
auth_pass k@l!ve1
1431+
}
1432+
virtual_ipaddress {
1433+
10.0.0.100/24
1434+
}
1435+
track_script {
1436+
chk_lb_ext
1437+
}
1438+
}
1439+
vrrp_instance VI_2 {
1440+
state MASTER
1441+
interface eth1
1442+
virtual_router_id 52
1443+
priority 150
1444+
advert_int 1
1445+
authentication {
1446+
auth_type AH
1447+
auth_pass k@l!ve1
1448+
}
1449+
virtual_ipaddress {
1450+
172.21.0.100/24
1451+
}
1452+
track_script {
1453+
chk_lb_int
1454+
}
1455+
}
1456+
vrrp_instance VI_3 {
1457+
state BACKUP
1458+
interface eth0
1459+
virtual_router_id 53
1460+
priority 100
1461+
advert_int 1
1462+
authentication {
1463+
auth_type AH
1464+
auth_pass k@l!ve3
1465+
}
1466+
virtual_ipaddress {
1467+
10.0.0.200/24
1468+
}
1469+
track_script {
1470+
chk_lb_ext
1471+
}
1472+
}
1473+
vrrp_instance VI_4 {
1474+
state BACKUP
1475+
interface eth1
1476+
virtual_router_id 54
1477+
priority 100
1478+
advert_int 1
1479+
authentication {
1480+
auth_type AH
1481+
auth_pass k@l!ve3
1482+
}
1483+
virtual_ipaddress {
1484+
172.21.0.200/24
1485+
}
1486+
track_script {
1487+
chk_lb_int
1488+
}
1489+
}
1490+
virtual_server 10.0.0.100 {
1491+
delay_loop 10
1492+
protocol TCP
1493+
lb_algo rr
1494+
lb_kind NAT
1495+
persistence_timeout 7200
1496+
real_server 10.0.0.10 {
1497+
}
1498+
}
1499+
virtual_server 172.21.0.100 {
1500+
delay_loop 10
1501+
protocol TCP
1502+
lb_algo rr
1503+
lb_kind NAT
1504+
persistence_timeout 7200
1505+
real_server 172.21.0.10 {
1506+
}
1507+
}
1508+
virtual_server 10.0.0.200 {
1509+
delay_loop 10
1510+
protocol TCP
1511+
lb_algo rr
1512+
lb_kind NAT
1513+
persistence_timeout 7200
1514+
real_server 10.0.0.10 {
1515+
}
1516+
}
1517+
virtual_server 172.21.0.200 {
1518+
delay_loop 10
1519+
protocol TCP
1520+
lb_algo rr
1521+
lb_kind NAT
1522+
persistence_timeout 7200
1523+
real_server 172.21.0.10 {
1524+
}
1525+
}
1526+
1527+
Then we define the symmetric configuration file on second machine. VI_3 & VI_4
1528+
are in MASTER state with a higher priority 150 to start with a stable state.
1529+
Symmetrically VI_1 & VI_2 are in default BACKUP state with lower priority of 100.
1530+
virtual_server should be 10.0.0.200, 172.21.0.200 and real_server 10.0.0.20,
1531+
172.21.0.20 accordingly. Other parameters should be same.
1532+
Also you need create file lbhealthcheck.sh somewhere(for example /home/user/),
1533+
which will be check is opened statistic port:
1534+
1535+
port=$(nc -z 172.21.0.220 2006;echo $?)
1536+
if [ $port -eq 1 ]; then
1537+
exit 1
1538+
else
1539+
exit 0
1540+
fi
1541+
1542+
Next you need set IP Load balancer adresses and ports for example next
1543+
configuration for LB1:
1544+
1545+
<external>
1546+
<host>10.0.0.10</host>
1547+
<ipLoadBalancerAddress>10.0.0.100,10.0.0.200</ipLoadBalancerAddress>
1548+
<udpPort>5060</udpPort>
1549+
<tcpPort>5060</tcpPort>
1550+
<tlsPort>5061</tlsPort>
1551+
<wsPort>5062</wsPort>
1552+
<wssPort>5063</wssPort>
1553+
<ipLoadBalancerUdpPort>5060</ipLoadBalancerUdpPort>
1554+
<ipLoadBalancerTcpPort>5060</ipLoadBalancerTcpPort>
1555+
<ipLoadBalancerTlsPort>5061</ipLoadBalancerTlsPort>
1556+
<ipLoadBalancerWsPort>5062</ipLoadBalancerWsPort>
1557+
<ipLoadBalancerWssPort>5063</ipLoadBalancerWssPort>
1558+
</external>
1559+
<internal>
1560+
<host>172.21.0.10</host>
1561+
<ipLoadBalancerAddress>172.21.0.100,172.21.0.200</ipLoadBalancerAddress>
1562+
<udpPort>5080</udpPort>
1563+
<tcpPort>5080</tcpPort>
1564+
<tlsPort>5081</tlsPort>
1565+
<wsPort>5082</wsPort>
1566+
<wssPort>5083</wssPort>
1567+
<ipLoadBalancerUdpPort>5080</ipLoadBalancerUdpPort>
1568+
<ipLoadBalancerTcpPort>5080</ipLoadBalancerTcpPort>
1569+
<ipLoadBalancerTlsPort>5081</ipLoadBalancerTlsPort>
1570+
<ipLoadBalancerWsPort>5082</ipLoadBalancerWsPort>
1571+
<ipLoadBalancerWssPort>5083</ipLoadBalancerWssPort>
1572+
</internal>
1573+
1574+
Also you need set next tags:
1575+
in <sip> section
1576+
1577+
<useIpLoadBalancerAddressInViaHeaders>true</useIpLoadBalancerAddressInViaHeaders>
1578+
1579+
in <common> section
1580+
1581+
<shutdownTimeout>10000<shutdownTimeout>
1582+
1583+
in <sipStack> section
1584+
1585+
<property>
1586+
<key>gov.nist.javax.sip.NEVER_ADD_RECEIVED_RPORT</key>
1587+
<value>true</value>
1588+
</property>
1589+
1590+
Same property should be set for LB2.
1591+
1592+
On server side you should also set
1593+
sip stack property gov.nist.javax.sip.NEVER_ADD_RECEIVED_RPORT=true
32.5 KB
Loading
27.1 KB
Loading

0 commit comments

Comments
 (0)