Erlang/cowboy crash (socket reset) on ab testing-Collection of common programming errors

Trying out Cowboy (Erlang) http library, helloworld example: https://github.com/extend/cowboy/tree/master/examples/hello_world

When using Apache’s “ab” testing tool in this manner, I get “connection reset”:

d7 ~/cb/cowboy/examples/hello_world % !564
ab -n 30000 -c 5000 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 127.0.0.1 (be patient)
Completed 3000 requests
Completed 6000 requests
Completed 9000 requests
Completed 12000 requests
Completed 15000 requests
Completed 18000 requests
Completed 21000 requests
Completed 24000 requests
Completed 27000 requests
apr_socket_recv: Connection reset by peer (104)

Testing with smaller values like -n 5000 -c 1000 works correctly.

What may be the problem that crashes or resets erl/Cowboy process? I have observed beam’s memory usage under top and it grows to smth like 120MB, nothing obscene (I have 3G of RAM on that vm).

ulimit settings are also rather generous:

% 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) 24088
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65535
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 16000
cpu time               (seconds, -t) unlimited
max user processes              (-u) 24088
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

What is it that erl/cowboy might have a problem with?

OS: Debian 7 x64.

  1. You should try disabling the SYN cookie sending. Search for this line net.ipv4.tcp_syncookies = 0 in /etc/sysctl.conf.