Skip to page content or Skip to Accesskey List.

Work

Main Page Content

Ben Forta On Optimizing Cf4 Applications

Rated 3.78 (Ratings: 2)

Want more?

 
Picture of r937

rudy limeback

Member info

User since: 14 Dec 1998

Articles written: 12

Ben Forta, Allaire evangelist, presented "Optimizing ColdFusion 4 Applications" at the Toronto CF User Group meeting last night. Here's a summary of some of his strategies.

Use the Database

According to Ben, the single biggest culprit in poorly performing CF websites is the CF programmer trying to do the database's job. Because CF is a runtime interpretive environment, you should use the database wherever possible, particularly for
  • relational integrity
  • triggers
  • unique constraints
  • sql aggregates and functions
For example, let the database default the current time into a timestamp column when inserting a new record, rather than using CF's Now() function and converting it to fit the database input datetime format. Another example? Use a trigger to return a database auto-generated value rather than a SELECT MAX() query to find the value that was just created.

Reuse Code

Use CFINCLUDE and Custom Tags (a powerful "black box" feature, especially in CF4+), to modularize your code and make it easier to maintain and optimize. Custom Functions will probably be available in CF5.

Caching

Hard drives are "the only component in your computer with a mean time between failures actually stamped on them," said Ben. "They will disappear, but not any time soon." Cold Fusion supports three types of caching:
  1. page level caching -- CF opens and reads a cfm page, translates it into P-code, and keeps it in cache; bump your 1024K default high enough to hold all the cfm pages in your site (the memory is not allocated, it's just an upper limit).
  2. page output cache -- use CFCACHE to cache dynamic output to simulate static pages (a great example is evolt's own FAQ page at http://evolt.org/faq/index.html)
  3. query result caching -- "How many times do you want to go to the database to get state codes to populate a drop down list? This being Canada, when was the last time you added a new province?" Ben asked. Many in the audience immediately shouted "Last April!" Not missing a beat, Ben came back with "And the time before that?" Another example where query result caching should be utilized is for "next N" queries, which otherwise would re-return the entire result set every time.
Ben also urged greater utilization of database stored procedures, but cautioned that CF cannot handle return codes, output parameters, or multiple result sets for one query.

The evening concluded with a question-and-answer session briefly covering Spectra, JRun, and WDDX. If you ever get a chance to catch a Ben Forta presentation, I recommend it highly.

rudy limeback

My involvement with evolt.org goes back to 1998, as one of the original founders. I'm an SQL consultant who dabbled in web development for several years, in the "golden age" between HTML 2 and XHTML 1.1. My web sites are r937.com and rudy.ca. I live in Toronto, Canada, and you are all cordially invited to come and visit and play a round of frisbee golf with me.

The access keys for this page are: ALT (Control on a Mac) plus:

evolt.org Evolt.org is an all-volunteer resource for web developers made up of a discussion list, a browser archive, and member-submitted articles. This article is the property of its author, please do not redistribute or use elsewhere without checking with the author.