Big delay in bridging queue calls

I 'm using Asterisk 13.20 and Freepbx 10.13 on a virtual server(8 cores CPU , 16 GB RAM ) we have multi queue and call recording
here is my problem: When queue increase in call volume (about 20 waiting calls ) calls ditributed normally but after agents answerd calls , there will be long delays in hearing the caller’s voice.
in same time “queue show” command responses with delay:

2018 has 18 calls (max unlimited) in ‘rrmemory’ strategy (218s holdtime, 72s talktime), W:6, C:962, A:159, SL:85.4% within 60s
1162 (Local/1162@from-queue/n from sip/20050) (ringinuse disabled) (dynamic) (In use) has taken 11 calls (last was 110 secs ago)
1123 (Local/1123@from-queue/n from sip/20058) (ringinuse disabled) (dynamic) (Not in use) has taken 13 calls (last was 110 secs ago)
1113 (Local/1113@from-queue/n from sip/20044) (ringinuse disabled) (dynamic) (in call) (In use) has taken 4 calls (last was 32 secs ago)
1191 (Local/1191@from-queue/n from sip/20055) (ringinuse disabled) (dynamic) (in call) (In use) has taken 5 calls (last was 261 secs ago)
1057 (Local/1057@from-queue/n from sip/20054) (ringinuse disabled) (dynamic) (In use) has taken 8 calls (last was 494 secs ago)
1114 (Local/1114@from-queue/n from sip/20053) (ringinuse disabled) (dynamic) (in call) (In use) has taken no calls yet
1128 (Local/1128@from-queue/n from sip/20052) (ringinuse disabled) (dynamic) (in call) (In use) has taken 45 calls (last was 117 secs ago)
1189 (Local/1189@from-queue/n from sip/20059) (ringinuse disabled) (dynamic) (In use) has taken 16 calls (last was 274 secs ago)
1030 (Local/1030@from-queue/n from sip/20051) (ringinuse disabled) (dynamic) (In use) has taken 15 calls (last was 152 secs ago)
1364 (Local/1364@from-queue/n from sip/) (ringinuse disabled) (dynamic) (Invalid) has taken no calls yet
1115 (Local/1115@from-queue/n from sip/20062) (ringinuse disabled) (dynamic) (in call) (In use) has taken 17 calls (last was 70 secs ago)
1. SIP/kam-dispatch-0001c313 (wait: 3:33, prio: 0)
2. SIP/kam-dispatch-0001c317 (wait: 3:22, prio: 0)
3. SIP/kam-dispatch-0001c318 (wait: 3:13, prio: 0)
4. SIP/kam-dispatch-0001c31f (wait: 2:59, prio: 0)
5. SIP/kam-dispatch-0001c324 (wait: 2:31, prio: 0)
6. SIP/kam-dispatch-0001c329 (wait: 2:11, prio: 0)
7. SIP/kam-dispatch-0001c331 (wait: 1:55, prio: 0)
8. SIP/kam-dispatch-0001c337 (wait: 1:42, prio: 0)
9. SIP/kam-dispatch-0001c33b (wait: 1:19, prio: 0)
10. SIP/kam-dispatch-0001c33c (wait: 1:11, prio: 0)
11. SIP/kam-dispatch-0001c33e (wait: 1:07, prio: 0)
12. SIP/kam-dispatch-0001c340 (wait: 1:01, prio: 0)
13. SIP/kam-dispatch-0001c347 (wait: 0:40, prio: 0)
14. SIP/kam-dispatch-0001c349 (wait: 0:34, prio: 0)
15. SIP/kam-dispatch-0001c34a (wait: 0:30, prio: 0)
16. SIP/kam-dispatch-0001c34b (wait: 0:23, prio: 0)
17. SIP/kam-dispatch-0001c34d (wait: 0:03, prio: 0)
18. SIP/kam-dispatch-0001c34f (wait: 0:01, prio: 0)

thanks in advance.

In log files there is a related warning message:
[2018-12-05 15:14:30] WARNING[31027][C-0000c3f0] channel.c: Exceptionally long voice queue length queuing to Local/1057@from-queue-0000fa42;1

more info :
-we have two servers with same hardware and software config and both of them have this issue .
-these servers connected to remote mysql (LAN server) by ODBC to store CDRs.
-All clients and servers are on LAN network without firewall or NAT devices , we don’t use DNS for client registering or trunks.
-Asterisk still working with no crash or core dump files

Hi Danial,

I have a similar setup and eventually ran into the same issue - big queues (20-40 waiting calls) and voice delay 5-10 sec only on those which are being recorded.
Already tried different versions of Asterisk, ESX software, hardware, SSD and HDD storage, but still no luck.

Have you finally solved this problem? Do you have any suggestions? I will appreciate any help.

To my knowledge, these types of problems are based on the structure and load of the Asterisk server.
In multi-thread services such as Asterisk, if one of them is delayed, the delay will affect other parts.
For example, if your SQL server is delayed, your calls will not be handled properly.

tried recording to a ramdrive ?
sudo mount -t tmpfs -o size=3G myramdisk /var/spool/asterisk/monitor

You can try add MySQL timeout if you write your own script.

When have delay, show your system performance and see what happen, what have bottleneck: CPU , RAM , HDD, network … , also see sleep connection in MySQL