Openser中文网

专注于VoIP,Opensips,Kamailio等技术,QQ群:QQ群:293697898

对比OpenSIPS的Load balancer、Dispatcher和Kamailio的Dispatcher使用


tags:opensips load_balancer dispatcher kamilio 创建时间:2024-05-26 09:11:06

  1. 先看看数据表:

Kamailio dispatcher:

`CREATE TABLE dispatcher ( id SERIAL PRIMARY KEY NOT NULL, setid INTEGER DEFAULT 0 NOT NULL, destination VARCHAR(192) DEFAULT ' NOT NULL, flags INTEGER DEFAULT 0 NOT NULL, priority INTEGER DEFAULT 0 NOT NULL, attrs VARCHAR(128) DEFAULT ' NOT NULL, description VARCHAR(64) DEFAULT ' NOT NULL );

INSERT INTO version (table_name, table_version) values ('dispatcher','4'); `

OpenSIPS dispatcher:

`INSERT INTO version (table_name, table_version) values ('dispatcher','9'); CREATE TABLE dispatcher ( id SERIAL PRIMARY KEY NOT NULL, setid INTEGER DEFAULT 0 NOT NULL, destination VARCHAR(192) DEFAULT ' NOT NULL, socket VARCHAR(128) DEFAULT NULL, state INTEGER DEFAULT 0 NOT NULL, probe_mode INTEGER DEFAULT 0 NOT NULL, weight VARCHAR(64) DEFAULT 1 NOT NULL, priority INTEGER DEFAULT 0 NOT NULL, attrs VARCHAR(128) DEFAULT ' NOT NULL, description VARCHAR(64) DEFAULT ' NOT NULL );

ALTER SEQUENCE dispatcher_id_seq MAXVALUE 2147483647 CYCLE;`

OpenSIPS load_balancer:

`INSERT INTO version (table_name, table_version) values ('load_balancer','3'); CREATE TABLE load_balancer ( id SERIAL PRIMARY KEY NOT NULL, group_id INTEGER DEFAULT 0 NOT NULL, dst_uri VARCHAR(128) NOT NULL, resources VARCHAR(255) NOT NULL, probe_mode INTEGER DEFAULT 0 NOT NULL, attrs VARCHAR(255) DEFAULT NULL, description VARCHAR(128) DEFAULT NULL );

ALTER SEQUENCE load_balancer_id_seq MAXVALUE 2147483647 CYCLE; CREATE INDEX load_balancer_dsturi_idx ON load_balancer (dst_uri);`

  1. 看看库依赖

Kamailio

  1. Dependencies

2.1. Kamailio modules

The following modules must be loaded before this module:

TM - only if active recovery of failed hosts is required.

database engine - only if you want to load balancing routes from database instead of plain text file. .

2.2. External libraries or applications

The following libraries or applications must be installed before running Kamailio with this module:

none.

OpenSIPS dispatcher依赖

1.2. Dependencies

1.2.1. OpenSIPS modules

The following modules must be loaded before this module:

TM - only if active recovery of failed hosts is required.

clusterer - only if "cluster_id" option is enabled.

database - one of the DB SQL modules

freeswitch - only if "fetch_freeswitch_stats" is enabled..

1.2.2. External libraries or applications

The following libraries or applications must be installed before running OpenSIPS with this module:

none.

OpenSIPS load balancer依赖

1.4. Dependencies

1.4.1. OpenSIPS Modules

The following modules must be loaded before this module:

Dialog - Dialog module

freeswitch. - only if "fetch_freeswitch_stats" is enabled.

dialog - TM module (only if probing is enabled)

clusterer - only if "cluster_id" option is enabled.

database - one of the DB modules

1.4.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

None.

  1. 对比sql语句

Kamailio dispatcher

INSERT INTO "dispatcher" VALUES(1,1,'sip:192.168.0.1:5060',0,12,'rweight=50;weight=50;cc=1;','); INSERT INTO "dispatcher" VALUES(2,1,'sip:192.168.0.2:5060',0,12,'rweight=50;weight=50;cc=1;',');

OpenSIPS load_balancer

insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.103', 'pstn=32', 'FS1'); insert into load_balancer (group_id, dst_uri, resources, description) values (1,'sip:100.100.100.104', 'pstn=32', 'FS2'); OpenSIPS dispatcher的与Kamailio的类似

  1. 实际使用

在面对要进行负载均衡等时,特别是针对话务,我们优先选择OpenSIPS的load_balancer模块,是由于它:

a. 当OpenSIPS将呼叫路由到一组目标时,它能够保留每个目标的负载状态(作为正在进行的呼叫数),并选择路由到负载较少的目标.

b. load_balancer模块能够接收来自目的地的反馈,从而决定它是不是有效的。

c. 它必须依赖内置的Dialog模块为它提供服务。

但是opensips load balancer和kamailio的dispatcher有个缺点,在面临多网卡时,不能象Opensips dispatcher那样指定某个网卡

也就是说,load balancer模块,不是只proxy过去就不管了,而是基于dialog过程获取你到底行不行的干预。

所以,在针对语音SIP进行负载均衡时,OpenSIPS的load_balancer模块要优于dispatcher模块(不论是OpenSIPS还是Kamailio)。



如果在有疑问或需要沟通的地方,可以QQ:1354608370 或 加FreeSWITCH+Kamailio+Opensips QQ群: 293697898 沟通交流!