load balancing load balancers - kamailio...7 dispatcher module - load balancing dispatching...
TRANSCRIPT
![Page 1: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/1.jpg)
Load Balancing Load Balancers
Daniel-Constantin MierlaCo-Founder Kamailio Project
www.asipto.com
![Page 2: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/2.jpg)
2
Load Balancing
Load BalancerLoad Balancer
- load balancing- traffic dispatching- high availability- security- as simple as possible
![Page 3: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/3.jpg)
3
Load Balancing
Load BalancerLoad Balancer
Rating EngineCall Routing Engine
- main service- very reliable- easy to scale
![Page 4: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/4.jpg)
4
Load Balancing
Load BalancerLoad Balancer
Rating EngineSIP Routing Engine
Application Srv
Application Srv
Application Srv
- plus-value to servicing- controlled via routing engine- service partitioning- add as you needed
![Page 5: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/5.jpg)
5
Load Balancing
Load BalancerLoad Balancer
Rating EngineSIP Routing Engine
App Srv (CC)
App Srv (P&IM)
App Srv (Acc)
Backends
Monitoring
Web 2.0- simplified view
![Page 6: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/6.jpg)
6
Load Balancing
SIP AS
SIP AS
SIP AS
?
![Page 7: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/7.jpg)
7
Dispatcher Module - Load Balancing
dispatching algorithms compute an integer value using a hashing function
hash over callid ensures that all requests within a dialog goes to same box
hash over from uri ensures that all requests from same user goes to same box
hash over to uri ensures that registrations of an AoR goes to same box
hash over request-uri ensures that requests to same destination are processes by
same box hash over config variable
for different needs
![Page 8: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/8.jpg)
8
Dispatcher Module - Load Balancing
balancing algorithms
call load distribution counting of active calls per destination address
weight based distribution each destination address has assigned a weight
(percentage) to it priority based distribution
each destination address has assigned a priority to it (practically is same as serial forking)
round-robin (next destination) - recommended well-known algorithm with pretty fair distribution
![Page 9: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/9.jpg)
Dispatcher destinations file
9
![Page 10: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/10.jpg)
Dispatcher Config
10
![Page 11: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/11.jpg)
Dispatcher Config
11
# Dispatch requestsroute[DISPATCH] {! # round robin dispatching on gateways group '1'! if(!ds_select_dst("1", "4"))! {! ! send_reply("404", "No destination");! ! exit;! }! xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");! t_on_failure("RTF_DISPATCH");! t_relay(); exit;}# Failure re-routefailure_route[RTF_DISPATCH] {! if (t_is_canceled()) {! ! exit;! }! # next DST - only for 500 or local timeout! if (t_check_status("500")! ! ! or (t_branch_timeout() and !t_branch_replied()))! {! ! if(ds_next_dst())! ! {! ! ! t_on_failure("RTF_DISPATCH");! ! ! t_relay();! ! ! exit;! ! }! }}
![Page 12: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/12.jpg)
12
Dispatcher Module - Features
simple, lightweight extension - fast and reliable can combine load balancing and dispatching algorithms
as needed in the same configuration file can work with flat text file or database for loading routing
records can reload routing records at runtime (no need to restart) can auto-detect out-of-service destinations can ping destination to automatically inactivate/activate offers high flexibility in configuration file
event routes, access to attributes and list of destinations can detect if traffic is coming from an address in the
destinations list
![Page 13: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/13.jpg)
Scaling the load balancer
![Page 14: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/14.jpg)
14
Thank You, That’s All!
Nobody got to the upper limits of Kamailio
routing performances!!!
![Page 15: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/15.jpg)
15
... anyhow ...
... let’s do it just for research purposes ...
![Page 16: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/16.jpg)
Dispatcher Config - Stateful forwarding
16
# Dispatch requestsroute[DISPATCH] {! # round robin dispatching on gateways group '1'! if(!ds_select_dst("1", "4"))! {! ! send_reply("404", "No destination");! ! exit;! }! xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");! t_on_failure("RTF_DISPATCH");! t_relay(); exit;}# Failure re-routefailure_route[RTF_DISPATCH] {! if (t_is_canceled()) {! ! exit;! }! # next DST - only for 500 or local timeout! if (t_check_status("500")! ! ! or (t_branch_timeout() and !t_branch_replied()))! {! ! if(ds_next_dst())! ! {! ! ! t_on_failure("RTF_DISPATCH");! ! ! t_relay();! ! ! exit;! ! }! }}
![Page 17: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/17.jpg)
Dispatcher Config - Stateless forwarding
17
# Dispatch requestsroute[DISPATCH] {! # round robin dispatching on gateways group '1'! if(!ds_select_dst("1", "4"))! {! ! send_reply("404", "No destination");! ! exit;! }! xlog("L_DBG", "--- SCRIPT: going to <$ru> via <$du>\n");! forward(); exit;}
loadbalancer
![Page 18: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/18.jpg)
DNS SRV Load Balancing
18
_sip._udp.kamailio.com. IN SRV 10 1 5060 sip1.kamailio.com._sip._udp.kamailio.com. IN SRV 10 1 5065 sip2.kamailio.com._sip._udp.kamailio.com. IN SRV 10 1 6065 sip3.kamailio.com.
loadbalancer
![Page 19: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/19.jpg)
Load Balancing to /dev/null
19
request_route { ;}
![Page 20: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/20.jpg)
Load Balancing to One Host
20
request_route { rewritehostport(“1.2.3.4”); forward();}
request_route { forward(1.2.3.4);}
![Page 21: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/21.jpg)
Stateless Config Round Robin Load Balancer
21
loadmodule “sl.so”loadmodule “textops.so”loadmodule “pv.so”modparam("pv", "varset", "i=i:0")request_route { if(!is_method(“INVITE”)) { sl_send_reply(“404”, “Not Found”); exit; } $var(i) = ($var(i) + 1 ) mod 2; if($var(i)==1) { rewritehostport(“1.2.3.4”); } else { rewritehostport(“2.3.4.5”); } forward();}
Per Process Round Robin Routing!
![Page 22: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/22.jpg)
Stateless Config Round Robin Redirect Balancer
22
loadmodule “sl.so”loadmodule “textops.so”loadmodule “pv.so”modparam("pv", "varset", "i=i:0")request_route { if(!is_method(“INVITE”)) { sl_send_reply(“404”, “Not Found”); exit; } $var(i) = ($var(i) + 1 ) mod 2; if($var(i)==1) { rewritehostport(“1.2.3.4”); } else { rewritehostport(“2.3.4.5”); } sl_send_reply(“301”, “Moved Temporarily”);}
![Page 23: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/23.jpg)
Stateless Config Round Robin Load Balancer
23
loadmodule “sl.so”loadmodule “textops.so”loadmodule “pv.so”loadmodule “cfgutils.so”modparam("pv", "shvset", "i=i:0")modparam("cfgutils", "lock_set_size", 1)request_route { if(!is_method(“INVITE”)) { sl_send_reply(“404”, “Not Found”); exit; } lock(“balancing”); $shv(i) = ($shv(i) + 1 ) mod 2; $var(x) = $shv(i); unlock(“balancing”); if($var(x)==1) { rewritehostport(“1.2.3.4”); } else { rewritehostport(“2.3.4.5”); } forward();}
Per Instance Round Robin Routing!
![Page 24: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/24.jpg)
Scalability - Paritioning
24
USERSCALLS
USERSCALLS
USERSCALLS
![Page 25: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/25.jpg)
Scalability
25
USERSCALLS
USERSCALLS
USERSCALLS
![Page 26: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/26.jpg)
Scalability
26
![Page 28: Load Balancing Load Balancers - Kamailio...7 Dispatcher Module - Load Balancing dispatching algorithms compute an integer value using a hashing function hash over callid ensures that](https://reader030.vdocuments.net/reader030/viewer/2022033122/5e8f6512c742176290780d30/html5/thumbnails/28.jpg)
sponsors and exhibitors