Load balancing solution using pure FreeSWITCH
Hi dear FS community, After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109) and ( http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL). It works on few of our servers right now without any issues. Feel free to reuse / improve it or provide your comments if you see something wrong with it. We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration. --> MS_1 RS --> MS_2 --> MS_N (Failover can be implemented by adding one more routing server, but this is out of scope of current description). Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers). Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml). Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests). The whole routing can be presented by the following chain: Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well). *1. RS Dialplan: default.xml* <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include> *2. RS Lua script: route.lua* called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string); *3. PHP script: get_server_ip.php* <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip); All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds. Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools. P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true"); Best regards, vIT
this is something you took from Mera .. isn't it ? :) On Tue, Mar 16, 2010 at 1:04 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Hi dear FS community,
After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109) and ( http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL).
It works on few of our servers right now without any issues.
Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration.
--> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description).
routing server is your single point of failure, you should make two of them in active/standby mode. What about registered endpoints ? ... where do you register them?.... you should have a DB replication in order to have the "registered context" distributed between both routing servers So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers.
Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
you will be loosing calls on the on the MS if it goes down ... maybe there
is a way to "replace" media resource for that calls and keep them going even after the MS went down.
Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml). Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
consider ODBC in the core!
The whole routing can be presented by the following chain:
Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End
Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well).
*1. RS Dialplan: default.xml* <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
*2. RS Lua script: route.lua* called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string);
do your bridging in the dialplan not from a script... you will get better performances!
*3. PHP script: get_server_ip.php* <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools.
P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
anyhow it is a good start ... with a custom module for media server "kepalive" and resource migration it could be a great solution. T.
Hi Tihomir, What do you mean by "took from Mera"? If someone else already implemented this, could you please provide me a link? This solution was invented by me personally, after looking into the following: http://wiki.freeswitch.org/wiki/SBC_Setup They use Kamailio layer as routing, I decided that we can avoid this and use OOB things. Thanks for your reply, it can add more value to the solution. Regards, vIT 2010/3/16 Tihomir Culjaga <tculjaga@gmail.com>
this is something you took from Mera .. isn't it ? :)
On Tue, Mar 16, 2010 at 1:04 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Hi dear FS community,
After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109) and ( http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL).
It works on few of our servers right now without any issues.
Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration.
--> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description).
routing server is your single point of failure, you should make two of them in active/standby mode. What about registered endpoints ? ... where do you register them?.... you should have a DB replication in order to have the "registered context" distributed between both routing servers
So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers.
Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
you will be loosing calls on the on the MS if it goes down ... maybe there
is a way to "replace" media resource for that calls and keep them going even after the MS went down.
Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml). Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
consider ODBC in the core!
The whole routing can be presented by the following chain:
Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End
Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well).
*1. RS Dialplan: default.xml* <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
*2. RS Lua script: route.lua* called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string);
do your bridging in the dialplan not from a script... you will get better performances!
*3. PHP script: get_server_ip.php* <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools.
P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
anyhow it is a good start ... with a custom module for media server "kepalive" and resource migration it could be a great solution.
T.
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I have read the document and except that it describes one signalling server and three media servers with routing to less busiest server it has nothing else related to solution I wrote for FreeSWITCH. Basically topology and high level part will be repeated in any solutions, because this is obvious for everyone. The same topology as described in this document and by me will be created using any routing server (OpenSIPS or whatever) and will come to the mind of most people that need to implement load balancing. Regards, vIT 2010/3/16 Tihomir Culjaga <tculjaga@gmail.com>
On Tue, Mar 16, 2010 at 2:19 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Hi Tihomir, What do you mean by "took from Mera"? If someone else already implemented this, could you please provide me a link?
read the file attached :)
T.
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Tue, Mar 16, 2010 at 5:28 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
I have read the document and except that it describes one signalling server and three media servers with routing to less busiest server it has nothing else related to solution I wrote for FreeSWITCH. Basically topology and high level part will be repeated in any solutions, because this is obvious for everyone. The same topology as described in this document and by me will be created using any routing server (OpenSIPS or whatever) and will come to the mind of most people that need to implement load balancing.
Regards, vIT
it is just the topology that is the same ... RS + MS, after that you are on your own... that's what i meant.
T.
Vit: Nice email, very informative; curious to find out the reasons why you decided to go with FS instead of OpenSip. We soon have to make a similar decision and would like to find out the rationale behind it. Thanks, Alfredo On Tue, Mar 16, 2010 at 8:04 AM, Vitalii Colosov <vetali100@gmail.com> wrote:
Hi dear FS community, After a brief analysis of 2 solutions using OpenSIPS and Kamailio (http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109 ) and (http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL). It works on few of our servers right now without any issues. Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration. --> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description). Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml). Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
The whole routing can be presented by the following chain: Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well). 1. RS Dialplan: default.xml <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
2. RS Lua script: route.lua called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string); 3. PHP script: get_server_ip.php <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools. P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
Best regards, vIT
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Basically this solution gives me exactly what I need at the moment. If there is a still special reason to use OpenSIPS, maybe we should expect opinion of some better FS experts then me :-) vIT 2010/3/16 Alfredo Quiroga-Villamil <lawwton@gmail.com>
Vit:
Nice email, very informative; curious to find out the reasons why you decided to go with FS instead of OpenSip. We soon have to make a similar decision and would like to find out the rationale behind it.
Thanks,
Alfredo
On Tue, Mar 16, 2010 at 8:04 AM, Vitalii Colosov <vetali100@gmail.com> wrote:
Hi dear FS community, After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109 ) and (http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL). It works on few of our servers right now without any issues. Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration. --> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description). Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
Routing server is used to register subscribers (it will have directory files ./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml). Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
The whole routing can be presented by the following chain: Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well). 1. RS Dialplan: default.xml <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
2. RS Lua script: route.lua called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string); 3. PHP script: get_server_ip.php <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools. P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
Best regards, vIT
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Tihomir, Could you please add more details to the following? "So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers." Do you have any links that describe how to implement this kind of fail over? I thought about configuring 2 DNS servers on 2 Routing servers, so if one will go down, traffic will be addressed to another, but at the moment I don't have enough knowledge how to implement this. Thanks, vIT 2010/3/16 Vitalii Colosov <vetali100@gmail.com>
Basically this solution gives me exactly what I need at the moment.
If there is a still special reason to use OpenSIPS, maybe we should expect opinion of some better FS experts then me :-)
vIT
2010/3/16 Alfredo Quiroga-Villamil <lawwton@gmail.com>
Vit:
Nice email, very informative; curious to find out the reasons why you decided to go with FS instead of OpenSip. We soon have to make a similar decision and would like to find out the rationale behind it.
Thanks,
Alfredo
On Tue, Mar 16, 2010 at 8:04 AM, Vitalii Colosov <vetali100@gmail.com> wrote:
Hi dear FS community, After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109 ) and (http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL). It works on few of our servers right now without any issues. Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration. --> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description). Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
Routing server is used to register subscribers (it will have directory files
./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml).
Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
The whole routing can be presented by the following chain: Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well). 1. RS Dialplan: default.xml <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
2. RS Lua script: route.lua called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string); 3. PHP script: get_server_ip.php <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools. P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
Best regards, vIT
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Tue, Mar 16, 2010 at 6:31 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Tihomir, Could you please add more details to the following?
"So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers."
no problem, you can update your knowledge base for free, check http://www.linux-ha.org/wiki/Main_Page
Do you have any links that describe how to implement this kind of fail over?
I thought about configuring 2 DNS servers on 2 Routing servers, so if one will go down, traffic will be addressed to another, but at the moment I don't have enough knowledge how to implement this.
Thanks, vIT
2010/3/16 Vitalii Colosov <vetali100@gmail.com>
Basically this solution gives me exactly what I need at the moment.
If there is a still special reason to use OpenSIPS, maybe we should expect opinion of some better FS experts then me :-)
vIT
2010/3/16 Alfredo Quiroga-Villamil <lawwton@gmail.com>
Vit:
Nice email, very informative; curious to find out the reasons why you decided to go with FS instead of OpenSip. We soon have to make a similar decision and would like to find out the rationale behind it.
Thanks,
Alfredo
On Tue, Mar 16, 2010 at 8:04 AM, Vitalii Colosov <vetali100@gmail.com> wrote:
Hi dear FS community, After a brief analysis of 2 solutions using OpenSIPS and Kamailio ( http://www.opensips.org/html/docs/modules/devel/load_balancer.html#id226109 ) and (http://wiki.freeswitch.org/wiki/SBC_Setup) I decided to implement my own solution using ONLY FreeSWITCH and ONLY 1 table of any database server (we use MySQL). It works on few of our servers right now without any issues. Feel free to reuse / improve it or provide your comments if you see something wrong with it.
We have one routing server (RS) and several Media Servers (MS). FreeSWITCH is installed on each server in default configuration. --> MS_1 RS --> MS_2 --> MS_N
(Failover can be implemented by adding one more routing server, but this is out of scope of current description). Routing server routes calls to media servers based on logic that you can easily define. (Generally speaking, Routing server can route part of the calls onto itself, but to simplify let's say that it will route only to Media Servers).
Routing server is used to register subscribers (it will have directory files
./freeswitch/conf/directory/default/10001whatever.xml-99999whatever.xml).
Media servers do NOT contain files with users (security issue? probably should be managed on dialplan stage of media servers by comparing ip addresses of requests).
The whole routing can be presented by the following chain: Call arrives into Default context-->RS default dialplan-->Lua script-->PHP script to get destination MEDIA SERVER IP-->back to Lua script-->Bridge "sofia/external/" to determined MS IP address-->[Bridge to fail over media server, optionally]-->End Let's say we need to route all international calls based on less loaded server (other logic can be easily implemented in PHP script as well). 1. RS Dialplan: default.xml <include> <extension name="route"> <condition field="destination_number" expression="^(00)(\d+)"> <action application="lua" data="route.lua $2"/> </condition> </extension> </include>
2. RS Lua script: route.lua called_number = argv[1]; //without "00" api = freeswitch.API(); server_ip_address = api:executeString("curl http://localhost/get_server_ip.php); forwarding_session_string = "sofia/external/"..called_number.."@"..server_ip_address; session:setVariable("bypass_media", "true"); //described below!!! session:execute("bridge",forwarding_session_string); 3. PHP script: get_server_ip.php <<< ANY PHP CODE THAT WILL QUERY COMMON DATABASE AND WILL DETERMINE LESS LOADED AT THE MOMENT SERVER>>> die($less_loaded_server_ip);
All Media Servers should provide information about their current load into one common database (dedicated server or routing server can be used for database). If you use scripts you can update this table on starting a call and after call finished. Or you can create a job that will query FreeSWITCH and will update the database every, say, 10 seconds.
Basically that's all (really!) I beleive it can be used for most general purpose scenarios without need of third-party tools. P.S. The only problem we had from the beginning was that RTP media traffic was passing thru both servers: RS and Media Server. But after we added the following command to the routing script, RTP media traffic started to pass only thru Media server, making RS almost free. session:setVariable("bypass_media", "true");
Best regards, vIT
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE: http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Ghulam Mustafa cell: +92 333.611.7681 sip: cyrenity@ekiga.net mail: mustafa.pk@gmail.com web: cyrenity.wordpress.com
On Tue, Mar 16, 2010 at 2:31 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Tihomir, Could you please add more details to the following?
"So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers."
Do you have any links that describe how to implement this kind of fail over?
This is the topic for you: http://www.ultramonkey.org/3/topologies/ and this is what i already have implemented: http://www.ultramonkey.org/3/topologies/ha-eg.html
I thought about configuring 2 DNS servers on 2 Routing servers, so if one will go down, traffic will be addressed to another, but at the moment I don't have enough knowledge how to implement this.
don't like the idea as you are introducing one more point of failure :)
Thanks, vIT
Using it you still have one point of failure - only one router and it's on one internet line... What if one of these things goes down for a period? :-) I would prefer to have 2 separate servers on 2 different internet lines (better different providers even). Thanks, vIT 2010/3/16 Tihomir Culjaga <tculjaga@gmail.com>
On Tue, Mar 16, 2010 at 2:31 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Tihomir, Could you please add more details to the following?
"So, i'd suggest to bring up a LAN_HA and have a floating address between your routing servers.... of course the you should be using ODBC in the core to have registrations on both servers."
Do you have any links that describe how to implement this kind of fail over?
This is the topic for you: http://www.ultramonkey.org/3/topologies/ and this is what i already have implemented: http://www.ultramonkey.org/3/topologies/ha-eg.html
I thought about configuring 2 DNS servers on 2 Routing servers, so if one will go down, traffic will be addressed to another, but at the moment I don't have enough knowledge how to implement this.
don't like the idea as you are introducing one more point of failure :)
Thanks, vIT
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
On Tue, Mar 16, 2010 at 4:51 PM, Vitalii Colosov <vetali100@gmail.com>wrote:
Using it you still have one point of failure - only one router and it's on one internet line...
What if one of these things goes down for a period? :-)
well, thats something out of our reach ... we are taking care about the application and services that are working on top.... well the network is a totally different topic and it has to be addressed with care.
I would prefer to have 2 separate servers on 2 different internet lines (better different providers even).
right ... with BGP/MPLS in between as well ... as i said it is a different topic :)
Thanks, vIT
participants (4)
-
Alfredo Quiroga-Villamil
-
Ghulam Mustafa
-
Tihomir Culjaga
-
Vitalii Colosov