postrank-labs / goliath

Goliath is a non-blocking Ruby web server framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Log4r EM-safe?

JoshuaOSHickman opened this issue · comments

Log4r is the logger attached to the rack environment, and I notice you by-default are sending things to the logger, so this is likely to come up as a minor performance issue (in our production environment it was pretty minor). To an extent this seems like an unsolved problem, as EM file i/o is not supported particularly well. I'm sending my logs to another thread right now.

What's the expected pattern on this?

It's "safe" as far as it doesn't introduce any unexpected behaviors. Unfortunately EM does not provide any file I/O API's, so we're stuck with sync flushes. Having said that, you can configure log4r to buffer and flush periodically to minimize impact.

Having run Goliath for in prod for year+, we never had log4r come up as a problem or as a performance bottleneck.

I wouldn't send your logs to a separate thread. Just the act of spinning up an extra thread within EM introduces a whole lot of other performance edge cases.