Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Erlang YAWS在轻负载下响应错误。未处理的答复fr.do_recv(){error,econnaborted}_Erlang_Yaws_Httpc - Fatal编程技术网

Erlang YAWS在轻负载下响应错误。未处理的答复fr.do_recv(){error,econnaborted}

Erlang YAWS在轻负载下响应错误。未处理的答复fr.do_recv(){error,econnaborted},erlang,yaws,httpc,Erlang,Yaws,Httpc,亲爱的爱尔兰人: 这只是另一个玩Erlang语言的爱好者。我有一个非常简单的YAWS应用程序模块,当被单个客户端访问时,它可以正常工作。但是,如果我尝试跨越多个客户端来模拟光流量,这些客户端就会开始接收错误。知道是什么引起的吗 生成客户端的代码: -module(concurrent). -export([measure/0, get/0]). get() -> Result = httpc:request("http://localhost:8080/blah"), io:fo

亲爱的爱尔兰人:

这只是另一个玩Erlang语言的爱好者。我有一个非常简单的YAWS应用程序模块,当被单个客户端访问时,它可以正常工作。但是,如果我尝试跨越多个客户端来模拟光流量,这些客户端就会开始接收错误。知道是什么引起的吗

生成客户端的代码:

-module(concurrent).
-export([measure/0, get/0]).

get() ->
  Result = httpc:request("http://localhost:8080/blah"),
  io:format("Result: ~p.\n", [Result]).

get_spawner(0) -> io:format("Done.\n");
get_spawner(Times) ->
  spawn(concurrent, get, []),
  get_spawner(Times - 1).

measure() ->
  io:fwrite("Starting inets...\n"),
  inets:start(),
  io:fwrite("Done\n"),

  io:fwrite("Creating blah...\n"),
  httpc:request(put, { "http://localhost:8080/blah", [], "", "" }, [], []),
  io:fwrite("Done\n"),

  get_spawner(9),

  io:fwrite("Stopping inets...\n"),
  inets:stop(),
  io:fwrite("Done\n"),

  init:stop().
我观察到,对于8个并发客户机来说,这一切都可以正常工作,但当我跨越9个或更多客户机时,他们开始从服务器接收以下消息:

=ERROR REPORT==== 24-Jan-2017::12:30:04 ===
** Generic server httpc_manager terminating
** Last message in was {request,
                           {request,undefined,<0.74.0>,0,http,
                               {"localhost",8080},
                               "/blah",[],get,
                               {http_request_h,undefined,"keep-alive",
                                   undefined,undefined,undefined,undefined,
                                   undefined,undefined,undefined,undefined,
                                   undefined,undefined,undefined,undefined,
                                   undefined,undefined,"localhost:8080",
                                   undefined,undefined,undefined,undefined,
                                   undefined,undefined,undefined,undefined,
                                   undefined,[],undefined,undefined,undefined,
                                   undefined,"0",undefined,undefined,
                                   undefined,undefined,undefined,undefined,[]},
                               {[],[]},
                               {http_options,"HTTP/1.1",infinity,true,
                                   {essl,[]},
                                   undefined,false,infinity,false},
                               "http://localhost:8080/blah",[],none,[],
                               1485261004189,undefined,undefined,false}}
** When Server state == {state,[],httpc_manager__handler_db,
                            {cookie_db,undefined,8209},
                            httpc_manager__session_db,httpc_manager,
                            {options,
                                {undefined,[]},
                                {undefined,[]},
                                0,2,5,120000,2,disabled,false,inet,default,
                                default,[]}}
** Reason for termination ==
** {'EXIT',
       {shutdown,
           {gen_server,call,
               [httpc_handler_sup,
                {start_child,
                    [<0.61.0>,
                     {request,#Ref<0.0.6.64>,<0.74.0>,0,http,
                         {"localhost",8080},
                         "/blah",[],get,
                         {http_request_h,undefined,"keep-alive",undefined,
                             undefined,undefined,undefined,undefined,
                             undefined,undefined,undefined,undefined,
                             undefined,undefined,undefined,undefined,
                             undefined,"localhost:8080",undefined,undefined,
                             undefined,undefined,undefined,undefined,
                             undefined,undefined,undefined,[],undefined,
                             undefined,undefined,undefined,"0",undefined,
                             undefined,undefined,undefined,undefined,
                             undefined,[]},
                         {[],[]},
                         {http_options,"HTTP/1.1",infinity,true,
                             {essl,[]},
                             undefined,false,infinity,false},
                         "http://localhost:8080/blah",[],none,[],
                         1485261004189,undefined,undefined,false},
                     {options,
                         {undefined,[]},
                         {undefined,[]},
                         0,2,5,120000,2,disabled,false,inet,default,default,
                         []},
                     httpc_manager]},
                infinity]}}}

=ERROR REPORT==== 24-Jan-2017::12:30:04 ===
Error in process <0.74.0> with exit value:
{{case_clause,
     {undefined,
         {error,
             {'EXIT',
                 {shutdown,
                     {gen_server,call,
                         [httpc_handler_sup,
                          {start_child,
                              [<0.61.0>,
                               {request,#Ref<0.0.6.64>,<0.74.0>,0,http,
                                   {"localhost",8080},
                                   "/blah",[],get,
                                   {http_request_h,undefined,"keep-alive",
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined,
                                       undefined,undefined,"localhost:8080",
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined,
                                       undefined,undefined,undefined,[],
                                       undefined,undefined,undefined,
                                       undefined,"0",undefined,undefined,
                                       undefined,undefined,undefined,
                                       undefined,[]},
                                   {[],[]},
                                   {http_options,"HTTP/1.1",infinity,true,
                                       {essl,[]},
                                       undefined,false,infinity,false},
                                   "http://localhost:8080/blah",[],none,[],
                                   1485261004189,undefined,undefined,false},
                               {options,
                                   {undefined,[]},
                                   {undefined,[]},
                                   0,2,5,120000,2,disabled,false,inet,default,
                                   default,[]},
                               httpc_manager]},
                          infinity]}}}}}},
 [{httpc,handle_request,9,[{file,"httpc.erl"},{line,574}]},
  {concurrent,get,0,
      [{file,
           "c:/Users/piotr_justyna/Documents/rets/performance_tests/concurrent.erl"},
       {line,5}]}]}
我肯定这很简单,只是我不知道是什么。是并发连接的数量导致了它吗?你能帮我解释一下吗

问候,,
Piotr

您的代码生成了大量httpc:request/1调用,但随后它立即停止inets:

由于iNet已关闭,因此仍在进行中的请求会过早关闭,如错误报告中所示:

** Reason for termination ==
** {'EXIT',
       {shutdown,
           {gen_server,call,
               [httpc_handler_sup,
在调用inets:stop/0之前,需要使所有生成请求的父级等待这些请求完成。一种方法是将父pid传递给每个生成的子项,一旦httpc:request/1返回,让子项向父项发送消息。父级将生成所有N个子级,然后坐在一个循环中等待从子级接收N个完成消息,并且只有在接收到所有完成消息之后,它才会调用inets:stop/0

它适用于8个请求而不是9个请求的原因是由于在调用inets:stop/0之前缺少等待的竞争条件。请求处理接受进程的Yaws池的默认大小恰好是8。当您的代码发送8个请求时,池处理它的速度足够快,足以击败代码对inets:stop/0的调用,但对于9,当一个接受者处理两个请求时会有轻微的延迟,而这种轻微的时间更改足以允许您的inets:stop/0调用关闭一个或多个客户端进程。您可以通过acceptor_pool_size配置变量修改Yaws acceptor池大小


如果你认真的进行负载测试,你可以考虑使用一个工业级的解决方案,而不是滚动自己的。

你的代码产生了一些HTTPC:Reald/Cuffic调用,但是紧接着它就停止了:

由于iNet已关闭,因此仍在进行中的请求会过早关闭,如错误报告中所示:

** Reason for termination ==
** {'EXIT',
       {shutdown,
           {gen_server,call,
               [httpc_handler_sup,
在调用inets:stop/0之前,需要使所有生成请求的父级等待这些请求完成。一种方法是将父pid传递给每个生成的子项,一旦httpc:request/1返回,让子项向父项发送消息。父级将生成所有N个子级,然后坐在一个循环中等待从子级接收N个完成消息,并且只有在接收到所有完成消息之后,它才会调用inets:stop/0

它适用于8个请求而不是9个请求的原因是由于在调用inets:stop/0之前缺少等待的竞争条件。请求处理接受进程的Yaws池的默认大小恰好是8。当您的代码发送8个请求时,池处理它的速度足够快,足以击败代码对inets:stop/0的调用,但对于9,当一个接受者处理两个请求时会有轻微的延迟,而这种轻微的时间更改足以允许您的inets:stop/0调用关闭一个或多个客户端进程。您可以通过acceptor_pool_size配置变量修改Yaws acceptor池大小


<> P>如果你对负载测试很认真,你可以考虑使用一个工业级的解决方案,而不是滚动你自己的。质量建议,非常感谢。让我试试,我会更新线程。正是这样,谢谢你。谢谢你推荐tsung-看起来我很快就要开始使用它了。太棒了。质量建议,非常感谢。让我试试,我会更新线程。正是这样,谢谢你。谢谢你推荐tsung-看起来我很快就要开始使用它了。
** Reason for termination ==
** {'EXIT',
       {shutdown,
           {gen_server,call,
               [httpc_handler_sup,