Out of memory issues caused by error_logger

88 views
Skip to first unread message

Suhail Doshi

unread,
Feb 18, 2010, 6:45:11 AM2/18/10
to MochiWeb
I am pretty sure I am having this issue:
http://blogtrader.net/blog/a_case_study_of_scalable

Though he talks about it, he doesn't offer a solution--does anyone
know a good solution. I am noticing my mochiweb process hits 4G of
used memory every now and then (we do a sizable amount of requests a
second). The server essentially becomes unresponsive. Debugging in the
past showed it was error_logger proc.

Anton Krasovsky

unread,
Feb 18, 2010, 2:06:40 PM2/18/10
to moch...@googlegroups.com
Are you logging anything to error_logger or the logging messages are
the byproduct of crashes? I had the later problem, where processes
handling large binaries (images) would crash and erorr logger would
use too much memory trying to pretty-print the crashed process data.

anton

> --
> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> To post to this group, send email to moch...@googlegroups.com.
> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mochiweb?hl=en.
>
>

Bob Ippolito

unread,
Feb 18, 2010, 9:07:42 PM2/18/10
to moch...@googlegroups.com
You can get around that by handling exceptions in your loop function
and providing your own error logging (or not). The pattern we use
looks basically like this:

loop(Req) ->
try
%% do something here
catch
exit:normal ->
%% this happens when the client closed the connection
exit(normal);
Type:What ->
Report = ["web request failed",
{path, Req:get(path)},
{type, Type}, {what, What},
{trace, erlang:get_stacktrace()}],
error_logger:error_report(Report),
Req:respond({500, [], []})
end.

Anton Krasovsky

unread,
Feb 19, 2010, 7:31:29 AM2/19/10
to moch...@googlegroups.com
Thanks Bob! I've stopped handling large binaries in-process, but that snipet
would come handy to silence the occasional unexpected requests, like
proxy scanning attempts, etc.

Anton

Reply all
Reply to author
Forward
0 new messages