Random things #7

Written on 2 December 2014, 10:55pm

Tagged with: , , ,

1. Custom templates for request debug output

Use case: you want to temporarily enable debug output in a production environment (ex – to determine the cause of a specific performance problem), but you obviously don’t want the users to see the debug information.
Solutions:
– restrict debug output to your IP only (if you know exactly who is behind your IP), but it will still introduce a performance problem (the IP has to be checked for every request)
– create a custom debug template (*) – example logging.cfm instead of classic.cfm and log all the details you need instead of outputting
– create an empty debug template (silent.cfm), then create a component with a main logging method based on the classic.cfm debug template. Call this main method onRequestEnd to log all the needed details.

(*) A custom debug template can be created and placed in the WEB-INF/debug ColdFusion folder. The classic.cfm template can be used as starting point.
More info: http://www.bennadel.com/blog/116-finding-template-execution-stack-in-coldfusion.htm

2. When a ColdFusion template cannot be found

Use onMissingTemplate and return a 404 HTTP error code. Let the web server handle the error:

<cffunction name="onMissingTemplate">
    <cfargument name="targetPage" type="string" required="true"/>
    <cfheader statuscode="404" statustext="Not Found">
</cffunction>

3. AJP proxy

The Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web server through to an application server that sits behind the web server. #

In some setups you can use ajp to forward the web server requests for ColdFusion to the CF Application Server (like JRun or other J2EE server). If your web server is Apache you can use ProxyPassMatch and ProxyPassReverse directives to achieve this.

4. JDK 8 support

A post from the official ColdFusion blog where the ColdFusion JDK support is described. While the information is very useful, it is not the best example of clarity and usability. A matrix like the one below would be more suitable:


+=============================+=======+=======+======+
|              -              | JDK6  | JDK7  | JDK8 |
+=============================+=======+=======+======+
| CF 11 Update 3 and later:   | -     | -     | Yes  |
+-----------------------------+-------+-------+------+
| CF 11 Update 2 and earlier: | -     | Yes   | -    |
+-----------------------------+-------+-------+------+
| CF 10 Update 14 and later:  | -     | -     | Yes  |
+-----------------------------+-------+-------+------+
| CF 10 Updates 8-13:         | -     | Yes   | -    |
+-----------------------------+-------+-------+------+
| CF 10 Update 7 and earlier: | Yes   | -     | -    |
+-----------------------------+-------+-------+------+
| ...etc                      |       |       |      |
+-----------------------------+-------+-------+------+

Made with Ascii Table Generator

5. Benchmark tools

When it comes for tools for benchmarking your web app, the 2 below are a good choice:
Apache Benchmark – be aware that it currently does not follow redirects
Siege – I particularly like the -i option:

This option is used with a configuration file, that is a file containing many URLs. With this option in place, each user randomly hits any one of the URLs in the file each time it hits the server. Much like you can’t tell the users of your website which pages they can view, you have no control over which pages siege will hit in internet mode. With this option set, there is no guarantee that every page in the file will be hit.

Update 8 December 2014:

6. Enable Whitespace Management

It looks like this option is available in CF Admin only on certain J2EE app servers (JRun is one of them, obviously). If you’re stuck with another J2EE server you can implement a custom JAVA-based filter. Resources:
http://www.simonwhatley.co.uk/eliminating-whitespace-in-coldfusion

If you have access to the server and want to implement it on every page request search for and install trimflt.jar. It’s a Java servlet filter that will remove all whitespace and line breaks before sending it off. Drop the jar in the /WEB-INF/lib dir of CF and edit the web.xml file to add the filter. Its configurable as well to remove comments, exclude files or extensions, and preserve specific strings.
http://stackoverflow.com/questions/2241910/white-space-coldfusion

7. CF8 performance gains

http://www.richinternet.de/attachments/062_CF-Performance-Tuning-Multi-Instance-Management-and-Clustering.pdf

Leave a response