Asterisk服务器出现问题,显示高负载平均值我无法解释。 Ny设置是:
星号用于发送语音消息。 我有一个上游SIP提供商,没有硬件电话卡。 sip.conf中只允许alaw / ulaw。
我使用AMI Originate命令来启动一个呼叫; 然后在上下文中执行Playback()来发送预先录制的语音信息(本地ext4 FS中的ulaw文件)。 与被叫没有其他交互,没有IVR菜单,没有通话logging。 几个非常简单的Perl AGI脚本将调用结果保存到DB(MySQL和MSSQL(通过Perl Sybase)); 通常每个Originate有1-2个AGI呼叫。 另外,几乎没有扩展的处理 – 字面上有20行预设置的CDR()和一对AGI调用。 只有一个AMI连接用于启动所有呼叫。
具体是 – 大多数电话没有回答。 我每秒发起多达50个电话,但实际上只有5-10个电话被听取。
问题是 – 我有非常低的CPU使用率,但非常高的洛杉矶。 如果我以20-25 cps – 20-24 LA的话来说,但是如果我把它提高到50cps,洛杉矶就会爬到90+。 在〜50LA后,audio质量有问题(我能理解为什么)。
大多数Asterisk用户声称,他们有更多的通话音量和更less的硬件。
# uptime 12:56:36 up 9 days, 15:52, 1 user, load average: 32,10, 33,45, 33,10 #vmstat -w 1 procs ---------------memory-------------- ---swap-- -----io---- -system-- ------cpu----- rb swpd free buff cache si so bi bo in cs us sy id wa st 3 0 0 30322760 199176 832452 0 0 0 0 237471 38738 5 8 87 0 0 3 0 0 30319148 199176 832500 0 0 0 0 188340 38960 4 6 90 0 0 3 0 0 30325528 199176 832564 0 0 0 26 319903 43916 6 10 83 0 0 105 0 0 30270288 199176 832568 0 0 0 14 175216 39014 4 6 90 0 0 16 0 0 30307908 199176 832572 0 0 0 0 323598 43428 11 12 77 0 0 # mpstat 1 Linux 3.13.0-24-generic (asterisk2) 25.02.2015 _x86_64_ (24 CPU) 13:18:09 CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle 13:18:10 all 5,77 0,00 7,90 0,00 0,17 0,00 0,00 0,00 0,00 86,16 13:18:11 all 5,56 0,00 8,83 0,00 0,21 0,00 0,00 0,00 0,00 85,40 13:18:12 all 10,29 0,00 11,42 0,00 0,25 0,00 0,00 0,00 0,00 78,03 13:18:13 all 9,70 0,00 10,75 0,00 0,21 0,00 0,00 0,00 0,00 79,34 # uname -a Linux asterisk2 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux # cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 6 model : 45 model name : Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz stepping : 7 microcode : 0x70d cpu MHz : 2000.216 cache size : 15360 KB physical id : 0 siblings : 12 core id : 0 cpu cores : 6 apicid : 0 initial apicid : 0 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid bogomips : 4000.43 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual ... processor : 23 vendor_id : GenuineIntel cpu family : 6 model : 45 model name : Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz stepping : 7 microcode : 0x70d cpu MHz : 2000.216 cache size : 15360 KB physical id : 1 siblings : 12 core id : 5 cpu cores : 6 apicid : 43 initial apicid : 43 fpu : yes fpu_exception : yes cpuid level : 13 wp : yes flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid bogomips : 4001.85 clflush size : 64 cache_alignment : 64 address sizes : 46 bits physical, 48 bits virtual # cat /proc/interrupts CPU02 CPU23 0: 24 0 IR-IO-APIC-edge timer 8: 1 0 IR-IO-APIC-edge rtc0 9: 2 0 IR-IO-APIC-fasteoi acpi 16: 33 0 IR-IO-APIC-fasteoi ehci_hcd:usb1 23: 107 0 IR-IO-APIC-fasteoi ehci_hcd:usb2 88: 0 0 DMAR_MSI-edge dmar0 89: 0 0 DMAR_MSI-edge dmar1 90: 1855369 0 IR-PCI-MSI-edge ahci 91: 1 0 IR-PCI-MSI-edge eth0 92: 11296 0 IR-PCI-MSI-edge eth0-TxRx-0 93: 790 0 IR-PCI-MSI-edge eth0-TxRx-1 94: 85066770 0 IR-PCI-MSI-edge eth0-TxRx-2 95: 6851 0 IR-PCI-MSI-edge eth0-TxRx-3 96: 174614 0 IR-PCI-MSI-edge eth0-TxRx-4 97: 4846139 0 IR-PCI-MSI-edge eth0-TxRx-5 98: 136593 0 IR-PCI-MSI-edge eth0-TxRx-6 99: 1294090 0 IR-PCI-MSI-edge eth0-TxRx-7 109: 2 0 IR-PCI-MSI-edge ioat-msix 110: 2 0 IR-PCI-MSI-edge ioat-msix 111: 2 0 IR-PCI-MSI-edge ioat-msix 112: 2 0 IR-PCI-MSI-edge ioat-msix 113: 2 0 IR-PCI-MSI-edge ioat-msix 114: 2 0 IR-PCI-MSI-edge ioat-msix 115: 2 0 IR-PCI-MSI-edge ioat-msix 116: 2 0 IR-PCI-MSI-edge ioat-msix 117: 0 0 IR-PCI-MSI-edge ioat-msix 118: 0 0 IR-PCI-MSI-edge ioat-msix 119: 0 0 IR-PCI-MSI-edge ioat-msix 120: 0 0 IR-PCI-MSI-edge ioat-msix 121: 0 0 IR-PCI-MSI-edge ioat-msix 122: 0 0 IR-PCI-MSI-edge ioat-msix 123: 0 0 IR-PCI-MSI-edge ioat-msix 124: 0 0 IR-PCI-MSI-edge ioat-msix NMI: 3642 1990 Non-maskable interrupts LOC: 53207172 19108700 Local timer interrupts SPU: 0 0 Spurious interrupts PMI: 3642 1990 Performance monitoring interrupts IWI: 804483 60489 IRQ work interrupts RTR: 0 0 APIC ICR read retries RES: 60096784 31495629 Rescheduling interrupts CAL: 4046461325 4101338127 Function call interrupts TLB: 2390847639 1479027286 TLB shootdowns TRM: 0 0 Thermal event interrupts THR: 0 0 Threshold APIC interrupts MCE: 0 0 Machine check exceptions MCP: 2501 2501 Machine check polls ERR: 0 MIS: 0 # atop CPL | avg1 22.45 | avg5 22.65 | | avg15 22.74 | | csw 379728 | intr 1612164 | | | numcpu 24 | MEM | tot 31.4G | free 28.4G | cache 829.3M | dirty 0.0M | buff 194.7M | slab 188.0M | | | | | SWP | tot 32.0G | free 32.0G | | | | | | | vmcom 737.1M | vmlim 47.7G | MDD | md0 | busy 0% | read 0 | write 12 | KiB/r 0 | KiB/w 4 | MBr/s 0.00 | MBw/s 0.01 | avq 0.00 | avio 0.00 ms | DSK | sda | busy 1% | read 0 | write 11 | KiB/r 0 | KiB/w 5 | MBr/s 0.00 | MBw/s 0.01 | avq 1.00 | avio 12.7 ms | DSK | sdb | busy 1% | read 0 | write 11 | KiB/r 0 | KiB/w 5 | MBr/s 0.00 | MBw/s 0.01 | avq 1.00 | avio 11.6 ms | NET | transport | tcpi 1994 | tcpo 2452 | udpi 17159 | udpo 14811 | tcpao 117 | tcppo 1 | tcprs 0 | tcpie 0 | udpip 0 | NET | network | ipi 19235 | ipo 17268 | ipfrw 0 | deliv 19235 | | | | icmpi 7 | icmpo 0 | NET | eth0 0% | pcki 19345 | pcko 17272 | si 3256 Kbps | so 2954 Kbps | coll 0 | erri 0 | erro 0 | drpi 0 | drpo 0 |
你可以看到,在cs和vmstat字段中有非常多的数字。 我无法解释他们。
所以,就我所知 – 在很短的时间内有线程的突发变得可执行(你可以在vmstat输出中看到一个这样的突发事件)。 但是,在我的设置可以导致这样的事情?
我试过了:
但没有任何帮助。
我检查了我能想到的一切 – 没有磁盘IO,没有其他应用程序在这台服务器上。 邮件发送者有类似的问题,但是这个问题还没有解决,而且是相当久的。
还有一个想法 – 我有一个更多的服务器与非常相似的硬件和Asteriskconfiguration相同的问题,但有Asterisk 1.8(FreePBX)和CentOS正在使用。 我怀疑,这导致我的特殊用法。
也许,这是AMI的核心问题,我应该使用别的方式来进行批量初始化调用?
编辑1:这是我的LA图:
编辑2:这里是星号strace。 它在高低负荷上相对相同。 我本人不是Linux程序员,不能正确解释。
# strace -f -q -c -p 17150 ^C% time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 42.05 1595.370429 13209 120778 18231 futex 41.21 1563.521630 6304523 248 14 restart_syscall 15.96 605.470340 4726 128105 26 poll 0.23 8.811410 12037 732 nanosleep 0.16 5.903679 26 228693 22073 read 0.15 5.600020 66 85202 write
Ookay,我明白了。 这只是解决方法,但问题已经下降到我可以接受的水平。
在一天中的不想要的重启之后,我注意到Load Average大大下降了! 我检查了我们的服务器监控系统 – LA总是在3-4个小时的连续(稳定的)负载中一点一点地爬上去。 这是不明显的,因为我在一天之前无法重新启动它。
正如我所说,我有几个Perl脚本,通过AGI()应用程序调用。 其中之一被称为h扩展; 它只运行一个简单的数据库查询。 事实certificate,有时DB会变得过载一点; 查询必须等待200-500ms; 星号必须等到Perl脚本完成。
所以,我开始fork()我的Perl脚本 – 使AGI()调用总是立即返回。 这帮了很多! 洛杉矶变得很稳定。 这不是一个完整的解决scheme – 它似乎仍然在Asterisk内部破坏,但速度慢得多,这几乎不是一个问题。
对于那些寻找准备使用的代码段(不要忘记在fork() ing之前获取所有variables,因为您将无法访问$AGI之后):
my $AGI = new Asterisk::AGI; # get all your variables here my $var = $AGI->get_variable('var'); undef $AGI; if (fork) { exit 0; }; open STDIN, '<', '/dev/null'; # dont forget to free your parent's file handles open STDOUT, '>', '/dev/null'; open STDERR, '>&STDOUT';
这看起来像一个错误 – 但我想知道为什么没有人比我这样的问题。
编辑1:那么,消除AGI电话后,问题完全消失。 我只是做了一些自定义ODBC函数( func_odbc.conf ),这些函数只是为asynchronous处理保存信息(后来由单独的perl守护进程处理)。 洛杉矶从20-25下降到0.5-0.9(!)。 我从来没有想过AGI会造成如此巨大的负担。