[rabbitmq-discuss] gen_server2 ques. and was: Re: clarifying plugin supervision, configuration

Matthew Sackman matthew at rabbitmq.com
Tue Sep 7 16:02:42 BST 2010


Hi Jon,

On Thu, Sep 02, 2010 at 10:13:20AM -0500, Jon Brisbin wrote:
> > Best explained by reading the comments at the top of the gen_server2
> > module.
> 
> Sure. Did that. But I'm wondering (out loud ;) if some of the
> situations described there (ordered delivery, hibernate etc...)
> wouldn't nicely fit what the webhooks plugin is doing. It will sit for
> periods of time with little activity and it would be nice to have that
> hibernation (though I don't know that I could take full advantage of
> it). I'm just not sure that spending time trying to use those features
> would really buy that much. I was wondering if there's a rule of thumb
> that's been discovered here that your situation should hit X number of
> messages or it should be doing Y before you really need to worry about
> using gen_server2? I'm not terribly afraid of being tied to an
> internal API because it'll likely stay a plugin for the foreseeable
> future.

There is no especial rule of thumb there. We tend to use gen_server2
when any of the following are met:

a) we need message priorities
b) we know that this process is going to need to make calls to other
processes whilst its mailbox is massive
c) we want the process to hibernate, but we also know that it might be
woken up fairly frequently and we don't want it to burn huge amounts of
CPU endlessly hibernating and waking up

Point (b) is now irrelevant if you're using a modern erlang - I think
they fixed that in either R13B04 or R14A - check the release notes.

Point (c) is really the motivation behind the backoff stuff - we noticed
that if you had lots of idle queues, and were doing a "watch rabbitmqctl
list_queues" you could max out your CPU because every queue was
hibernating and then waking up.

Matthew



More information about the rabbitmq-discuss mailing list