递增CouchDB并发连接

我使用CouchDB来每秒处理数千个请求。 在重负载下,似乎响应很慢,所以我开始用阿帕奇板凳进行testing。 沙发可以响应50k请求,1k并发。 然后我把并发提高到了2K,但基准总是在大约8K的请求中被破坏,

apr_socket_recv: Connection reset by peer (104) 

在CouchDb日志中,我可以find这两个错误:

 [Sat, 21 Nov 2015 17:16:07 GMT] [error] [<0.8073.2>] {error_report,<0.31.0>, {<0.8073.2>,crash_report, [[{initial_call, {mochiweb_acceptor,init, ['Argument__1','Argument__2','Argument__3']}}, {pid,<0.8073.2>}, {registered_name,[]}, {error_info, {exit, {error,accept_failed}, [{mochiweb_acceptor,init,3, [{file,"mochiweb_acceptor.erl"},{line,34}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,239}]}]}}, {ancestors, [couch_httpd,couch_secondary_services, couch_server_sup,<0.32.0>]}, {messages,[]}, {links,[<0.105.0>]}, {dictionary,[]}, {trap_exit,false}, {status,running}, {heap_size,233}, {stack_size,27}, {reductions,330}], []]}} // and this: [Sat, 21 Nov 2015 17:11:54 GMT] [error] [<0.105.0>] {error_report,<0.31.0>, {<0.105.0>,std_error, {mochiweb_socket_server,297, {acceptor_error,{error,accept_failed}}}}} 

可悲的是,我不明白他们的意思。

我到目前为止所做的尝试为CouchDB增加资源:

  • 提高了文件描述符限制到250k,硬和软
  • 引发“系统资源限制”如下所述:
    • export ERL_MAX_PORTS=8192 < – 虽然这是不赞成我认为
    • export ERL_MAX_ETS_TABLES=6000
    • export ERL_FLAGS="+Q 350000 +P 750000 +A 100"
  • 提高了CouchDBconfiguration中的几乎所有值
  • 我还读了一些关于在TIME_WAIT中的端口的内容,但是在基准testing之后,它似乎只有280个端口

没有任何工作。

对于这些testing,我正在使用VM:

  • Ubuntu 14.04.2
  • CouchDB 1.5.0
  • Erlang R16B03 (erts-5.10.4)

CouchDb的Kxepal把我和这封电子邮件联系起来:

使用limits.conf的一个常见问题是,couchdb su的couchdb用户和debian / ubuntu的/etc/pam.d/su默认尊重limits.conf,你需要启用它。

所以我做了vim /etc/pam.d/su ,发现:

 # Sets up user limits, please uncomment and read /etc/security/limits.conf # to enable this functionality. # (Replaces the use of /etc/limits in old login) #session required pam_limits.so 

我取消了最后一行的注释,重新启动了虚拟机,CouchDB现在支持尽可能多的并发请求。 它一直忽略了极限configuration。

我还了解到,实际上需要大量文件描述符的是基准本身,而不是基准testing的服务。 也许我应该从不同的虚拟机进行基准testing