[erlang-questions] gen_server mailbox scans

Chandru <>
Thu Jan 15 12:34:05 CET 2009


Hi Ben,

2009/1/15 Ben Hood <>

> > * And if you did a sys:get_status(Pid) on the gen_server, you will
> copying
> > the entire message queue just to view it...
> > * Crash reports will be MUCH bigger.
>
> Sure - transferring the mailbox to process memory does make reading
> the state of the process much more heavyweight.
>
> So it would be a good idea to try to avoid this standard calls.
>
> However, I still think the benefit of avoiding the scan outweighs
> these disadvantages in our particular use case. Previously, we used an
> intermediate process as a buffering proxy to solve this problem, but
> modifying gen_server seems less intrusive from an API perspective, and
> it means that we have one less moving part.
>
>
I agree. If you are brave enough to have your own version of gen_server, may
be you can have your message queue in an ordered_set ets table, instead of a
queue. That way, you still keep the message queue in a separate area, and
get all the power of ets. Will work better when you have large message
queues to deal with.

Is there no way you can throttle your clients before they send a message to
the server process? That would make your life a lot easier.

cheers
Chandru
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090115/40d974e8/attachment.html>


More information about the erlang-questions mailing list