开发者

Does having Rails logging enabled on a production environment a performance hit?

开发者 https://www.devze.com 2023-04-10 05:24 出处:网络
I hope this question isn\'t too vague, but does logging in a production开发者_Python百科 environment cause a hit in performance? In addition to the traditional production.log logging, we have a couple

I hope this question isn't too vague, but does logging in a production开发者_Python百科 environment cause a hit in performance? In addition to the traditional production.log logging, we have a couple of additional things we record in begin/rescue type events to help us for debugging issues.

In our production.rb file, our settings are:

config.log_level = :info
config.active_support.deprecation = :log

And we also have some:

TRACKER_LOG.warn xml_response_hash

These files can become quite large (1 or 2 GB each) and our website receives a couple million page views a month. Chould minimizing our use of logs on production help with performance?


Logging does impact on performance, but it can still be useful in production if it allows the people running the service to diagnose problems without taking the service down.

That said, a couple of million hits a month is less than 100k per day (on average) and that shouldn't be too much of a worry. Similarly, a few GB of log files should not be a worry provided the service is deployed sanely — and provided you're using a log rotation strategy of course — since disk space is pretty cheap. Thus at current levels, I'd suggest you should be OK. Keep an eye on it though; if traffic suddenly spikes (e.g., to 1M hits in a normal day) you could have problems. Document this! You don't want the production people to be surprised by these sorts of things.

Consider making the extra logging conditional on a flag that you can disable or enable at runtime so that you only collect anything large if you're looking for it; with usual volumes of logging data there's a good chance that you'll only look for problems occasionally anyway.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号