Jump to content

load balace resources


abuzooz

Recommended Posts

Hi All

I am not sure this feature exist in Kazoo, but I guess so as I saw there is weight assigned in resources, what I am trying to do, is to define 3 servers as gateway for Kazoo (I used to have 1 and working perfectly) and Kazoo shall chose one of the servers for outbound calls randomly as I set the resources weight to be equal. However, it is always calling one server and if this server (gateway) is down the call fails.

Any Idea?

Dailplan regex is the same for all gatewaysimage.png.442b7fdbe8bbdef0364ba6f2a275ceba.png

 

 

Link to comment
Share on other sites

  • 2600Hz Employees

Look at the flag for 'gateway_strategy'; can be 'sequential' or 'random'. Then you can define one resource with 3 gateways and shuffle between them.

With resources of the same weight, there is no expected or implied order; its kinda up to the system and how things are fetched from the database.

Link to comment
Share on other sites

  • 3 weeks later...

Hi @mc_

If I understood you correctly, I added 1 resource with 3 gateways as below, still the first defined gateway will be always used and no load distribution is happening, am I doing anything wrong?

{
   "data":{
      "emergency":false,
      "enabled":true,
      "flags":[
         
      ],
      "gateways":[
         {
            "channel_selection":"ascending",
            "codecs":[
               "PCMU",
               "PCMA"
            ],
            "custom_sip_headers":{
               "out":{
                  "user_caller_id_number":"{caller_id_number}",
                  "user_caller_id_name":"{caller_id_name}",
                  "X-account-id":"{account_id}",
                  "X-Member":"{caller_id_name}"
               }
            },
            "emergency":false,
            "enabled":true,
            "endpoint_type":"sip",
            "format_from_uri":false,
            "gateway_strategy":"sequential",
            "invite_format":"route",
            "prefix":"",
            "progress_timeout":15,
            "realm":"bill.XXX.com",
            "server":"bill.XXX.com",

            "suffix":"",
            "username":"",
            "password":"",
            "Custom-Channel-Vars":{
               "Caller-Privacy-Hide-Name":false,
               "Caller-Privacy-Hide-Number":false
            },
            "force_port":false,
            "port":5060,
            "skype_rr":true
         },
         {
            "channel_selection":"ascending",
            "codecs":[
               "PCMU",
               "PCMA"
            ],
            "custom_sip_headers":{
               "out":{
                  "user_caller_id_number":"{caller_id_number}",
                  "user_caller_id_name":"{caller_id_name}",
                  "X-account-id":"{account_id}",
                  "X-Member":"{caller_id_name}"
               }
            },
            "emergency":false,
            "enabled":true,
            "endpoint_type":"sip",
            "format_from_uri":false,
            "gateway_strategy":"sequential",
            "invite_format":"route",
            "prefix":"",
            "progress_timeout":15,
            "realm":"bill2.XXX.com",
            "server":"bill2.XXX.com",

            "suffix":"",
            "username":"",
            "password":"",
            "Custom-Channel-Vars":{
               "Caller-Privacy-Hide-Name":false,
               "Caller-Privacy-Hide-Number":false
            },
            "force_port":false,
            "port":5060,
            "skype_rr":true
         },
         {
            "channel_selection":"ascending",
            "codecs":[
               "PCMU",
               "PCMA"
            ],
            "custom_sip_headers":{
               "out":{
                  "user_caller_id_number":"{caller_id_number}",
                  "user_caller_id_name":"{caller_id_name}",
                  "X-account-id":"{account_id}",
                  "X-Member":"{caller_id_name}"
               }
            },
            "emergency":false,
            "enabled":true,
            "endpoint_type":"sip",
            "format_from_uri":false,
            "gateway_strategy":"sequential",
            "invite_format":"route",
            "prefix":"",
            "progress_timeout":15,
            "realm":"bill3.XXX.com",
            "server":"bill3.XXX.com",

            "suffix":"",
            "username":"",
            "password":"",
            "Custom-Channel-Vars":{
               "Caller-Privacy-Hide-Name":false,
               "Caller-Privacy-Hide-Number":false
            },
            "force_port":false,
            "port":5060,
            "skype_rr":true
         }
      ],
      "grace_period":10,
      "gateway_strategy":"sequential",
      "media":{
         "audio":{
            "codecs":[
               "PCMU",
               "PCMA"
            ]
         },
         "video":{
            "codecs":[
               
            ]
         },
         "encryption":{
            "enforce_security":false,
            "methods":[
               
            ]
         }
      },
      "name":"bill.XXX.com",
      "rules":[
         "[1-9]\\d+"
      ],
      "weight_cost":50,
      "id":"billing"
   },
   "auth_token":"{auth_token}}"
}

Link to comment
Share on other sites

  • 2600Hz Employees

You want to set `gateway_strategy` to `random` on the top-level of the document (not per-gateway). See the schema at https://docs.2600hz.com/dev/applications/crossbar/doc/resources/

Sequential will dial the gateways in the order they appear in the array; random will shuffle the array and dial in that randomized order. Assuming the shuffle is "random" enough, you should see a roughly even balance of which gateway is dialed first.

Link to comment
Share on other sites

2 hours ago, mc_ said:

You want to set `gateway_strategy` to `random` on the top-level of the document (not per-gateway). See the schema at https://docs.2600hz.com/dev/applications/crossbar/doc/resources/

Sequential will dial the gateways in the order they appear in the array; random will shuffle the array and dial in that randomized order. Assuming the shuffle is "random" enough, you should see a roughly even balance of which gateway is dialed first.

I am not sure what I am doing wrong, I change where should I put gateway_strategy almost everywhere in the document with no luck,(trial #1 and trial #2 for example), somehow it is always using the first gateway defined in the document in below example (bill.xxx.com), and ignoring the gateway_strategy option, I tried to shuffel gateways and it is always selecting the first one.

 

am I doing something wrong here?

{

    "data": {
      
        "emergency"false,
        "enabled"true,
        "flags": [],
          "gateway_strategy":"sequential",        ---> tried it here  (trial #1)
        "gateways": [
            {
               "gateway_strategy":"sequential",        ---> tried it here (trial #2)
                "codecs": [
                    "PCMU",
                    "PCMA"
                ],
                "custom_sip_headers": {
                    "out": {
                        "user_caller_id_number""{caller_id_number}",
                        "user_caller_id_name""{caller_id_name}",
                        "X-account-id""{account_id}",
                        "X-Member""{caller_id_name}"
                    }
                },
                "emergency"false,
                "enabled"true,
                "endpoint_type""sip",
                "format_from_uri"false,
                "invite_format""route",
                "prefix""",
                "progress_timeout"15,
                "realm""bill.xxx.com",
                "server""bill.xxx.com",
                "suffix""",
                "username""",
                "password""",
                "Custom-Channel-Vars": {
                    "Caller-Privacy-Hide-Name"false,
                    "Caller-Privacy-Hide-Number"false
                },
                "force_port"false,
                "port"5060,
                "skype_rr"true
            },
             {
                "channel_selection""ascending",
                "codecs": [
                    "PCMU",
                    "PCMA"
                ],
                "custom_sip_headers": {
                    "out": {
                        "user_caller_id_number""{caller_id_number}",
                        "user_caller_id_name""{caller_id_name}",
                        "X-account-id""{account_id}",
                        "X-Member""{caller_id_name}"
                    }
                },
                "emergency"false,
                "enabled"true,
                "endpoint_type""sip",
                "format_from_uri"false,
                "invite_format""route",
                "prefix""",
                "progress_timeout"15,
                "realm""bill2.xxx.com",
                "server""bill2.xxx.com",
                "suffix""",
                "username""",
                "password""",
                "Custom-Channel-Vars": {
                    "Caller-Privacy-Hide-Name"false,
                    "Caller-Privacy-Hide-Number"false
                },
                "force_port"false,
                "port"5060,
                "skype_rr"true
            },
             {
                "channel_selection""ascending",
                "codecs": [
                    "PCMU",
                    "PCMA"
                ],
                "custom_sip_headers": {
                    "out": {
                        "user_caller_id_number""{caller_id_number}",
                        "user_caller_id_name""{caller_id_name}",
                        "X-account-id""{account_id}",
                        "X-Member""{caller_id_name}"
                    }
                },
                "emergency"false,
                "enabled"true,
                "endpoint_type""sip",
                "format_from_uri"false,
                "invite_format""route",
                "prefix""",
                "progress_timeout"15,
                "realm""bill3.xxx.com",
                "server""bill3.xxx.com",
                "suffix""",
                "username""",
                "password""",
                "Custom-Channel-Vars": {
                    "Caller-Privacy-Hide-Name"false,
                    "Caller-Privacy-Hide-Number"false
                },
                "force_port"false,
                "port"5060,
                "skype_rr"true
            }
        ],
        "grace_period"10,
        "media": {
            "audio": {
                "codecs": [
                    "PCMU",
                    "PCMA"
                ]
            },
            "video": {
                "codecs": []
            },
            "encryption": {
                "enforce_security"false,
                "methods": []
            }
        },
        "name""billing",
        "rules": [
            "[1-9]\\d+"
        ],
        "weight_cost"100,
        "id""billing"
    },
     "auth_token""{auth_token}}"
}
Link to comment
Share on other sites

1 hour ago, mc_ said:

This has been part of 4.3 since 4.3.90: https://github.com/2600hz/kazoo/releases/tag/4.3.90

So make sure you have a version >= .90.

But, more importantly, you continue to show examples using "sequential". That means "in the order they appear in the gateways array".

Thank you @mc_ the version I have is 4.3-126, somehow when I changed the strategy to "random" it worked, the strange thing when using sequential it keeps using the same gateway without changing, over and over.

I am glad with random it worked, thanks again for your help!

Edited by abuzooz (see edit history)
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...