<div dir="ltr">You could tag messages with a timestamp, and each time a client proceses a message, check difference between the message and current timestamp.<div><br></div><div>Processes that get more behind than some threshold can close the connection and exit. </div>
<div><br></div><div>Remember to find the cheap timestamp function - search around here - people have benchmarked them and explained why some are faster and some are slower. IIRC it was something to do with guarantees about increasing values at very high rates on SMP.</div>
<div><br></div><div>Also as mentioned on stack-overflow, ref-counted binaries are held-onto until all processes which have seen them have GC'd so you might need to manually GC on long-lived processes every now and then.</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On 20 September 2013 17:08, akonsu <span dir="ltr"><<a href="mailto:akonsu@gmail.com" target="_blank">akonsu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello,<div><br></div><div>I have posted this question to stackoverflow (<a href="http://stackoverflow.com/questions/18895614/terminate-process-if-it-is-slow-at-receiving-messages" target="_blank">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 href="http://erlang.org/pipermail/erlang-questions/2011-June/059335.html" target="_blank">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>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>