Situation

When Use ab Command, Client & Server Return Error MSG

  • Server

    • apr_socket_recv: Connection reset by peer (104)

  • Client

    • socket: Too many open files (24)

Solutions

Server Error

$ vim /etc/sysctl.conf 

net.ipv4.tcp_syncookies = 0

$ sysctl -p

Client Error

$ ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-m: resident set size (kbytes)      unlimited
-u: processes                       62302
-n: file descriptors                1024
-l: locked-in-memory size (kbytes)  65536
-v: address space (kbytes)          unlimited
-x: file locks                      unlimited
-i: pending signals                 62302
-q: bytes in POSIX msg queues       819200
-e: max nice                        0
-r: max rt priority                 0
-N 15:                              unlimited

Set -n : file descriptors

ulimit -n 204800