| By Ben Forta | Article Rating: |
|
| June 16, 2003 12:00 AM EDT | Reads: |
14,177 |
Most Web-based applications operate in real time. Add an article to a database and it shows up immediately on content pages. Update a user address and the new contact information is available immediately. Add or remove an employee and the phone directory is correct when next viewed. Real-time data in a real-time world. That's a good thing, isn't it?
Real Time Is Real Expensive
In an ideal world, real-time everything would indeed be a good thing. But we don't live in an ideal world. As appealing as always being up-to-date is, real time comes with a real cost:
If you were to analyze all the timings and debug output from your ColdFusion applications, you'd undoubtedly find that more time is spent processing <CFQUERY> tags than anything else (possibly even everything else combined). In other words, eliminate all your <CFQUERY> tags and your application will fly. And while avoiding databases is not at all practical (or even advisable), understanding the price of real-time data interaction is important.
Of course, database access and <CFQUERY> are not the only culprits; you likely use Web services and CFX tags and calls to COM and Java and more, and all of those can impact performance too. But databases are a good place to start because they're so prevalent and because making changes (where appropriate) is actually not that difficult.
Is Real Time Really Necessary?
Obviously, some applications (or parts thereof) must be real time. Could you imagine eBay auctions if bids were updated only periodically? How do you think users would react to Amazon.com listing products as in stock only to send out an "oops" e-mail after checkout? What would users do if they changed their AOL or Yahoo or MSN passwords only to find that the password change took some unknown length of time to take effect? All of these sites utilize real-time processing to ensure the best customer experience - some operations simply must occur in real time.
And that's key - some operations, but not all. If you were to place an online classified listing on any of the major classified sites (including Yahoo) you'd find that your ad did not appear instantaneously. Rather, listings are updated with current information at regular intervals. Similarly, online user directories obtain new data on a regular basis, but online listings sometimes take months to be updated.
So why are some operations performed in real time and others not? Simply because there is a tradeoff to be made - the more data is real time, the greater the hit on performance and scalability. As such, developers of applications have to choose between the two, and for many, the choice is to not perform real-time processing unless it is absolutely required.
But most ColdFusion developers don't make the choice at all. ColdFusion makes implementing real-time processing so easy (much easier than implementing anything non-real time) that they go the real-time route by default. That's a real problem.
Reducing Database Reads
I'm not going to be able to cover every real-time scenario in this column, but I would like to point out some ideas you should think about as a starting point. The simplest (and remarkably effective) change you can make to your application involves the reading of data from database tables. <CFQUERY> is a very powerful tag; it lets you access all sorts of databases easily, maybe too easily. And so developers tend to overuse <CFQUERY>, often rereading data that likely has not changed (or has changed with changes that need not be utilized immediately).
I covered reducing database access via caching extensively in a column entitled "Caching in on Performance" (CFDJ, Vol. 1, issue 2). As explained there:
Where would you use caching within your applications? Here are some examples:
Even though frequently retrieved data is likely cached by the database server itself, retrieving the data again is obviously more resource intensive than not requesting it at all. Furthermore, as ColdFusion usually isn't running on the same box as the database server, eliminating unnecessary database requests can also reduce network traffic between the two machines, which in turn further eliminates potential performance bottlenecks.
ColdFusion provides two different ways to cache database reads:
I am not going to explain these here; refer to the previously mentioned column to learn more.
Reducing Dynamic Processing
Beyond database access, you likely have entire blocks of your application that are being generated programmatically in real time, but that perhaps need not be. For example, the above mentioned employee list. Not hitting the database unnecessarily is a great first step, but you also loop through the results creating output and embedding formatting. Does that really need to occur on each and every page request?
ColdFusion provides several options that may be used to reduce dynamic processing, and you may use any or all of them (or roll your own). In order of granularity:
Of course, each of these options requires that you give something up; if you serve cached content you are serving old (not real-time) content. But depending on what your app is, that may be entirely acceptable. And if so, all you have to lose are performance and scalability problems.
Using Delayed or Batch Processing
One of the most important (and least trivial) concepts in the real-time discussion is the use of delayed or batch processing. The best way to understand the idea is via examples. So:
In all of these examples, some processing is postponed and/or batched. The result? Not only are the applications faster and more scalable, but the developers also have greater control over exactly what operations occur and when.
Conclusion
Real time has become the norm by default, not by necessity. And real time causes real problems. Database caching, dynamic output caching, and delayed or batch processing are all concepts that can (and should) be leveraged so as to improve application performance and scalability. The truth is, there is no right or wrong here - everything is a tradeoff. Not all options will always be usable (you'd not want to use delayed batched credit card processing, for example, if you are selling access to a paid Web site). As a developer you get to make the real-time versus non-real-time choice. The important thing is that you actually make the choice. And I think you'll find that most parts of most applications actually need not function in real time at all.
Published June 16, 2003 Reads 14,177
Copyright © 2003 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Ben Forta
Ben Forta is Adobe's Senior Technical Evangelist. In that capacity he spends a considerable amount of time talking and writing about Adobe products (with an emphasis on ColdFusion and Flex), and providing feedback to help shape the future direction of the products. By the way, if you are not yet a ColdFusion user, you should be. It is an incredible product, and is truly deserving of all the praise it has been receiving. In a prior life he was a ColdFusion customer (he wrote one of the first large high visibility web sites using the product) and was so impressed he ended up working for the company that created it (Allaire). Ben is also the author of books on ColdFusion, SQL, Windows 2000, JSP, WAP, Regular Expressions, and more. Before joining Adobe (well, Allaire actually, and then Macromedia and Allaire merged, and then Adobe bought Macromedia) he helped found a company called Car.com which provides automotive services (buy a car, sell a car, etc) over the Web. Car.com (including Stoneage) is one of the largest automotive web sites out there, was written entirely in ColdFusion, and is now owned by Auto-By-Tel.
![]() |
Kevin 10/03/05 06:21:03 PM EDT | |||
Great article, but small site owners remember that you probably don't need to worry too much about this, but keep it in mind if you ever want to grow. I just switched a site over to a full CFML backend that write static .html files to disk only when the admin tells it too. There is Tons of data in databases, but it only changes now and then. a few times a week at most. A full site rebuild only takes about 3 seconds when the .html files are created. |
||||
![]() |
Steve Sommers 10/16/03 01:03:46 PM EDT | |||
Harry, Ross, I've been programming for over 25 years now and this is the first time I have ever this definition of "real-time" -- "Real time refers to an environment in which some bit of code can be executed within a very precise time frame. Due to net latency alone, no web application is real time as the execution time cannot be guaranteed within *any* boundaries (other than 0 to infinity :)." Maybe I'm straining at gnats here but I always considered our payment processing solution "real time" and some of the front end communication takes place over the Internet and some of the back end communications takes place over other nets -- does this automatically disqualify it as real time? Or does the fact that our front end "over the web" communication modules which compensate for timeouts and protocol failures much more quickly than the standard HTTP protocol bring us back into the real time environment? I?m VERY confused by the above stated definition. Here?s my quandary: Can "very precise time frame" be defined in such a way that no application known to man can achieve "real time" status or can the "guaranteed within any boundaries" be overcome by simply defining a fixed timeout or can no piece of code which must communicate to any other piece of code (including a database server) be real time? |
||||
![]() |
Ross Fortini 07/08/03 06:39:00 PM EDT | |||
I agree 100%, Harry. I think that most misusers of the term "real-time" _really_ mean "synchronous," i.e. "I cannot successfully complete my task until this process I'm dependent upon finishes." I am likewise bothered by the use of "near-time"--though in this case it's just that the word "near" is much more ambiguous than it appears at first blush. Too bad "asynchronous" is apparently too difficult to use. (I once heard a Java developer refer to that term as "too mainframey!") |
||||
![]() |
Harry Slaughter 07/07/03 04:45:00 PM EDT | |||
i wish folks would stop mis-using the term "real time". Real time refers to an environment in which some bit of code can be executed within a very precise time frame. Due to net latency alone, no web application is real time as the execution time cannot be guaranteed within *any* boundaries (other than 0 to infinity :). A web app may seem very very fast, but it's still not real time. This may seem like a trivial point, but misusing terms like this one defeats the original purpose/definition of the term :) |
||||
![]() |
Martin Ladner 06/23/03 12:34:00 AM EDT | |||
- Do it now. If you do the task now, the user you're dealing with has an expectation that there might be a short pause while you perform the task requested or triggered by the user. The longer you put off a task, the greater the resource hit; a long-delayed task will result in a drop in performance noted by all users at that moment, a drop that has nothing to do with them. And, it will affect them longer than it would have affected the single user requesting a task to be performed. In a contest between scanning a large database for unfinished tasks or performing a task (typically transaction/message file creation and a database update) while the appropriate keys are known, doing it now will always win. |
||||
- Oracle To Keynote Cloud Computing Expo
- Contrary Opinion: Why Silverlight is Good for Adobe
- Analytics for Adobe Air Applications
- Adobe’s Aiming ColdFusion at Multiple Clouds
- Eval JavaScript in a Global Context
- Fig Leaf Software to Exhibit at Government IT Conference & Expo
- Is Microsoft as Free as Open Source?
- Cloud Computing Journal: Adobe to Deliver ColdFusion in the Cloud
- The Planet Named “Bronze Sponsor” of Cloud Computing Expo
- Adobe Reader Sued
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Adobe Enters Cloud Computing with LiveCycle
- Oracle To Keynote Cloud Computing Expo
- Social Media Terrorists
- Adobe Flash Media Server on iPhone
- Contrary Opinion: Why Silverlight is Good for Adobe
- Adobe Flash Based GetJar Surpasses a Half Billion Downloads
- Adobe ColdFusion 9 and ColdFusion Builder Public Betas Now Available
- Adobe Tries Commercializing Its Online Software
- Adobe Open Sources Flash Initiatives
- The Next Programming Models, RIAs and Composite Applications
- Where Are RIA Technologies Headed in 2008?
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- Has the Technology Bounceback Begun?
- Building a Zip Code Proximity Search with ColdFusion
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers


































