Kamailio load balancing with dynamic routing

956 views Asked by At

How can I divide all incoming traffic between 3 servers with the following information? I am configuring kamailio with 3 or more asterisk servers. I configured dr_rules.gwlist table on database.

mysql> select * from dr_gateways;
+------+------+--------------------+-------+------------+-------+-------------+
| gwid | type | address            | strip | pri_prefix | attrs | description |
+------+------+--------------------+-------+------------+-------+-------------+
|    5 |   10 | 192.168.50.11:5060 |     0 | NULL       | NULL  |             |
|    6 |   10 | 192.168.50.12:5060 |     0 | NULL       | NULL  |             |
|    9 |   10 | 192.168.50.16:5060 |     0 | NULL       | NULL  |             |
+------+------+--------------------+-------+------------+-------+-------------+
3 rows in set (0.00 sec)

mysql> select * from dr_rules;
+--------+---------+----------+-----------------+----------+---------+-----------------------+-------------+
| ruleid | groupid | prefix   | timerec         | priority | routeid | gwlist                | description |
+--------+---------+----------+-----------------+----------+---------+-----------------------+-------------+
|     13 | 0       | 70704070 |                 |        0 | 0       | 6,9;9,6;6,9,5 |             |
+--------+---------+----------+-----------------+----------+---------+-----------------------+-------------+
7 rows in set (0.00 sec)

I want to balance all traffic with 70704070 prefix to 3 server with follow priority:

gwid6 = 40%

gwid9 = 40%

gwid5 = 20%

1

There are 1 answers

0
arheops On

Use RANDOM https://kamailio.org/docs/modules/1.3.x/cfgutils.html#AEN165

After that use dispatcher or other gateway managment module(or just read from db with htable caching)