Over Tweaking

by Pete Freitag

There was a thread recently on the CFGURU mailing list about the merits of the various tweaks that CFML developers use to gain a few extra milliseconds. The consensus was that most performance problems won't be solved by using these tweaks, they typically lay within the database, application architecture, and lack of caching. Here are some tips:

This is all not to say that there are no best practices, there are - you need to evaluate the best practices to see if they make sense.

You should ask yourself before you do anything performance related if it improves your code quality; the readability, maintainability, and performance. If it does then it is a good practice.

Additionally the relative low cost of hardware issue is often an excuse for writing poor performing code. I'm not trying to advocate that you don't pay attention to performance, just that you should be focused when you tune your app. The 80/20 rule states that 80% of the execution time takes place in 20% of your code.

The Fixinator Code Security Scanner for ColdFusion & CFML is an easy to use security tool that every CF developer can use. It can also easily integrate into CI for automatic scanning on every commit.

Comments

Dutch Rapley

So true. A few years back, I was asked to help a developer who was actually crashing Sybase. The developer was looping over a recordset with 1000+ records. With each iteration of the loop, she was making another 5 queries against the database to "join" the related tables. A single request to the CF page would make 5000+ calls to the database. I re-wrote the code for her, making all of her joins in one query. After it worked, her answer was "That can't be right, I'll have to come in this weekend and work on it." The largest contributor to bottlenecks, that I've seen, is improper database interaction (also including design). Many developers can save themselves trouble if they would pick up Ben Forta's Sams Teach Yourself SQL in 10 Minutes. For the developer who finds himself/herself in the database design boat, Groff Weinberg's SQL - The Complete Reference is a nice primer. Of course, there are also other cosiderations, including hardware, webserver, and database server configurations too.