Asterisk 20 Performance Issues with SET Commands


Asterisk version: 20.6.0

During Asterisk 20 load testing, we encountered an issue where above a certain channel count (~300), SET commands start to slow down (2-4 ms per variable declaration).

Our call logic is quite complex even within a single call:

  • Variable setting within contexts (1 call): 130-140 variable declaration
  • Gosub usage (1 call): 110-130 instances
  • Variable declaration via FastAGI (1 call) with 7 AGI scripts they declare overall 30-40 variables

Our observations on an 11-core virtual machine (LXC container):

  • When new calls arrive and call logic starts executing, CPU usage jumps from 30-40% to 75% around 300 channels (150 calls).
  • This is when command execution starts to slow down, most noticeably with SET command.
  • Once calls are established, CPU usage drops back to 40-50% and remains so up to 1200 channels (600 calls).
  • At 1200 channels, CPU usage spikes to 90% when calls are established and then drops to around 60% (for 600 parallel calls).
  • There are no voice problems, just the dialplan slows down from 87 commands/call/10ms to 5-10 commands/call/10ms

During the test, we processed 2 calls per second (cps) with long call durations of 15 minutes per call.

We attempted to fine-tune stasis.conf based on information available on forums.

Additionally, applications connect via AMI. Endpoints subscribe to manage their own state, resulting in around 1000 subscriptions.

The question is whether anyone else has experienced this issue and what recommendations do you have for optimizing the dialplan?