At my webserver, I have separate logfiles for all my over 250 domains.

Is this showing the server down? Would it be faster to have only one logfile that contains all access-logs?

I will try Disable Apache logging completely

  • I thought, this is a place to ask questions, if someone has done this already. If not, sure, then I will start some benchmarks myself, but why reinvent the wheel? Why the downvote? If this fits better to Server Fault, couldn't you just move this question there instead of downvoting?
    – rubo77
    Apr 30 '13 at 8:42

In my experience, Apache logging (sub)system doesn't come with big enough CPU performance penalty even on extremely busy servers to be worth looking for optimisations down that path, so your optimisation efforts could probably be more rewarding, if you consider other possible bottlenecks, such as I/O and network lag.

  • First, make sure that the HostNameLookups is Off in your httpd.conf (or httpd-vhosts.conf) file. This setting, when On, adds a significant enough lag when resolving DNS names that it may pay off to switch it off on busy servers. If you need to resolve DNS names for statistical and tracking purposes, then I recommend using hardware based DNS resolvers (router, switch, firewall) that have DNS caching capability and can mostly do this asynchronously, then link to these logs when analyzing traffic data.

  • Second, analyze your server's I/O performance and check that frequent writes (IIRC Apache doesn't really read anything from these log files, it just appends to them as a file stream) don't take a significant percentage of your total I/O operations that your server can handle. On spindles (HDD), this can be costly, so you could consider spreading these logs to multiple physical drives instead of writing them all to a single drive. Obviously, if you're using HDDs, switching to SSDs is highly recommended, as they are capable of much higher IOPS. Also check suggestions for this question on Server Fault.

  • You could also check that you're only logging requests that you really need to. Often, requests to some file types aren't even needed or can be moved to other, simpler logs that don't consume system's resources so much (i.e. don't require DNS resolver, if you need this data logged for other requests). Both of this can be set in your Apache configuration file and might save you a microsecond or two on each request (which can accumulate).

Other suggestions could be load-balancing, moving some of the most frequently accessed files to another location and creating your own CDN, and so on, but these already fall way out of the scope of your question about Apache logfile performance.

  • 1
    Ok, so from what I heard now, it won't make much difference on my server, cause the load is not critical. But I got good hints from this question for more optimization, so I mark this solved. Thanks
    – rubo77
    Apr 30 '13 at 11:41
  • HostnameLookups already was "Off" but see my comments in the other answer, It saved a lot of diskusage disabling all logging
    – rubo77
    May 19 '15 at 15:20
  • HostnameLookups already was "Off" and see my comments in the other answer, It doesn't seem to save diskusage disabling all logging
    – rubo77
    May 19 '15 at 15:49

I suggest you check /server-status and sar -d -p. If you see L - Logging state and have high disk latency (see sar's column await higher than tens of msecs), then you would most likely get better performance writing to only one place on the disk rather than to hundreds opened files.

  • I had to enable sysstat in /etc/default/sysstat and restart with /etc/init.d/sysstat restart to watch "system activity information" as the man sais, but there seems to be nothing collected now. how long do I have to wait untill it collects anything? and wouldn't sysstat now cost performance too?
    – rubo77
    May 19 '15 at 13:15
  • I see, it collects data every 10 min by cron. I have a high await value on sda all the time (min. 28 max 149 over the last hour)
    – rubo77
    May 19 '15 at 14:18
  • I can watch -d -c 'sar -d -p|while read i; do echo $i; done|cut -d" " -f1,2,8|grep -v 0,00' and I see: the await time doesn't seem to be affected by logging. Does this mean disabling logging doesn't affect the performance?
    – rubo77
    May 19 '15 at 15:48
  • I collect sar data every second when tuning: 5-55/10 * * * * root command -v debian-sa1 > /dev/null && debian-sa1 1 600 However, you can just collect data ad hoc, this will do samples every second and count average for 5 seconds: sar -d -p 1 5 Run this in your peak time and check the average. Writing into one log file or turning off logs would help in situation when logs are on the same device as your static files and when multiple robots visit your server and download many different static pages - when the files simply do not fit to the cache.
    – brablc
    May 19 '15 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.