ColdFusion 9.0 Resources |
Using the Server Monitor to improve server performanceThe Server Monitor provides information that you can use to help improve the performance of your ColdFusion server. Find bottlenecks in your application during development
JVM memory usageBecause ColdFusion is an enterprise Java application, the Java Virtual Machine (JVM) is the software component that most influences performance. Different JVMs from different vendors and different versions of the same JVM from the same vendor have different performance characteristics. You might benefit from changing the JVM that you are using with ColdFusion. ColdFusion contains an embedded version of JRun 4 as the application server and the Sun 1.6 version of the JVM. By contrast, ColdFusion for J2EE running on IBM WebSphere Application Server uses the JVM that WebSphere is configured to use. To configure ColdFusion to use a different JVM, edit the cf_root/runtime/lib/jvm.config file with a text editor by modifying the value of java.home to point to the root directory of the JVM to use. Alternatively, you can switch to a different JVM in the ColdFusion Administrator on the Java and JVM Settings page. Because switching the JVM changes the software environment significantly, do so first in a development or testing environment. Also, fully test your ColdFusion applications before you make the change on a production server. The JVM performs memory management and can have a significant effect on your performance depending on how you configure the JVM. The most important settings for the JVM are the initial heap size and maximum heap size. The initial heap size represents the amount of memory that the JVM uses on startup; the maximum heap size represents the amount of memory that the JVM can use. You can modify these settings in the ColdFusion Administrator on the Java and JVM Settings page. The Initial Memory Size setting specifies the initial heap size; the Maximum Memory Size setting specifies the maximum heap size. The JVM arguments for initial heap size and maximum heap size are -XmsNm and -XmxNm respectively, where N is the size of the heap in megabytes (MB). These JVM arguments are stored in the jvm.config file, in the value of the java.args setting. The default maximum heap size is set to 512 MB in ColdFusion. For best performance, set the initial heap size and the maximum heap size to the same value. Determining the optimal size for the heap to run the applications on your ColdFusion server results in improved performance. Setting the value too high can result in poorer performance because of the higher degree of garbage collection and internal memory management required for the larger heap. Conversely, setting the heap size too small can result in a java.lang.OutOfMemoryError error if your application tries to use more memory than is available to it. The best way to find the optimal heap size is to run your application under simulated peak load with a large heap and monitor how much memory your application actually uses. If you find that your application uses only 180 MB of memory, for example, you might see performance benefit from reducing your heap size to 256 MB. The java.lang.OutOfMemoryError error can occur in other, more complicated, conditions. One common cause of the error is when objects fill up the heap's permanent generation, which defaults to 64 MB. You can increase the value, for example, to 128 MB, by adding the following JVM argument to the Java and JVM Settings page of the ColdFusion Administrator: -XX:MaxPermSize=128m. Physical hardware memory is an important consideration when determining the optimal heap size. Setting the maximum heap size to a value that exceeds the amount of free physical memory causes severe performance degradation. For example, if you have only 512 MB of physical memory, do not set the maximum heap size to 512 MB. Because the operating system and other running applications use memory, much less than 512 MB of memory is available for the JVM process. it is important to have hardware that meets the requirements of your software application. For best results, run on server hardware with 1 GB or more of physical memory. The Server Monitor Summary page monitors the JVM’s memory usage. Use this information when determining the optimal heap size. Variable memory usageConfigure client variable storage to use cookies or an RDBMS for best performance when using client variables; you do this on the Client Variables page of the ColdFusion Administrator. Wherever possible, it is best to fully scope your variable names, especially when using the isdefined() function. For example, <cfif isdefined("variables.myvariable")> performs much better than <cfif isdefined("myvariable")>. To monitor how variables use memory, view the reports in the Memory Usage of the Server Monitor. Request handlingThe Simultaneous Requests setting on the Settings page of the ColdFusion Administrator has the largest effect on how well an application performs under load. This setting dictates how many threads are used to simultaneously process incoming requests. For most applications, a good starting point for the optimal value for this setting is three per processor; you can set a dual processor computer to six simultaneous requests. To find the optimal value for this setting, test your application under load with different values until you find the value that provides the best performance under load. While you test your application, you can view the average response time on the Server Monitor Summary page and the reports in Statistics. CachingYou can turn on the trusted-cache setting on the Caching page of the ColdFusion Administrator for production applications so that the server does not check the file system to see if the CFML source code changed since it was last compiled. This setting provides the benefit of minimizing system I/O, which has a major effect on performance. Set the template-cache size on the Caching page of the ColdFusion Administrator to be roughly equal to the number of ColdFusion templates that are normally used. To monitor how your settings affect performance, use the Template Cache Status in the Request Statistics section of the Server Monitor. In addition, use one of the following methods to cache wherever possible in your application:
Database response timeWherever possible, it's best to allow database servers to handle data manipulation. Adding SQL code to handle this work is much more efficient than doing string manipulations or doing in-memory queries (query of queries). Additionally, stored procedures generally provide a higher level of performance than regular SQL queries. Converting queries in cfquery calls to stored procedures and using the cfstoredproc tag typically improves performance. To view database response time information, use the Database section of the Server Monitor (see Database). |