Difference between revisions of "ColdFusion Performance"

From Hostek.com Wiki
Jump to: navigation, search
(Created page with "When analyzing ColdFusion's performance, There are several things to keep in mind including JVM (memory) settings, slowness on the database tier, and memory leaks that can be ...")
 
m (added categories..JH)
Line 32: Line 32:
  
 
Additionally, if you have '''Seefusion''' on your VPS, it will hightlight the server's slowest scripts. You can also obtain stack traces of running scripts to find the root cause of any slowness.
 
Additionally, if you have '''Seefusion''' on your VPS, it will hightlight the server's slowest scripts. You can also obtain stack traces of running scripts to find the root cause of any slowness.
 +
 +
[[Category:ColdFusion]]
 +
[[Category:VPS]]

Revision as of 18:34, 20 November 2012

When analyzing ColdFusion's performance, There are several things to keep in mind including JVM (memory) settings, slowness on the database tier, and memory leaks that can be easily avoided.

JVM Settings

Sizing the Heap

A good set of 64-bit JVM arguments to start with (for controlling memory and garbage collection) are below:
java.args=-server -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:+UseCompressedOops -Xms1024m -Xmx1024m -XX:NewSize=64m -XX:MaxNewSize=64m -XX:SurvivorRatio=4 -XX:MaxPermSize=512m -XX:PermSize=512m -XX:+UseParNewGC -Djava.awt.headless=true

Those settings specify a maximum ColdFusion heap of 1 GB (1024 MB), an Eden space of 64 MB, and a non-heap Perm space of 512 MB. If your application needs a bit more memory, you can adjust the "-Xmx" and "-Xms" values as needed. A good rule of thumb though is to set them to the same value as each other to help improve ColdFusion perform better. More info on tuning the JVM can be found in this article, but the recommended JVM settings above are great for most ColdFusion applications: Java Garbage Collection Tuning

Garbage Collection Performance

Because a lot of the JVM's processing time can be spent in garbage collection of memory, it can be helpful to enable Garbage Collection Logging to your server. In order to do so, just add the following arguments to your ColdFusion server's jvm.config file:
-verbose:gc -Xloggc:gc-1.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps

If you wish to change the name of the log file, just change 'gc-1.log' to the filename you wish. By default, this file will be created in the same folder as your jvm.config file.

Tuning the Database Tier

Add Indexes

Make sure all database fields are indexed properly, adding indexes for any columns used in a WHERE clause.

Tune Your Queries

Be sure to remove any 'SELECT *' statements in the code. Instead, explicitly name each column used in a query. Also, make use of query advisors such as this free utility: https://tools.percona.com/query-advisor

Cache Queries Where Possible

Does your application have queries that could be cached? If so, enable caching on those queries as shown here: http://www.coldfusionmuse.com/index.cfm/2010/9/19/safe.caching

Preventing Known Memory 'Leaks'

Specify CFFunction Output Attribute

For any <cffunction> and <cfcomponent> tags, make sure that you have output="false" specified. If for some reason you do need output from the function, be sure to explicitly add the output="true" attribute. There is a bug in CF that leaks memory when the output function is left of function and component declarations.

Use Var Scope for Variables withing CFFunction

Make sure all functions have their variables in the "var" scope, including queries. The varscoper utility here will check your code for any missing var statements in your code: http://varscoper.riaforge.org/ We highly recommend using this on a regular basis for all your sites.

Handle Bots and Spiders Properly

Because bots and spiders can create a lot of useless sessions when indexing sites, we recommend setting a custom session timeout as shown here: Lower Session Timeouts for Bots and Spiders

Debugging Individual Scripts

During non-peak hours for your site, try enabling the ColdFusion debug output and adding your IP to the remote debug IP list. Then load the most frequently accessed pages and grab the debug output. Once you have this, focus on improving the slowest sections of code first.

Additionally, if you have Seefusion on your VPS, it will hightlight the server's slowest scripts. You can also obtain stack traces of running scripts to find the root cause of any slowness.