Note: Most of My Website's Storage Costs Comes from a Single Error Log File

Share

My website is hosted on NearlyFreeSpeech. It says I use 419 megabytes of storage, which costs me 41 cents of a dollar per month. That sounds like a lot, but perhaps I just have too many images. Today, I realized 196 of those megabytes come from a single log file.

Apache can log every single HTTP request done to a website in a log file. NearlyFreeSpeech calls this the "access log," and it's disabled by default to save costs. Yes, I'm charged for the size of the log file that resides in the web server I'm paying for. SSDs don't grow on trees, after all. There are two other log files besides the access log: the error log and the rewrite log. The rewrite log is disabled by default, but the error log isn't. Naturally, you would like to log errors if they happen, wouldn't you?

Turns out I had so many PHP errors that the error log file ballooned to 196 megabytes. Whoops!

Of course it's not my code that is broken—my PHP code is impeccable—it's WordPress and its plugins spamming errors and warnings. An excerpt:

PHP Error: PHP Warning:  Undefined array key "HTTP_USER_AGENT" in [...]/wp-content/advanced-cache.php on line 12
PHP Error: PHP Warning:  Undefined array key "path" in [...]/wp-includes/canonical.php on line 728

The first warning comes from a WordPress plugin called "Hyper Cache." I don't know why its file is advanced-cache.php. WordPress can't actually reliably cache anything because it inserts an admin bar if you're logged in, so I'm not even sure what this plugin does, to be honest.

The second issue is part of core WordPress:

Maybe if I updated WordPress it would get fixed, but updating things can break things. Is it really worth the risk just to get rid of a warning?

For now, I'm downloading the logs with scp, "rotating" them (so they're renamed in the server and a new, blank log file starts being used), and deleting the old moved logs to save 19 cents.

Although I'm more concerned about whether having these immense logs is causing performance issues. I do have a terrible Time To First Byte for some reason after all. Or it could be the the real reason for the performance issues isn't the logging of the errors, but that errors are happening?

Observations

NearlyFreeSpeech queues a log rotation if you click on a link labelled "Request Log Rotation." This isn't how it's supposed to work. Visiting a webpage's URL is a GET HTTP request and shouldn't have side effects. It's also misleading from a GUI perspective. It should be a button or a page with a button to POST it.

Comments

Leave a Reply

Leave your thoughts! Required fields are marked *