測(cè)試服務(wù)器ab
被測(cè)試服務(wù)器apache
apache版本2.2.25
問(wèn)題一、socket: Too many open files (24)
解決(在測(cè)試服務(wù)器操作):
1根吁、查看當(dāng)前系統(tǒng)設(shè)置:open files (-n) 1024為1024
[root@localhost ~]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7844
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
2、修改默認(rèn)值:
臨時(shí)生效:
[root@localhost ~]# ulimit -n 65536
永久生效:
/etc/security/limits.conf文件中添加以下兩行后重新登陸
* soft nofile 65536
* hard nofile 65536
3剃法、查看修改結(jié)果
[root@localhost ~]# ulimit -n
65536
問(wèn)題二庭瑰、apr_socket_recv: Connection reset by peer (104)
網(wǎng)上有一個(gè)解決辦法是修改內(nèi)核參數(shù)(被測(cè)試服務(wù)器):
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.tcp_syncookies = 0
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv4.tcp_max_syn_backlog = 819200
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_max_tw_buckets = 819200
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
執(zhí)行sysctl -p生效
執(zhí)行以上內(nèi)核參數(shù)修改操作后,ab還是同樣的錯(cuò)誤坛吁,只是被測(cè)試的服務(wù)器的日志中不會(huì)再有以下提示:
Oct 9 15:07:21 localhost kernel: possible SYN flooding on port 80. Sending cookies.
解決:
1摩幔、清除以上設(shè)置
2彤委、sysctl -p
3、在測(cè)試服務(wù)器執(zhí)行以下操作:
修改源代碼后重新編譯安裝apache
vim support/ab.c
1373 return;
1374 } else {
1375 //apr_err("apr_socket_recv", status);
1376 bad++;
1377 close_connection(c);
1378 return;
1379 }
注:只使用修改源碼的ab程序測(cè)試热鞍,不修改內(nèi)核參數(shù)的話葫慎,測(cè)試服務(wù)器日志中會(huì)提示Oct 9 15:07:21 localhost kernel: possible SYN flooding on port 80. Sending cookies.但是ab正常運(yùn)行
問(wèn)題三、ab的-c選項(xiàng)的參數(shù)最大到20000薇宠,如果想再大偷办,只能修改源碼再安裝
問(wèn)題四、-c選項(xiàng)的參數(shù)不能大于-n的參數(shù)