littlebizzy / slickstack

Lightning-fast WordPress on Nginx
https://slickstack.io
GNU General Public License v3.0
624 stars 113 forks source link

Nginx access log enabled by default but nginx.conf says not #206

Closed joshfester closed 9 months ago

joshfester commented 9 months ago

In the nginx.conf, it says this about access logs:

"to improve scalability access_log is hardcode disabled to reduce CPU and disk usage"

but then it does not seem to be disabled:

access_log /var/www/logs/nginx-access.log;

Is the access log disabled somewhere else? Am I just misunderstanding this? Also, is this purely about performance or are there other implications like storage space?

Sorry if this is the wrong place to ask. Just trying to get a deep understanding of the whole stack 🤓

jessuppi commented 9 months ago

You are correct @joshfester

There are still some things like this floating around SlickStack, because I'm not sure about a few features being hardcoded or not, or what the best default setting should be. What are your thoughts re: access logging?

In the past the opinion has been it wastes CPU esp. during high traffic. However I'm not sure how serious that is, because I haven't noticed major issues with it in most cases.

joshfester commented 9 months ago

Thanks @jessuppi

I've never run into any scaling issues with access logging, but it does make sense that disabling it would increase performance. It would be very interesting to see a benchmark comparing logs vs no logs

One argument for enabling the logs is monitoring tools. I ran into this issue because I was testing out Nginx Amplify. It not only requires the access logs, it also requires writing additional data to the logs. I believe this is pretty common -- at first glance it looks like this is how Signoz monitors Nginx as well.

Another option is passing the logs to syslog rather than writing directly to a file. I swear I saw some Nginx docs implying that this was better for performance, but I can't find a link. It's possible that this is a good middle ground.

Overall I'd lean towards using access logs for monitoring. However, I still haven't narrowed my search for the best monitoring solution. Would love to hear your thoughts on that if you have any

jessuppi commented 9 months ago

Ref: https://github.com/littlebizzy/slickstack/commit/e0f37fffe6be2f13046e44d60a3918319ecf1910

jessuppi commented 9 months ago

Ref: https://github.com/littlebizzy/slickstack/commit/8bb62da00de515f8e033346e067b3ea0cf1c6f4d

jessuppi commented 9 months ago

Great thanks for the specific examples @joshfester

I've been wanting to hardcode enable access_log for the last few years, just was hoping someone else would come by and sort of confirm my opinions on this publicly. I have some fairly high traffic clients using SlickStack with access logging enabled and haven't noticed any issues, I think for usability it makes much more sense to keep it enabled.

Plus, we just recently added support for cloudflare.conf and real IP tracking anyways.

Ref: https://github.com/littlebizzy/slickstack/issues/198

Another option is passing the logs to syslog rather than writing directly to a file. I swear I saw some Nginx docs implying that this was better for performance, but I can't find a link. It's possible that this is a good middle ground.

That's interesting, I've never heard that before. I wonder why. Well, to keep things clean and organized I think best to keep the logs a bit separate from each other when appropriate so let's keep as-is for now. Thanks!

Re: monitoring prob best to discuss on the forums or Discord