Accessibility

Table of Contents

Performance tuning for ColdFusion applications

Performance tuning with ColdFusion Administrator

ColdFusion Administrator provides options for tuning application performance. The effectiveness of the settings discussed below depends on a number of factors including the application itself, load, and number of CPUs.

Caching page

You can use settings on the Caching page to manage how ColdFusion handles caches.

Trusted Cache and Maximum Number Of Cached Templates

ColdFusion compiles CFMs and CFCs to Java bytecode and stores them in memory known as the template cache. On subsequent requests for the CFM or CFC, ColdFusion refers to the compiled template, but also checks whether the actual file has been modified or not.

When the Trusted Cache option is enabled in ColdFusion Administrator under Server Settings > Caching, ColdFusion will not check whether the file has been modified. Because this file system overhead is eliminated, performance improves. In production, if your application does not require automatic detection of template changes then enable the Trusted Cache setting.

Note: While enabling Trusted Cache can greatly improve throughput, there is a drawback. If a file is updated, ColdFusion will not automatically reflect the changes. You can manually clear the cache by clicking Clear Template Cache Now on the Caching page. This will force ColdFusion to reload templates into memory the next time they are requested and recompile them if they have been modified.

By default the template cache can store a maximum of 1024 cached templates. This can be changed under Server Settings > Caching using the Maximum Number Of Cached Templates setting. If your application has more static pages and your server has enough memory, then increasing this value can improve performance. If your application has a very large number of templates and you have increased the maximum number of cached templates, it is a good idea to increase MaxPermSize setting for the JVM as these templates will be stored in permanent generation in JVM. By default this setting is: -XX:MaxPermSize=192m.

Figure 9 shows the performance improvement for BlogCFC when Trusted Cached is turned on.

Throughput comparison with Trusted Cache enabled and disabled

Figure 9. Throughput comparison with Trusted Cache enabled and disabled

Save Class Files

If you enable the Save Class Files option on the Caching page, then ColdFusion will save the class files that the ColdFusion bytecode compiler generates. Instead of recompiling the templates when it restarts, ColdFusion will load templates from disk. There is, however, a tradeoff between I/O operation and compilation time. ColdFusion will take some time to search and read class files from disk, and this must be weighed against the cost in time to compile a template again. Enabling this option may not provide any significant gain in performance.

Maximum Number Of Cached Queries

Because database queries are very time consuming activities, caching queries can increase performance significantly. There are advantages and disadvantages to increasing the maximum number of cached queries. For more details on this topic, see Caching Queries to Disk or to Memory with ColdFusion.

As a rule of thumb:

  • Cache only those queries that are most commonly used.
  • Since you can control maximum number of cached queries but not the amount of memory used by these cached queries, try to limit the size of your recordsets otherwise it will cause issues with JVM.
  • Cache queries with recordsets that do not change very often.

Request Tuning page

The Request Tuning page in ColdFusion Administrator (Server Settings > Request Tuning) provides several options that can be used to improve performance.

Maximum Number Of Simultaneous Template Requests

If the CPU usage of the server on which ColdFusion is installed is low (around 10-30%) then increasing the maximum number of simultaneous template requests can improve performance. If CPU usage is already high then this setting may not help performance.

Maximum Number Of Running JRun Threads

By changing the server's thread concurrency settings, you can limit or increase the number of requests that a JRun server can processes concurrently. This should result in performance improvements as the number of CPUs increases. The number of <cfthread> requests in your application should be less than the value specified by the Maximum Number Of Running JRun Threads setting, since threads created by the <cfthread> tag are mapped to JRun threads. If the number of ColdFusion threads created by <cfthread> exceeds the maximum number specified by this setting then ColdFusion threads will be queued.

For more information on JRun threads, see Tuning the JRun Thread Pool.

Settings page

On the Settings page (Server Settings > Settings) there are two settings to consider.

Enable Whitespace Management

Enabling whitespace management will compress repeating sequences of spaces, tabs, and carriage returns, hence reducing the size of content received from server. Web pages with a significant amount of whitespace will benefit most from this setting.

Disable CFC Type Check

This option turns off verifying the CFC type when calling methods with CFCs as arguments. This option also disables verifying an object that implements the right interface.

I did not find significant gains in performance by turning this option on.

Client Variables page

Client variables let you store user information and preferences between sessions. For better performance, select either Cookies or RDBMS as the client variable storage mechanism.

For more information on how to configure and use client variables see Configuring and using client variables.

Debugger Settings page

On production servers, be sure to disable debugging to maximize performance. Debugging can be disabled on the Debugging & Logging-> Degug Output Settings page of ColdFusion Administrator.

Memory tracking

Memory tracking should be turned off whenever it is not required.