[erlang-questions] Two questions: a. Recommended Application design b. Erlang memory maangement
Thu Jan 24 15:38:58 CET 2013
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
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
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,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions