Asterisk CPU Usage goes to around 100% in a few second

Now I am using asterisk for a CTI system.
I am using FreePBX for asterisk GUI. And the CTI system is made by PHP and Javascript.
For the softphone I am using webrtc. The webrtc is customized by Sipml5.
Server spec is 4 GB / 2 Virtual CPU, 20GB SSD Plan, CentOS 6.
Everyday the recording files and asteriskcdrdb mysql database are cleaned up.

Usually it will have 10 operators using it to call at the same time.

But sometimes, my server CPU usage will go over 50% and in 2 sec it will go over 100%.
It makes the server stop working.
At this time I use “top” command, it shows asterisk using CPU going over 50% or 100% or more.

When it happens, I can only restart asterisk to let the server keep working.

I checked /var/log/ all files but I still can’t find the reason.

There are some details about when the issue happens:

  1. Usually that CTI system has 10 operators using it at the same time, but this issue also happens even when only 2 operators using.

  2. When there is no issue, the CPU just uses less than 10%, even when 10 operators are calling at the same time. When it happens the CPU will go from less than 10% to 100% in few seconds. It seems like there is some infinite loop.

  3. I also tried different company, different server service. All had same problem.

  4. I tried Asterisk 11 and Asterisk 13, all had same problem.

And this is when there is issue I use “top” command.

Does anyone have the same experience and know how to fix this problem?

Here are things I would look for:

  1. Are there any WARNING or ERRORs in Asterisk when the issue occurs?

  2. When the issue occurs, what is happening in Asterisk? Are you running calls, recordings? What SIP messages are in flight?

  3. Are you interfacing to any external systems (databases, API servers, etc.), and is Asterisk communicating with them when the issue occurs?

  4. When the issue occurs, does Asterisk stop processing (a) SIP requests (you’ll stop seeing requests logged, or responses won’t be sent, etc.); (b) new calls (SIP messages are processed but calls hang); © calls are processed but get stuck at parts in the dialplan, etc.

Thanks mjordan for the reply.

Here is /var/log/asterisk/full log file, I uploaded to this url, please check. The file is light.
http://radi-work.sakura.ne.jp/asteriskissue/full
This time the issue was happened at around 2016-08-16 16:24:00, server timezone.

Yes, until now, this issue only happens when there are operators doing call.
Never happened When no operator using.

Other then asterisk, as I said, there is my CTI system, working on another server. The softphone I am using webrtc, the webrtc is customized by Sipml5.[quote=“mjordan, post:2, topic:67741”]
When the issue occurs, does Asterisk stop processing (a) SIP requests (you’ll stop seeing requests logged, or responses won’t be sent, etc.); (b) new calls (SIP messages are processed but calls hang); © calls are processed but get stuck at parts in the dialplan, etc.
[/quote]
(a) I don’t know if asterisk stops processing SIP request, but I know if an operator is on the phone, the call will be cut. (b) It does stop new calls being made. © No calls can be made at all.

Hello mjordan.
Sorry maybe the answer not really good, or I sent the link and it made it too heavy to open. I deleted all before 2016-08-16 16:21:00 logs from full file. I think the file now is more light. And this time the issue happened at 2016-08-16 16:24:00, you can use Ctrl + F search it and jump to the issue point.

I just thought to show you this is better than I copy some messages

I mean when the issue occurs, my operators running calls and recordings.