Friday, November 22, 2013

Errors matter

"If your error_log is bigger than your access_log, you might be a bad webmaster."
--Bill the Web Hosting Engineer

True and wise words.  Most of the problems web designers run into, and escalate to the hosting provider, could be solved simply by paying attention to the logs produced by the web server, the database server, and the language runtime.

The PHP runtime tells you when you've committed a language faux pas such as referencing undefined variables.  While you, the original programmer, might understand that the reference in question is safe, the subsequent maintenance programmer may not.  Write your code to be transparent, so that its intent and correctness are evident by inspection.

Web server logs tell you many things such as broken links that invoke potentially heavyweight HTTP 404 error handlers.

MySQL "slow logs" give you insight into which queries are problematic.  Lots of them indicate that you need to think carefully about what needs indexes.  The ultimate example, I think, came from a client who reported a MySQL error that indicated a full disk.  Investigation showed it was the MySQL slow log that had grown to over 9 gigabytes.  Thus explained all his own end users' complaints about site performance.  His queries were searching an unindexed table containing every commercial transaction his business had performed since it started -- some 3 million rows.

"So you're saying indexing the columns would make the site faster?"
--the client

Yes we can make the point that proper data modeling and implementation is part of the job.  But any person who writes code for the web needs to realize that a properly rendered site in the browser is not the final (or even most important) metric of how successful that product is.  Learn what makes the web work, and learn how to read the indications of success or failure.

No comments:

Post a Comment