[erlang-questions] Two questions: a. Recommended Application design b. Erlang memory maangement
Thu Jan 24 19:51:44 CET 2013
An alternative to manual garbage collecting is to do all of the parsing of
this ephemeral data in a separate process that dies when it's no longer
needed. This is probably the best solution, and you could even tune its
min_heap_size when you spawn it such that no GC (or fewer GCs) will be
Some other tuning options available are the spawn_opt (some of these can be
set globally too) fullsweep_after, min_heap_size, and min_bin_vheap_size.
Here's some other resources with good information about the GC with varying
levels of detail:
On Thu, Jan 24, 2013 at 6:38 AM, atul atri <atulatri2004@REDACTED> wrote:
> I recently learned erlang to work on a chat application. I wrote a chat
> gateway for ejabberd. Here is my application design.
> Every time a user logs into ejabberd, two processes(gen_server) are
> created. These processes keep polling two different http addresses for new
> messages and new chat events. These two processes are responsible for
> getting/posting new chat events to/from a http server for each user.
> Communication is done using *big* XMLs. And XMLs are parsed using same
> parser used by ejabberd. Mnesia is used to store parsed XMLs. I used this
> design because
> 1. It is easy to implement polling using timeouts on message boxes.
> 2. I learned that erlang loves processes.
> So here is my first question. Is this application design correct? Or will
> you recommend any other design(like http request pool?)?
> So after creating this application, I load tested it. And here are some
> results. When around 250 users are logged in to ejabberd , memory uses
> reaches to 81% and CPU usages reaches to around 80%. I checked memory and
> CPU usages using 'top' command. And if I increase 20-30 more users,
> ejabberd crashes due to low memory.
> But when I use *erlang*:*garbage_collect*(self()) after parsing xml in
> each process, Memory usages remains from 25% to 40% for same 250 users.
> However CPU usages shoots above 90%.
> So, Here is my second question. Is it wise to use *erlang*:*
> garbage_collect*(self())? I have not seen *garbage_collect* uses anywhere
> else in any other application that I know. Also it would be great if some
> one could throw some light on how erlang garbage collector works. Why does
> not it recollect memory as soon as it is available to be recollected?
> Thanks & Regards,
> Atul Atri.
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions