测试服务器ab
被测试服务器apache
apache版本2.2.25
问题一、socket: Too many open files (24)
解决(在测试服务器操作):
1、查看当前系统设置: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、修改默认值:
临时生效:
[root@localhost ~]# ulimit -n 65536
永久生效:
/etc/security/limits.conf文件中添加以下两行后重新登陆
* soft nofile 65536
* hard nofile 65536
3、查看修改结果
[root@localhost ~]# ulimit -n
65536
问题二、apr_socket_recv: Connection reset by peer (104)
网上有一个解决办法是修改内核参数(被测试服务器):
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
执行sysctl -p生效
执行以上内核参数修改操作后,ab还是同样的错误,只是被测试的服务器的日志中不会再有以下提示:
Oct 9 15:07:21 localhost kernel: possible SYN flooding on port 80. Sending cookies.
解决:
1、清除以上设置
2、sysctl -p
3、在测试服务器执行以下操作:
修改源代码后重新编译安装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程序测试,不修改内核参数的话,测试服务器日志中会提示Oct 9 15:07:21 localhost kernel: possible SYN flooding on port 80. Sending cookies.但是ab正常运行
问题三、ab的-c选项的参数最大到20000,如果想再大,只能修改源码再安装
问题四、-c选项的参数不能大于-n的参数