ColdFusion Muse

You CAN Use the File System With Cfdocument (Who Knew)

In regard to my previous post on Cfdocument and SSL I stand corrected. It is definitely possible to use a "file:" protocol identifier in the image path when using Cfdocument. My problem was with the syntax. As is often the case, a helpful reader put me on the right path. Thanks to Julian Halliwell for pointing out that my problem was syntax. I was trying 2 slashes as in:

<img src="file://d:\mysite\images\myimage.jpg" width="50" height="60">
Julian noted that it should actually be 3 leading slashes after the "file:" protocol identifier.
<img src="file:///d:\mysite\images\myimage.jpg" width="50" height="60">

Not only is this a rock solid fix for the SSL issue (see the previous post) but it has the potential to dramatically impact the speed of your cfdocument call, especially if you using large images. We have an application that embeds fairly large photographic images. I'm guessing this will greatly increase the speed of rendering. I'll post a follow up and let you know.

Cfdocument and SSL

Some of you might have read my post on Cfdocument Performance. One of the tips in that article is to watch out for external resources. If your HTML is pointing to images or css files (as opposed to "in-line" CSS), cfdocument will have to "go get" those files. The way it does this is important. The server does not does not simply "include" the file (a la cfinclude). Instead, cfdocument impersonates a browser and uses HTTP. This has an impact on how you use Cfdocument. Each cfdocument call has the potential to generate many http requests. Here are the details.


Limiting the Size of a POST Request

CF Muse Reader Asks:
With CF 7 is there a way to control the max file size on a upload? to prevent someone uploading a massive file?

Oh how I love easy questions. Yes Virginia you can do this but only "globally" through the CF Admin. Log into the CF Administrator and click on the "settings" link. There are 3 new settings that apply here. Here's the scoop from the release notes.

  • Maximum size of post data (MB) - Limits the amount of data that can be posted to the server in a single request. Coldfusion rejects single requests larger than the specified limit. The default value is 100 MB.

  • Request throttle threshold (MB) - Requests smaller than the specified limit are neither queued nor counted as part of the total memory. Requests larger than the specified limit are counted as part of total memory and are queued if the request throttle memory size has been exceeded. The default value is 4 MB.

  • Request throttle memory (MB) - Limits total memory size for the throttle. If there is not enough total memory available, Coldfusion queues requests until enough memory is free. The default value is 200 MB.
The "maximum size of post data" is the one that you need to worry about. It limits the amount of data that can be posted to Coldfusion. Keep in mind that if you expect a lot of this sort of activity the throttle memory will come into play. It's the total heap amount allocated to handle the throttle.

A Case for a Higher Default "Simultaneous Request" Setting

In a technote titled Coldfusion Performance Tuning that was last updated on March 7th 2003, the following advice was given regarding the "simultaneous request" setting in the Coldfusion administrator. The writer indicates that this setting has the largest impact on scalability, and then goes on to recommend a setting of 3 times the number of processors as a "starting point". This number has been oft stated as the "rule of thumb". I've heard as 2 to 3 requests per processor and I've often heard the number of 4 to 5 per processor, although I was unable to locate that recommendation in any online documents. I think this baseline recommendation should be changed to as high as 7 to 10 per processor for a CFMX server on a modern server (P4 or Xeon).


File Uploads - Does Size Really Matter?

When creating complicated web applications you sometimes run into situations where long running requests are necessary. Please don't email me with altruistic best practice jargon. I know they are not a good idea. My point is, that they can be unavoidable in some cases. Consider file upload for example. Suppose you need to allow users to upload more than 1 file in a single request (let's say 5) and suppose the files are typically .5 to 2 Megabytes. Potentially this means a maximum total aggregate of 6 megabytes.


Why is my Jrun Error Log So Big?

CF Muse Reader Asks:
On our CF 6.1 server, we have a /CFusionMX/runtime/logs/default-err.log file that is over 100MB in size. Is there a good way to knock that down, or is it okay to just delete the thing?

First things first, yes it is fine to delete this file. Make sure you know why it is growing so large - there may be errors you should be concerned about, and this file merits your review. In order to delte the file you will have to stop coldfusion. Upon a restarting Coldfusion will actually recreate the file starting with a nice tidy 1 kilobyte. You might notice that the "event" log actually "rolls over" every 200k. Wouldn't it be nice if the err log did that too? It can...


Sessions and Cookies and Bots (oh my)

Would you like to know how to create your own memory leak using the design of the Coldfusion Server to do it? Here's one way. Let's say you have a site that sells products from Narnia. It has a root folder that display your products and prices. You've done a great job of creating friendly links for browsing your Narnia products. You have stuffed Aslan lions both friendly and fearsome, White witch figurines, fauns, nyads, dryads, a toy lamppost and even a wardrobe for sale. Let's say (for the sake of argument) that you have 50 links to Narnia products just on your home page. If a user chooses to buy one of your products he or she clicks on "add to cart". At this point the user is taken into the "/shop/" folder to the page at "". So far so good. This is how many online stores are organized and it's just peachy. But let's look under the hood shall we.

Listen Here


Terminal Services, Win3k SP1 and CF May Cause Memory Leak

Paul Vernon posted an interesting item on CF Talk regarding a memory leak on a Windows 2003 server running SP 1. His contention was that when you log on to a Win3k server that is running Coldfusion using terminal services, then log off again, the memory is not being released from the "winlogon" process. Over time the memory usage builds up into the hundreds of megabytes causing a resource utilization issue. We've seen this as well, although I do not think it has anything to do with Coldfusion. I imagine that other 3rd party server applications would cause the same behavior. In any case, I reviewed his fix and it seems to work splendidly. Here's some more information.


Coldfusion Administrator and the jvm.config file (a love-hate relationship)

If you are using CMFX and trying to "tune" the JVM - or maybe even just adding a class path, I have some advice for you. Don't use the CF Administrator to do it! Instead, get used to editing the jvm.config file located in cfusionmx7/runtime/bin. Not only will you benefit from gaining a better knowledge of the inner workings of your JVM, but you will also miss out on a ticklish bug that will have you scratching your head in frustration. Here's the scoop.


Finding all those sneaky log files in Coldfusion

At some point you will have to troubleshoot server problems. Trust me - it will happen. It's no good sticking your head in the sand or your fingers in your ears (or both - tricky, but doable). Your first question will likely be, "Where do I find out information about what is happening on the server." Fortunately there are a great many log files in Coldfusion. Unfortunately they are not easy to find, and they contain different formats of information. There are 3 "groups" of file based logs on a Coldfusion MX installation. These groups are mostly the same for CFMX 7 as they are for CFMX 6 and CFMX 6.1 (a few exceptions). Here's a rundown:


Coldfusion and its undeserved Bad Rap - is it I?

Bill Moore is a very good friend of mine. He owns and operates EV World. Bill is a case study for the best and worst thing about Coldfusion - it's ease of use. The fact that CFML is accessible as a language makes it a great choice for designers to enter the world of web programming. Bill is an excellent designer and an amazing individual. It's impossible to meet him without warming to him immediately. His real passion isn't web programming, it's alternative energy technology. He uses Coldfusion because he can write all kinds of code and it will usually work. In fact, Bill absorbs only the amount of CF that he needs to update his site and add the features he wants. As you can see by reviewing his site that is actually quite a lot by now. The rest of his enormous energy is devoted to promoting alternative sources to fossil fuels. Looking at EV World it's hard to believe it's the work of a single man. It looks more like a corporation with a team of developers. He offers subscription services, reviews, news, dozens of articles - a whole cornucopia of content for anyone interested in a green way of life. Yet Bill would not characterize himself as a Cold fusion developer.


<CFLOCK> and Synchronizing Data

Locking among CF developers arouses the same sort of Ire as the Linux Vs. MS debate. There are CF developers who believe that locking is unnecessary in most cases and locking everything is an unnecessary waste of time and effort. There are others who believe that everything should be locked without regard to any examination of the data or its significance. Both camps have salient points and I do not fault either of them for their viewpoint. In our case we err on the side of caution. We lock every write for the session and application scope and we lock "most" reads of the session scope. That's our standard and I only mention it to get it out of the way. I do not intend write an apology on wether you should lock or not. Instead, I think we should examine how locking syntax varies and how it used appropriately (or inappropriately).


Using <CFFLUSH> for better page loading

I've found cf flush to be useful when you are serving up long tabular report data. If you are going to output several hundred rows, cfflush can help a lot. One approach I've used that works great for intranet sites where the browser is a known item is a combination of a status bar, javascript and cfflush. I create a flash movie that has a status bar with frames from 1 to 100 (1 being an "empty" bar and 100 being "filled") based on a variable I can set using the "SetVariable( )" function in Javascript. Then, as I'm outputting data I increment that variable using cfflush and javascript.

For example, using MOD 100 (or whatever threshold makessense to you) and currrent row I could run a calculation that gives me the percent commplete of the output. let's say 13 percent at row 200. Then, I would write this: ( <script> movie.SetVariable(13,"13%"); </script >) .. the first item is the frame number I want the movie to go to and stop, the second variable is a label. I use <CFFLUSH> to send it to the html page where it is run "inline" immediately. The result is a nice looking status bar that climbs incrementally at the top of the report and lets the user know that data is being sent to the browser and to please be patient. This approach can be useful for things like data upload tools where user uploads a spreadsheet or database that is subsequently inserted into a table or appended to a file.

For source files click here.


Troubleshooting Coldfusion 4 and 5 servers

Finding a cause for something as generic as a CPU spike can be a frustrating task. In my experience it is best to start with "known" issues and get them out of the way. First, ensure that the OS is up to date with all patches (if using w2k - sp4). Likewise the RDBMS server should be up to date - both the OS and the application (sql2000 SP 2 for example). Next, examine the CF server and make sure that it is up to date as well. Be careful - make sure that all patches are installed and tested for compatibility on the dev server first. I never install a patch on the first day - or without doing it on the dev server first. Patches get rolled back too. Current CF 5 version is 5.0 - but there is an extensive list of hot fixes that may or may not be germane to your installation. Here's a link to Macromedia's Patch List.


Locking in CFMX

This is an outstanding article by Brian Kotek on locking in CFMX. His description of "stateless" cfcs and how they handle the variables and the this scope is especially good.

Locking data and persisting CFCs in ColdFusion MX

More Entries

Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.