Astersik used 100% cpu

hello everyone
I am using this asterisk dialplan for messaging
code in “/etc/asterisk/extension_custom.conf” as :

[astsms]
exten => _X.,1,NoOp(SMS receiving dialplan invoked)
exten => _X.,n,NoOp(To ${MESSAGE(to)})
exten => _X.,n,NoOp(From ${MESSAGE(from)})
exten => _X.,n,NoOp(Body ${MESSAGE(body)})
exten => _X.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _X.,n,ExecIf($[“${ACTUALTO}” != “sip:${EXTEN}”]?Set(ACTUALTO=sip:${EXTEN}))
exten => _X.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _X.,n,Set(FILE(/var/spool/asterisk/sms/${STRFTIME(${EPOCH},%F-%T)}-${CALLERID(num)}-${EXTEN}.txt,a)=${MESSAGE(body)})
exten => _X.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _X.,n,GotoIf($[“${MESSAGE_SEND_STATUS}” != “SUCCESS”]?sendfailedmsg)
exten => _X.,n,Hangup()
;
; Handle failed messaging
exten => _X.,n(sendfailedmsg),NoOp(Sending error to user)
exten => _X.,n,Set(SRC=${MESSAGE(from)})
exten => _X.,n,Set(DST=${MESSAGE(to)})
exten => _X.,n,Set(MSG=${MESSAGE(body)})
exten => _X.,n,Set(MESSAGE(body)=“[${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Sending when available”)
exten => _X.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _X.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _X.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _X.,n,GotoIf($[“${INQUEUE}” != “1”]?startq)
exten => _X.,n,Hangup()
;
exten => _X.,n(startq),NoOp(Queueing messaging for offline)
exten => _X.,n,Set(MSGTIME=${STRFTIME(${EPOCH},%d%m%Y-%H:%M:%S)})
;exten => _X.,n,System(/bin/bash /var/lib/asterisk/agi-bin/sc.sh)
exten => _X.,n,System(/bin/bash /var/lib/asterisk/agi-bin/astqueue.sh -s ‘${SRC}’ -d ‘${DST}’ -m ‘${MSG}’)
exten => _X.,n,Hangup()
[app-fakeanswer]
exten => _X.,1,NoCDR
exten => _X.,n,Set(DESTDEV=${EXTEN})
exten => _X.,n,Set(THISDEVSTATE=${DEVICE_STATE(SIP/${DESTDEV})})
exten => _X.,n,GotoIf($[“${THISDEVSTATE}” = “UNAVAILABLE”]?hang)
exten => _X.,n,GotoIf($[“${THISDEVSTATE}” = “UNKNOWN”]?hang)
exten => _X.,n,Answer
exten => _X.,n,Hangup()
exten => _X.,n(hang),Hangup()

i have 200 users on this server. when more than 200 message request send within a second than cpu utilization is 100% and load average of server is around 50. at this stage asterisk stopped and server hanged up.
sometime dialplan missed the message request.

server: intel i5 with 4 core
RAM: 8GB
harddrive: 1TB

i dont know to handle the message request through dialpan and need help to resolve this problem.
please help me.

https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace

Note stopped is not precise as it is not clear whether you really mean terminated or you mean deadlocked.

Shelling out is an expensive thing to do.

Please mark up your dialplan as preformatted text when using the forum.

@david551::

Done preformatting.

No there ain’t a deadlock condition.
“Astersik stopped” over here means:

that the CPU load average goes 50 while using “top” command for monitoring.
And thus after that while using the command

systemctl status asterisk

the output shows that asterisk status as stopped, which I have to start again at this instance.

Now can you help out so how can I handle the request of 200 message per user of 200 users.

And can you also let me know what is the maximum word length for a single message for asterisk to provide optimal performance.

If it is stopping, you will need to obtain a backtrace and also to examine the log files;

https://wiki.asterisk.org/wiki/display/AST/Getting+a+Backtrace