error_logger, full RAM consumption

218 views
Skip to first unread message

Suhail Doshi

unread,
Oct 7, 2009, 1:39:08 AM10/7/09
to mochiweb
Has anyone experienced running mochiweb and having the server after some time consume 4 GB of the total server's ram with the error_logger process having the largest stack+heap size in the crash dump?

The problem would be easy to solve if I could simply find a gradual leak in memory but what is odd is that it instantly consumes all the memory in one giant spike making it hard to track down.

Sincerely,
Suhail

--
http://mixpanel.com
Blog: http://blog.mixpanel.com

Suhail Doshi

unread,
Oct 7, 2009, 2:40:20 PM10/7/09
to MochiWeb
This was resolved by updating to a newer erlang version.

Suhail

Anton Krasovsky

unread,
Oct 7, 2009, 5:20:59 AM10/7/09
to moch...@googlegroups.com
I've had similar problem with error_logger trying to format/print
message containing large binary and running out of memory in the
process. That wasn't related to mochiweb though.

Anton

Suhail Doshi

unread,
Oct 12, 2009, 11:56:19 PM10/12/09
to moch...@googlegroups.com, anton.k...@gmail.com
It sounds like then that if someone POSTs large enough data to a mochiweb server it'll just tank then? What's a counter measure to reject data that's say above 1 M large?

Suhail

Suhail Doshi

unread,
Oct 13, 2009, 12:10:59 AM10/13/09
to moch...@googlegroups.com, anton.k...@gmail.com
Also, I have actually tried turning off error_logger with the problem still persisting

Suhail

Bob Ippolito

unread,
Oct 13, 2009, 1:50:49 AM10/13/09
to moch...@googlegroups.com, anton.k...@gmail.com
It won't even read the data off the socket unless you do something
that starts reading it, and the default functionality will exit if the
body is more than 1MB (e.g. anything that ends up at recv_body()). If
it's reading more than 1MB off the socket, it's almost certainly your
code and not mochiweb.

On Mon, Oct 12, 2009 at 8:56 PM, Suhail Doshi <digital...@gmail.com> wrote:

WARC

unread,
Oct 21, 2009, 8:08:14 AM10/21/09
to moch...@googlegroups.com
Hi !

Is there a doc or examples about how to create, update, and delete
cookies during a Mochiweb session?

Thanks

Anton Krasovsky

unread,
Oct 30, 2009, 2:06:12 PM10/30/09
to moch...@googlegroups.com
Well, there is not much to it:

1. Get cookie from request: Req:get_cookie_value(?COOKIE)

2. Reply of some sort 302 in this case with Set-Cookie in the header:

Req:respond({302, [{"Location", Location},
{"Content-Type", "text/html; charset=UTF-8"},
mochiweb_cookies:cookie(?COOKIE,
Cookie, [{path, "/"}])
], ""})

3. Same as above but expire the cookie:

Req:respond({302, [{"Location", "/"},
{"Content-Type", "text/html; charset=UTF-8"},
mochiweb_cookies:cookie(?COOKIE, "expired",
[{path, "/"}, {max_age, 0}])
], ""}).


Anton
Reply all
Reply to author
Forward
0 new messages