Load Balancing Asterisk Cluster

I am looking at some options to better balance our Asterisk cluster. Right now we are fronting our Asterisk cluster with Opensips and it’s just doing a basic round robin. Once the call hits a particular Asterisk instance, it’s checking a table to see if that particular company has calls on another server. If it does, then it’s rejecting the call back up to the proxy and sent to another server, where it’s checked until it lands on the proper server. We do this so that calls for one company are on the same server for call transfers and call queues.

This approach works, but it gets us in some bad spots where all the calls load up one server just because a couple big companies land on that server. We would like to just force calls to that same server just if the call is going to a queue or if they are attempting an attended transfer. So basically a particular queue for a particular company will only be on one server at a time.

Do anyone have any suggestions on how to move an entire call to another server including channel variables and cdr? The problem with trying to move a call once it’s determined to be a queue call is that we have already gone through hundreds of lines of dialplan and built up a lot of channel variables that are needed to properly route the call and maintain good records of the details of the call.

Opensips 1.6
Asterisk 11.20.0
Mysql 5.5

You can’t. Asterisk is not something you can “cluster” in that way. If you route a call to Box A that is where the call is. If that call needed to be on Box B for a conference bridge, then you need to route that call to Box B from OpenSIPs.

Round Robining to multiple Asterisk boxes is fine when you’re just pushing calls through it that either route to the PSTN or back through OpenSIPs or over to another box for X function. However, trying to provide a single company with a PBX over multiple systems isn’t going to work since each call exists on the box it lands on.

You might want to modify the round-robin to include server affinity eg. big company A always lands on server A, B on B, etc.

Just before you enter Queue()/Transfer()/etc., you might be able to collect the minimum variables you need and push them into your database using func_odbc, then let the receiving server dip in there to pull back out what it needs after you move the call over.

Which comes right back to the issue of you can’t do this. If the user makes a call and they are routed to PBX A that’s where they are. You can’t magically move them over to PBX B. How would you do that?

How are you going to move all those variables and settings over to PBX B? How are you going to start a new channel over at PBX B? How are you going to update the Loose Routing and all the of the SIP messages that are telling the transaction where to go/expect replies from? How about the SDP information for the audio?

What I have been trying to do is when I looking in the DB with func_odbc and see that this company has calls for this queue on another server, I basically dial that peer and route it to a context to go through and retrieve all the HASH data from the db again I need to process the call and send it to QUEUE().

However, now I have two CDRs for this call, call recordings are messed up, and double the amount of hits on the DB. My only thought is to do something with CEL to know when this happens and try to clean up the data with a stored procedure when the call ends.

I appreciate you guys helping out, I’ll take any suggestions you might have.

I couldn’t get the transfer to work correctly to another Asterisk Peer. Should this work?

You might need to add more hops.

For example, consider SIP ingress PBXes 1, 2, 3, 4; and SIP egress PBXes A, B, C, D. Bridge ingress and egress over IAX (not SIP). Transfers can filter out extra hops better with IAX (sometimes.) Call flow might look like:

  1. Call comes in from ITSP to Opensips.
  2. Opensips load balances to PBX 2.
  3. PBX 2 load balances and/or business logic balances to PBX D.
  4. Now call is running: Caller -> ITSP -> OpenSIPs -> PBX 2 -> PBX D -> Callee.
  5. Callee now wishes to transfer caller into a queue.
  6. PBX D business logic uses in-dial plan Transfer() to PBX C.
  7. PBX 2 sees IAX end-to-end and moves call from PBX D to PBX C.
  8. Callee and PBX D both drop out.
  9. Now call is running: Caller -> ITSP -> OpenSIPs -> PBX 2 -> PBX C -> Queue.

Also you could probably do it with more OpenSIPs configuration. Or more ITSP magic.

This is a complete nightmare and a horrible solution for this. I would advise against it. If you have Client A with IVRs, Queues, X users, etc you can’t load balance that across three Asterisk systems.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.