How can I load FastAGI balance?

I am writing several AGIs using Perl that will be called from the Asterisk dialplan. I expect to receive numerous simultaneous calls, so I need a way to download their balance. I recommend using FastAGI instead of AGI. The problem is that my AGIs will be distributed across many servers, not just one at a time, and I need my Asterisk entry point to send calls between these servers (where agis is located) depending on their availability. So, I thought that the FastAGI application uses several IP addresses instead of one. Is it possible?

+3
source share
3 answers

Any reverse TCP proxy will do the trick. HAProxy is one and nginx using the TCP module is another.

While I was back, I created my own FastAGI proxy using node.js ( nodast ) to solve this problem and a bit more, including the ability to run the FastAGI protocol via SSL and route requests based on location and request parameters AGI (such as $ dnis, $ channel, $ language, ...)

In addition, since the proxy configuration is mainly javascript, you can really load balance in a really interesting way.

An example configuration will look like this:

var config = {
    listen : 9090,
    upstreams : {
        test : 'localhost:4573',
        foobar : 'foobar.com:4573'
    },
    routes : {
        'agi://(.*):([0-9]*)/(.*)' : function() {
            if (this.$callerid === 'unknown') {
                return ('agi://foobar/script/' + this.$3);
            } else {
                return ('agi://foobar/script/' + this.$3 + '?callerid' + this.$callerid);
            }
        },
        '.*' : function() {
            return ('agi://test/');
        },
        'agi://192.168.129.170:9090/' : 'agi://test/'
    }
};
exports.config = config; 
+2
source

IVR FastAGI (24 E1, FastAGI, 80%, 600 Asterisk FastAGI). , FastAGI: , , , .

, .

, zaptel/dahdi, . , , 2 FastAGI 4 E1. 2 E1 g1 2 E1 g2. :

[globals]
serverg1=ip_of_server1
serverg2=ip_of_server2

FastAGI :

AGI(agi://${server${CHANNEL(callgroup)}}/some_action)

, g1, g1, ip_of_server1; , g2, CHANNEL (callgroup) g2, ${serverg2}, ip_of_server2.

, , .., , -.

, , FastAGI, ...

+1

Mehhh... , , , -.

- robin DNS. , vru1.example.com 10.0.1.100 vru2.example.com 10.0.1.101, DNS, ...

fastagi.example.com 10.0.1.100

fastagi.example.com 10.0.1.101

... agi (agi://fastagi.example.com/youagi) 10.0.1.100 10.0.1.101. , .

Another way to go with something too complicated to explain here, but proxies like HAProxy should be able to route between multiple servers with the added benefit of being able to “pull one out” into the mix for maintenance or make it more advanced balancing, for example, to distribute equally on the basis of the current load.

+1
source

Source: https://habr.com/ru/post/1710239/


All Articles