<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Polling the message_queue_len of an
Erlang pid is sort of like trying to catch a falling knife, and it
is wasteful, processing time-wise. If you could set a limit on
the message queue size of an Erlang pid, that might help, but it
doesn't really help you handle error conditions. The best
solution is to queue the messages you care about, within the
Erlang pid's data, if they can't be handled immediately, so it
becomes a queueing problem.<br>
<br>
To handle slow clients, you just give each client a timeout
value. The OTP/Erlang source code doesn't decrement timeout
values as time elapses, so it is possible that a timeout doesn't
terminate a message call path in a way consistent with the timeout
value. The top-level function call throws an exception, but other
pids may continue to execute despite the timeout expiration.
Often, people don't care about the timeout value not handling
cumulative delay. If you do care about handling cumulative delay,
you should look at my open source project here <a class="moz-txt-link-freetext" href="http://cloudi.org">http://cloudi.org</a> ,
since CloudI services handle the timeout decrements and the
queueing (if you would want the most accurate timeout adjustments
possible, there are CloudI service options for that here:
<a class="moz-txt-link-freetext" href="https://github.com/okeuday/CloudI/blob/master/src/lib/cloudi_core/src/cloudi_configuration.hrl#L78">https://github.com/okeuday/CloudI/blob/master/src/lib/cloudi_core/src/cloudi_configuration.hrl#L78</a>).<br>
<br>
On 09/20/2013 08:08 AM, akonsu wrote:<br>
</div>
<blockquote
cite="mid:CA+eMAwaeXdfs=jkB66ZF8oiiLpw3MnQgQMZGNzQTmPPXL+D+TA@mail.gmail.com"
type="cite">
<meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
<div dir="ltr">Hello,
<div><br>
</div>
<div>I have posted this question to stackoverflow (<a
moz-do-not-send="true"
href="http://stackoverflow.com/questions/18895614/terminate-process-if-it-is-slow-at-receiving-messages">http://stackoverflow.com/questions/18895614/terminate-process-if-it-is-slow-at-receiving-messages</a>)
and received one helpful response, but I am still not clear
about the right way to do it.</div>
<div><br>
</div>
<div> I also have seen this thread: <a moz-do-not-send="true"
href="http://erlang.org/pipermail/erlang-questions/2011-June/059335.html">http://erlang.org/pipermail/erlang-questions/2011-June/059335.html</a>,
which is somewhat similar but it still did not hep me.</div>
<div><br>
</div>
<div>I would appreciate more help. Here is the question:</div>
<div><br>
</div>
<div><br>
<div><br>
</div>
<div>
<div>I have a data source process that sends messages to
worker processes. To keep memory consumption under
control, I need to terminate the workers that are slow
retrieving their messages from their mailboxes.</div>
<div><br>
</div>
<div>I am new to Erlang, I would appreciate any pointers. If
this is difficult to accomplish with Erlang messages,
maybe I can use sockets? If so, are there examples?</div>
<div><br>
</div>
<div>EDIT:</div>
<div>
<br>
</div>
<div>I have a registered process that reads from the web and
generates a lot of data. It sends these data to all the
"subscribed" processes using Erlang messages. For each
particular piece of data, it sends the same message to all
subscribers.</div>
<div><br>
</div>
<div>I also have a web server that streams the data that the
registered process reads. So, when a http client connects,
the web server creates a process and this process
subscribes to the registered process and starts receiving
its messages.</div>
<div><br>
</div>
<div>The registered process uses monitors to monitor
subscribers. The subscribers are controlled by the web
server, and when a connection is closed, the process that
were serving this connection, dies.</div>
<div><br>
</div>
<div>There is no acknowledgement, that is, subscribers do
not respond when a message is sent to them. Although I can
program them this way, but I think it is too much traffic.</div>
<div><br>
</div>
<div>Basically I want to close the connection if a http
client is too slow.</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
</blockquote>
<br>
</body>
</html>