Dispatchers

326 views
Skip to first unread message

paulg...@gmail.com

unread,
Dec 21, 2021, 1:23:43 PM12/21/21
to CGRateS
Hi All

Back to my Cgrates project to migrate from my current kamailio/asterisk/a2billing setup after some time putting to one side.

Have managed to get a full Kamailio/RTPengine failover setup in AWS (including keeping call active at least on UDP/TCP) with just CGRates at back end. Have dropped Kubernetes as a target deployment architecture and have gone back to using VMs/Docker native in EC2 for CGRates.

Now that I am happy with the resilience on Kamailio/RTPEngine side I would like to architect the CGrates side properly.

I am using AWS resilient databases in Elasticache Redis for Datadb and AWS Aurora MYSQL for stordb which work great with added benefit of sharing same Redis instance for RTPEngine failover keyspace notifications.

I am trying to understand more about Dispatchers as I think this will enable my active/active resilient backend for CGRates but I am struggling to find examples of the config I need.

Essentially I want it to work like this
Kamailio/SessionS Cluster -> Dispatchers Cluster and then based on Account filters route to a consistent CGrates Rals (as I know you cant have the same account interacting with two Rals at once due to the in memory nature of CGRates ). If a Rals goes down I want the Account filter config to route to the next Rals on the list.

This way I can get Active/Standby at the Kamailio end and Active/Active... on the back end.

Am I in the right direction? Would be grateful if you could point me in the the right direction to a config for Dispatchers that could do what I want or maybe I have missed the point of Dispatchers.

thanks
Paul

paulg...@gmail.com

unread,
Dec 21, 2021, 1:38:12 PM12/21/21
to CGRateS
Or maybe the Dispathchers and Sessions can be merged together on same CGrates instance? As I cant see an example that covers this I am not sure

Paul Walsh

unread,
Dec 21, 2021, 6:10:06 PM12/21/21
to cgr...@googlegroups.com
I think I found what I’m looking for in the tariff plans examples. Sorry, I was looking earlier but couldn’t find it


I set a session attribute something like RalGroup that is used to distribute the accounts across the Rals

Then in the profiles using filter on the attribute I route each group to the Dispatcher RAL connections using a *weight strategy.

E.g 
Group1 goes to RAL1,2,3 in weight order
Group2 goes to RAL2,3,1 in weight order
Group3 goes to RAL3,1,2 in weight order 

I think that achieves what I am trying to do


--
You received this message because you are subscribed to the Google Groups "CGRateS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cgrates+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/70d92552-d596-4df8-9059-f304349b03dbn%40googlegroups.com.

paulg...@gmail.com

unread,
Dec 22, 2021, 10:20:56 PM12/22/21
to CGRateS
Just to update back in case anyone lands on this post.

Got it working as described above after a bit of playing around

DispatcherHosts looks like this

#Tenant[0],ID[1],Address[2],Transport[3],TLS[4]
thetenant.ie,DH_EU_CGR_1,eu-cgr-1:2012,*json,false
thetenant.ie,DH_EU_CGR_2,eu-cgr-2:2012,*json,false
thetenant.ie,DH_EU_CGR_3,eu-cgr-3:2012,*json,false

DispatcherProfiles looks like this
#Tenant,ID,Subsystems,FilterIDs,ActivationInterval,Strategy,StrategyParameters,ConnID,ConnFilterIDs,ConnWeight,ConnBlocker,ConnParameters,Weight
thetenant.ie,DP_RAL_GROUP_1,*any,*string:~*req.RalGroup:1,,*weight,,DH_EU_CGR_1,,30,false,,20
thetenant.ie,DP_RAL_GROUP_1,,,,,,DH_EU_CGR_2,,20,,,
thetenant.ie,DP_RAL_GROUP_1,,,,,,DH_EU_CGR_3,,10,,,
thetenant.ie,DP_RAL_GROUP_2,*any,*string:~*req.RalGroup:2,,*weight,,DH_EU_CGR_2,,30,false,,20
thetenant.ie,DP_RAL_GROUP_2,,,,,,DH_EU_CGR_3,,20,,,
thetenant.ie,DP_RAL_GROUP_2,,,,,,DH_EU_CGR_1,,10,,,
thetenant.ie,DP_RAL_GROUP_3,*any,*string:~*req.RalGroup:3,,*weight,,DH_EU_CGR_3,,30,false,,20
thetenant.ie,DP_RAL_GROUP_3,,,,,,DH_EU_CGR_1,,20,,,
thetenant.ie,DP_RAL_GROUP_3,,,,,,DH_EU_CGR_2,,10,,,
thetenant.ie,DP_RAL_GROUP_NOT_FOUND,*any,,,*random,,DH_EU_CGR_1,,30,false,,10
thetenant.ie,DP_RAL_GROUP_NOT_FOUND,,,,,,DH_EU_CGR_2,,20,,,
thetenant.ie,DP_RAL_GROUP_NOT_FOUND,,,,,,DH_EU_CGR_3,,10,,,

Session Attribute for Dispatcher is called RalGroup in my example. 

#Tenant,ID,Contexts,FilterIDs,ActivationInterval,AttributeFilterIDs,FieldName,Type,Value,Blocker,Weight
thetenant.ie,AT_AU_35345987653,simpleauth,FI_AC_35345987653,,,*req.Password,*constant,hello,false,10
thetenant.ie,AT_SS_35345987653,*sessions,FI_AC_35345987653,,,*req.Password,*constant,hello,false,20
thetenant.ie,AT_SS_35345987653,,,,,*req.RequestType,*constant,*prepaid,,
thetenant.ie,AT_SS_35345987653,,,,,*req.RalGroup,*constant,3,,
thetenant.ie,AT_SS_35345987653,,,,,*req.Country,*constant,IE,,

Before it has this value in the session it can go to any Cgrates Attributes instance for simpleauth. When it does get it the *string:~*req.RalGroup:3 filter in DispatcherProfiles  will ensure the Dispatcher routes queries to its "sticky" cgrates host for everything else (with failover)


Sessions + Dispatchers only are enabled on the Cgrates instance thats colocated with Kamailio server with config like below (needs Datadb to get the dispatcher info)

{

// Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
// Copyright (C) ITsysCOM GmbH

"general": {
  "node_id":"eu-kam-1",
  "reply_timeout": "5s",
  "logger": "*stdout",
  "log_level": 7,
},

"listen": {
        "rpc_json": "eu-kam-1:2012",
        "rpc_gob": "eu-kam-1:2013",
        "http": "eu-kam-1:2080",
},

"data_db": {
        "db_type": "*redis",
        "db_host": "redis.url",
        "db_port": 6379,
        "db_name": "10",
},

"rpc_conns": {
        "birpcconn": {
                "strategy": "*first",
                "conns": [{"address": "eu-kam-1:2014", "transport": "*json"}],
        },
        "dispatcherconn": {
                "strategy": "*first",
                "conns": [{"address": "eu-kam-1:2012", "transport": "*json"}],
        },
        "session_replication_cgrates": {
                "strategy": "*first",
                "conns": [{"address": "eu-kam-2:2012", "transport": "*json"}],
        },
},

"caches":{
    "*dispatcher_profiles" : {"limit": 10000, "ttl":"5s", "precache": true},
    "*dispatcher_hosts" : {"limit": 10000, "ttl":"5s", "precache": true},        
    "*dispatcher_routes": {"limit": -1, "ttl": "5s"},
},

"sessions": {
        "enabled": true,
        "listen_bijson": "eu-kam-1:2014",
        "rals_conns": ["dispatcherconn"],
        "cdrs_conns": ["dispatcherconn"],
        "resources_conns": ["dispatcherconn"],
        "suppliers_conns": ["dispatcherconn"],
        "attributes_conns": ["dispatcherconn"],
        "stats_conns": ["dispatcherconn"],
        "routes_conns": ["dispatcherconn"],
        "thresholds_conns": ["dispatcherconn"],
        "chargers_conns": ["dispatcherconn"],
        "replication_conns": ["session_replication_cgrates"],
        "min_call_duration": "1s",
        "max_call_duration": "3h",
        "min_dur_low_balance": "5s",
        "debit_interval": "10s",
        "store_session_costs": true,
        "channel_sync_interval":"5m",
},

"dispatchers": {
        "enabled": true,
},

"kamailio_agent": {
  "enabled": true,
  "evapi_conns":[{"address": "eu-kam-1:8448", "reconnects": 10}],
  "sessions_conns": ["birpcconn"],
  "create_cdr": false,
},

}

One thing to note was that on the v10.2 current build I got an error saying there was a missing mandatory parameter ArgDispatcher on a Thresholds query. When I upgraded to v10.3 from late Sep 21 it all worked (the latest dev build on 20th Dec 21 caused a crash on load with a time parsing error)

Hope this helps someone else.

Great software by the way guys - so many great features on top of real time rating. Attributes, Filters and Dispatchers are particularly cool. So flexible

thanks
Paul

Nickolas Daniel Filip

unread,
Dec 23, 2021, 4:30:04 AM12/23/21
to CGRateS
Hi Paul!

Thank you for your kind words!
Regarding the time parsing error, could you please open a new issue on github and then capture and post the error there?

Thanks,
Nick

Paul Walsh

unread,
Dec 23, 2021, 9:00:37 AM12/23/21
to cgr...@googlegroups.com
Hi Nick

No problem

Issue raised as below

https://github.com/cgrates/cgrates/issues/3512

regards
Paul
> To view this discussion on the web visit https://groups.google.com/d/msgid/cgrates/ac818c77-7e69-4120-b389-7f252fc5d77cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages