Is there any way to limit the connection every time the dialplan is being used? We are making like 1k to 2k calls every minute thus making thousands of connection on our DB.
Dialplan
; AMD detection based from called_count
exten => 8380,1,Playback(sip-silence)
same => n,AGI(agi://127.0.0.1:4577/call_log)
same => n,NoOp(${DIALEDPEERNUMBER:12})
;same => n,NoOp(${ODBC_MARIADB(${DIALEDPEERNUMBER:12})})
same => n,GotoIf($[${ODBC_MARIADB(${DIALEDPEERNUMBER:12})}>=4]?AMD:NoAMD)
same => n(AMD),AMD(2000,2000,1000,5000,120,50,4,256)
same => n,NoOp(${AMDSTATUS})
same => n,NoOp(${AMDCAUSE})
same => n,AGI(VD_amd.agi,${EXTEN})
same => n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----SO)
same => n,Hangup()
same => n(NoAMD),AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----SO)
same => n,Hangup()
Here’s the entry on func_odbc.conf
[MARIADB]
dsn=asterisk
readsql=select called_count from vicidial_auto_calls a inner join vicidial_list b on a.lead_id=b.lead_id where a.phone_number=${ARG1} limit 1
ODBC DSN Settings
-----------------
Name: asterisk
DSN: mariaodbc
Last connection attempt: 1969-12-31 19:00:00
Number of active connections: 1 (out of 1)
It doesn’t open another connection if exceeded. It sets the maximum there can be at any given time. When you ran the command, there was 1 connection. If you are seeing other connections then it is unlikely they are from res_odbc itself.
Let’s say we will be calling 1k calls every minute on each dialer. Having max value on the max_connections should help limiting opening new connection on each query?
Let’s say the first call went through to extension 8380, so technically it would open one connection since I am using ODBC application to make query on the DB. Does it mean if the second call that would go through to the same extension would still use the same connection? Interval of the first and second attempt would only be less than 1 to 2 seconds.
The connection is not used simultaneously. One will use it, the others will wait to use it, a new one will use it, and so on. Setting max connections to greater than 1 increases the number of max connections and thus other users won’t have to wait.