CB doesn't obey canceled requests

66 views
Skip to first unread message

mar...@campanja.com

unread,
Jan 16, 2014, 9:10:03 AM1/16/14
to chica...@googlegroups.com
Hello,

When e.g. a GET request is canceled from the client's end, CB still performs the request completely. This is a big problem to us since we do some heavy server side report generation. If a user reloads the requests multiple times, chances are that OOM will occur, and we all know that OOM is Erlang's Achilles' heel. I just tested this in v0.8.9.

It doesn't seem as this issue have been raised before but I know the problem has existed from at least 0.8.1. Any plans of addressing it? Gut feeling about how hard this will be to fix?

Best regards,
Martin Torhage

Evgeny M

unread,
Jan 17, 2014, 5:39:17 PM1/17/14
to chica...@googlegroups.com, mar...@campanja.com
I had problems with requests taking too much memory too. I had to move all memory heavy logic into a pool of processes (poolboy), so there could be only so much of such tasks at any give time. When user sends request to create a report, controller tries to checkout a process from pool, and if it gets a timeout it just returns a message to the user that he has to wait for a while.
Another way to throttle is to make such tasks asynchronously. You may store requests for reports in db and return from immediately. There should be a process(es) which perform these tasks in the background and return result to the user via something like ajax or comet. You may even cancel these tasks if, for example, client haven't send a ping request with task id in a given interval of time.

четверг, 16 января 2014 г., 18:10:03 UTC+4 пользователь mar...@campanja.com написал:

Martin Torhage

unread,
Jan 20, 2014, 4:11:01 AM1/20/14
to Evgeny M, chica...@googlegroups.com
Hi Evgeny,

Putting the jobs in a queue makes sense. We're going to do just that and launch a cluster of servers to perform the heavy work. That will reduce the impact of this problem, but the problem will still exist, so I'm still interested to know if anyone knows more about this issue.

Thanks,
Martin

chan sisowath

unread,
Jan 20, 2014, 9:27:59 PM1/20/14
to chica...@googlegroups.com, Evgeny M
Hi,

by the way how do you cancel an HTTP request ?



2014/1/20 Martin Torhage <mar...@campanja.com>
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAD7D%3D90MBKo%3DfoZMOhbNaNx5sZ3NuzGfsa_4zir8%3Df-9t44q0g%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

Cuong Thai

unread,
Jan 21, 2014, 12:09:59 AM1/21/14
to chica...@googlegroups.com, mar...@campanja.com
Hi all,

I don't know how to cancel request to reproduce. I also curious about this.
As I know Django throws Broken Pipe exception when server is handling request if client cancels it. Loïc Hoguin, the author of cowboy server, answers me that it happens similarly with cowboy.

Martin Torhage

unread,
Jan 21, 2014, 7:53:03 AM1/21/14
to Cuong Thai, chica...@googlegroups.com
You simply terminate the TCP connection. In my tests I kill the curl processes performing the requests. In a browser you can do either:
* Close the browser tab or the browser.
* Hit the reload button.
* Abort AJAX requests by calling the 'abort' method on the XMLHttpRequest.

/ Martin

jackie dong

unread,
Jan 21, 2014, 8:16:09 AM1/21/14
to chica...@googlegroups.com
I think this way only kills the client process. It wont kill the server  process.  Maybe you can run the long time task in a separated link process. When the connection is closed by the client, the process on the server side will be also closed. I don't test it, I'm not sure it will work or not.

Martin Torhage <mar...@campanja.com>于2014年1月21日星期二写道:
--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAD7D%3D90%2By8RkAk8e4dKyEE50CwgCeedsbT%3DHMYghoQ65QswR5w%40mail.gmail.com.
Message has been deleted

Cuong Thai

unread,
Jan 21, 2014, 10:21:35 AM1/21/14
to chica...@googlegroups.com, mar...@campanja.com
Hi team,

Thanks to Martin Torhage, I can reproduce "canceled request".

Just implement slow controller:

index('GET', [], Context) ->
    timer:sleep(3000),
    {ok, Context}.

When running "curl http://localhost:8001/public/index", we press Ctrl + C to interrupt process at client side.

It built response completely even request was canceled at client-side
{response,200,[
{header,"Content-Language","en"},
{header,"Set-Cookie","csrf_token=SRRQPPONMLLI; Version=1; Expires=Mon, 27-Jan-2014 17:01:55 GMT; Max-Age=525600; Path=/"},
{header,"Set-Cookie","_boss_session=f5fb29155ac748ab81e40e5a74fd08a8c5d5f6ba; Version=1; Expires=Mon, 27-Jan-2014 17:01:55 GMT; Max-Age=525600; Path=/"},{header,"Content-Type","text/html"}],
[],
{data,[<<"bla bla bla">>]}})
(
in boss_web_controller_handle_request, it calls
handle_request/3,
handle_result/6,
build)dynamic_response/4,
handle_response/4,
then simple_bridge_response_wrapper:build_response/0,
then mochiweb_response_bridge:build_response/2
Here I don't understand why it didn't call cowboy_response_bridge:build_response/2. I define cowboy in boss.config
)
then there are error messages from cowboy
[error] Error in process <0.273.0> on node 'r2d2@localhost' with exit value: {{case_clause,closed},[{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}
[error] Ranch listener boss_http_listener had connection process started with cowboy_protocol:start_link/4 at <0.273.0> exit with reason: {{case_clause,closed},[{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]}
(
I don't know where CB uses cowboy, so I don't know to print debug 
)
Reply all
Reply to author
Forward
0 new messages