{"id":2427,"date":"2022-08-30T15:24:46","date_gmt":"2022-08-30T15:24:46","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/01\/12\/erlang-cowboy-crash-socket-reset-on-ab-testing-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:24:46","modified_gmt":"2022-08-30T15:24:46","slug":"erlang-cowboy-crash-socket-reset-on-ab-testing-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/erlang-cowboy-crash-socket-reset-on-ab-testing-collection-of-common-programming-errors\/","title":{"rendered":"Erlang\/cowboy crash (socket reset) on ab testing-Collection of common programming errors"},"content":{"rendered":"<p>Trying out Cowboy (Erlang) http library, helloworld example: https:\/\/github.com\/extend\/cowboy\/tree\/master\/examples\/hello_world<\/p>\n<p>When using Apache&#8217;s &#8220;ab&#8221; testing tool in this manner, I get &#8220;connection reset&#8221;:<\/p>\n<pre><code>d7 ~\/cb\/cowboy\/examples\/hello_world % !564\nab -n 30000 -c 5000 http:\/\/127.0.0.1:8080\/\nThis is ApacheBench, Version 2.3 \nCopyright 1996 Adam Twiss, Zeus Technology Ltd, http:\/\/www.zeustech.net\/\nLicensed to The Apache Software Foundation, http:\/\/www.apache.org\/\n\nBenchmarking 127.0.0.1 (be patient)\nCompleted 3000 requests\nCompleted 6000 requests\nCompleted 9000 requests\nCompleted 12000 requests\nCompleted 15000 requests\nCompleted 18000 requests\nCompleted 21000 requests\nCompleted 24000 requests\nCompleted 27000 requests\napr_socket_recv: Connection reset by peer (104)\n<\/code><\/pre>\n<p>Testing with smaller values like -n 5000 -c 1000 works correctly.<\/p>\n<p>What may be the problem that crashes or resets erl\/Cowboy process? I have observed beam&#8217;s memory usage under top and it grows to smth like 120MB, nothing obscene (I have 3G of RAM on that vm).<\/p>\n<p>ulimit settings are also rather generous:<\/p>\n<pre><code>% ulimit -a\ncore file size          (blocks, -c) 0\ndata seg size           (kbytes, -d) unlimited\nscheduling priority             (-e) 0\nfile size               (blocks, -f) unlimited\npending signals                 (-i) 24088\nmax locked memory       (kbytes, -l) 64\nmax memory size         (kbytes, -m) unlimited\nopen files                      (-n) 65535\npipe size            (512 bytes, -p) 8\nPOSIX message queues     (bytes, -q) 819200\nreal-time priority              (-r) 0\nstack size              (kbytes, -s) 16000\ncpu time               (seconds, -t) unlimited\nmax user processes              (-u) 24088\nvirtual memory          (kbytes, -v) unlimited\nfile locks                      (-x) unlimited\n<\/code><\/pre>\n<p>What is it that erl\/cowboy might have a problem with?<\/p>\n<p>OS: Debian 7 x64.<\/p>\n<ol>\n<li>\n<p>You should try disabling the SYN cookie sending. Search for this line <code>net.ipv4.tcp_syncookies = 0<\/code> in <strong>\/etc\/sysctl.conf<\/strong>.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2014-01-12 20:23:52. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Trying out Cowboy (Erlang) http library, helloworld example: https:\/\/github.com\/extend\/cowboy\/tree\/master\/examples\/hello_world When using Apache&#8217;s &#8220;ab&#8221; testing tool in this manner, I get &#8220;connection reset&#8221;: 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2427","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2427"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2427\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}