Site Contents
Home
My Blog
ColdFusion
JRun
Flex
Wireless & Networking
Hardware & Gadgets
HDTV
Software Picks
Pictures
Contact Me
Search


My Articles & Papers
Flex Performance
Server/Client
mm.com Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate

username:
password:
 

 
Macromedia ColdFusion MX

 

ColdFusion MX

Other Helpful Information:

ColdFusion Hot Fix Listing
Debugging Dumps with CFMX
Diagnosing Hangs with CFMX
FAQ for Connector Config
Support for Windows 20003
Known ColdFusion MX Issues
Determing you CFMX version/build
Tips for Performance and Scalability
Seans ColdFusion Resources
CFCDev List Archives

CFECLPSE Introductory Videos 

Load Testing Tools
Linux Brain Dump
Getting Started with Oracle
Windows symlink tool
Links I need to categorize
Tips & Tricks Page
CFMX Hosting
CFMX Sample Apps
CF_Accelerate (In-memory caching tag)
Image Resizing in ColdFusion MX
WYSIWYG In Browser Editors

Viewing by Category: ColdFusionMX / Main
April 2, 2008

If you had a chance to read my getting started with Ec2 article I highlighted some of the challenges with deploying applications on the cloud. One of these challenges can now be easily overcome based on a new feature recently provided on Ec2

Elastic IP Addresses:
Elastic IP Addresses are static IP addresses designed for dynamic cloud computing, and now make it easy to host web sites, web services and other online applications in Amazon EC2. Elastic IP addresses are associated with your AWS account, not with your instances, and can be programmatically mapped to any of your instances. This allows you to easily recover from instance and other failures while presenting your users with a static IP address.

Availability Zones:
Availability Zones give you the ability to easily and inexpensively operate a highly available internet application. Each Amazon EC2 Availability Zone is a distinct location that is engineered to be insulated from failures in other Availability Zones. Previously, only very large companies had the scale to be able to distribute an application across multiple locations, but now it is as easy as changing a parameter in an API call. You can choose to run your application across multiple Availability Zones to be prepared for unexpected events such as power failures or network connectivity issues, or you can place instances in the same Availability Zone to take advantage of free data transfer and the lowest latency communication.

Every new addition makes Ec2 more attractive. In the coming months I will be experimenting more with deploying a large scale application to the cloud and will post some of my findings.

March 15, 2008

I was recently introduced to Amazon's new Ec2 services. The idea of cloud computing really intrigued me after I heard about it so I decided to take the dive. There is a bit of a learning curve with getting started but once you get started you realize the unlimited potential that cloud computing offers. Ec2 offers the ability to deploy pre-configured (linux based) images (called AMI's). The AMI's can be created from scratch or based on prebuit versions that Amazon or other users have exposed. You can quickly deploy to several different types of machines depending on your requirements. The base system has a 1.7Ghz Xeon CPU, 1.75GB of RAM, 160GB of local disk, and 250Mb/s of network bandwidth. Currently this will cost you $.10 per computing hour plus bandwidth costs. You are only charged for the time that the virtual machine is running and you can start and stop multiple instances at your will to scale as you need to. There are also beefier 64-bit machines available at a higher cost. On limitation (depending on how you look at it) is that persistent storage is not offered on the instances. After you start it up if at any time it crashes you lose everything on the instance. There are ways to overcome this as I will explain later but it makes things a bit more challenging. I found that the simplest way to get started is to find a public AMI that meets you needs, make the modifications to the instance then save it as your own instance into Amazon S3. S3 is another service that Amazon offers for storage, S3 and Ec2 work hand-in-hand with one another.

To get started you will need an account with Amazon Web Services at http://aws.amazon.com. You will need to sign up with both Ec2 and S3. It does not cost anything up front but you will need a credit card for them to draw funds from once you start using the service. One thing that took me a little while to get use to was the extensive use of certificates for authentication. Beyond signing in to your AWS account nearly everything else with the Ec2 service uses certificates or private keys. You use them to start your instances, as well as gain remote root access to an instance that you have started. It really makes things more secure. So lets get started....btw I recently switched from PC to Mac so all of the instructions will be for the Mac but they translate easily to the PC if you are familiar with java.

  1. Log into your AWS account, I am assuming you signed up with Ec2 and S3 already.
  2. After you are signed click on the "You Web Services Account" button and you will find the "AWS Access Identifiers" link.
  3. Select X.509 certificates link.
  4. When you click on the "create new" link you will be asked to confirm, click yes and the two files will be generated. You will find the two following files. These are the certificates I mentioned above that are used to authenticate you when any commands are issued to Ec2. There will be an additional cert that we create later to launch your instances.
    1. X.509 certificate named cert-xxxxxxx.pem
    2. RSA private key named pk-xxxxxxx.pem
  5. Next you will need to download the Amazon Ec2 command line tools.
  6. Now it is time to setup your machine to use the Ec2 tools.
  7. Open the terminal and go to your Mac home directory and create a new folder named ~/.ec2
  8. Copy the cert-xxxxxxx.pem and pk-xxxxxxx.pem into your ~/.ec2 directory from above.
  9. Unzip the tools into the ~./ec2 directory and move out the bin and lib directories to this directory as well. It should look like the following
    1. cert-xxxxxxx.pem file
    2. pk-xxxxxxx.pem file
    3. The bin directory
    4. The lib directory
  10. Next you will need to set a few environmental variables. To make things easier you can place these changes in your ~/.bash_profile file. If this file does not exist in your home directory you can create it then add the following:
    # Amazon Ec2 tools
    export EC2_HOME=~/.ec2
    export PATH=$PATH:$EC2_HOME/bin
    export EC2_PRIVATE_KEY=`ls $EC2_HOME/pk-*.pem`
    export EC2_CERT=`ls $EC2_HOME/cert-*.pem`
    export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home/
  11. After making the changes you will need to reload your ~/.bash by running the command
    source ~/.bash_profile
  12. Now you are ready to start issuing commands to Ec2, list instances and start them. The first step is finding the instance that is appropriate for your needs. You can test with the amazon images that are available and customize them to your needs. To list all of the Amazon instances type the following command.
    $ ec2-describe-images -o amazon
    IMAGE ami-20b65349 ec2-public-images/fedora-core4-base.manifest.xml amazon available public
    IMAGE ami-22b6534b ec2-public-images/fedora-core4-mysql.manifest.xml amazon available public
    IMAGE ami-23b6534a ec2-public-images/fedora-core4-apache.manifest.xml amazon available public
    IMAGE ami-25b6534c ec2-public-images/fedora-core4-apache-mysql.manifest.xmlamazon available public
    IMAGE ami-26b6534f ec2-public-images/developer-image.manifest.xml amazon available public
    IMAGE ami-2bb65342 ec2-public-images/getting-started.manifest.xml amazon available public
    IMAGE ami-36ff1a5f ec2-public-images/fedora-core6-base-x86_64.manifest.xmlamazon available public
    IMAGE ami-bd9d78d4 ec2-public-images/demo-paid-AMI.manifest.xml amazon available public A79EC0DB
  13. Out of this bunch you should find at least one suitable to test with, we will use the Fedora Core 4 machine with Apache from above. Before doing this we need a keypair to start the instance. This keypair will be used to gain root access to the instance through SSH after it is up and running.
  14. To generate the keypair use the following command, this will create a RSA private key and output it to the screen. You will copy this entire key from ------BEGIN RSA PRIVATE KEY------ TO ------END PRIVATE RSA KEY------. Paste this into a new file named ec2-keypair in your ~/.ec2 directory.
    $ ec2-add-keypair ec2-keypair
  15. This step is something that I missed at first and it frustrated me until I figured out what I was doing wrong. Before you can use this key to SSH to a running instance the Ec2 tools require that you set permissions on the file so that only your account has access to the file. You can do that with the command.
    $ chmod 600 ec2-keypair
  16. Now we can boot up an ec2 instance. We have chosen the ami-23b6534a instance from above. You will use the following command to start the instance.
    $ ec2-run-instances ami-23b6534a -k ec2-keypair
  17. It will take a little while for your instance to start but while you are waiting you can check on the status of the instance with the following command:
    $ ec2-describe-instances
    Once it is up and running you will see "running" as the status. Take note of the server addresses that this command provides since the provide the DNS addresses you will need to access your instance with a web browser or via SSH. They will be in the format of:
    ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com - (Externally accessible DNS address)
    domU-xx-xxx-xxx-xxx.compute-1.internal - (Internally accessible DNS address used from instance to instance)
  18. The server instances are locked down pretty tight and you will not have external network access to any of the instances by default. You have control over opening the ports though similar to controlling your own firewall. The network access is not configured uniquely to each instance but instead you control it by groups. You can launch several instances in the same group and provide network access to that group. When you start an instance like we did above it is started as part of the "default" group. We now need to open up network access for web traffic on port 80 and SSH on port 22 with the following commands:
    ec2-authorize default -p 22
    ec2-authorize default -p 80
  19. You can now access your instance by opening up your web browser and entering your address http://ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com
  20. Now you are ready to access the command line of the instance. This is where the private key that you created early comes in. You do not have a root password, instead you use the private key to authenticate yourself. You can access via SSH with the command:
    ssh -i ec2-keypair root@ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com

Now you are up and running with your instance. You can change whatever you want and add software to the Linux image. Just remember that it does not persist if you shutdown. If you do a reboot it will persist. After you have made all of the changes you want you can repackage the instance as your own and store it into the Amazon S3 service (LINK TO THESE STEPS)

Challenges of working with Ec2

  1. You get a dynamic IP address each time you boot an image. There are solutions with DynDNS that are worth exploring.
  2. There is no persistent storage if an instance fails. There are ways to overcome this limitation. So far I have worked with PeristantFS which allows you to mount a bucket from S3 as a directory in your image.
  3. You are limited by space in the image to 10GB (I think I need to confirm) if are going to store large files I suggest putting them somewhere in the /mnt directory since that has a lot more space. Also if you save the image anything in the /mnt folder is not saved as part of the image. You can put log files and other content that you don't want saved in this location
  4. Databases are a challenge with limited options for persistence. Third parties are popping up offering db hosting on the cloud so you don't have to manage it yourself. I will explore these more in the future.

The future of scalable computing....

I really feel like cloud based solutions are the future for hosted solutions. Once you work out some of the limitations you can build a very scalable solution where you have automated scripts that launch new instances as you have a need to scale. In turn you can shut them down as the load decreases. There are overall architecture needs that have to be addressed to utilize an infrastructure like this but it is all doable with a bit of ingenuity. Add in the fact that a small business does not have to invest an significant amount into hardware and software to start running on this type of solution and it is a no brainer. The questions of SLA's come up and I expect that to be an issue for the short term but solvable in the future.

Getting started is easier with RightScale.com

I also used RightScale when I first got started with Ec2, they are a third party that puts a front end onto the managing of ec2 instance. It makes it a lot easier to get started and get your head around Ec2. All you need is an AWS account with Ec2 and S3 and you can get started with RightScale. You do not have to deal with all of the command line stuff above and the Ec2 tools.

 

December 8, 2007

In my last blog posting I discussed the advantages of using MaxMind GeoIP to obtain a site visitors geographical location based on their IP. In this posting I will show you how to integrate GeoIP into your site using ColdFusion. If you are a ColdFusion developer the most challenging part is getting the java source compiled and into a jar file so that you can leverage the GeoIP Java API in ColdFusion. I have made it easier by taking care of this process

The first thing you will need to do is download the example and jar file. Since this example was written using the Lite version of GeoIP you will need to download the Binary version of the Lite database. After you get it up and running you can download and just replace the .dat file with the full binary version. Go to http://www.maxmind.com/app/geolitecity and look under the section that says "Binary Format", click on the "Download the latest GeoLite City Binary Format" link. After that go ahead and extract the .dat file from the zip.

The zip file that you downloaded above will contain a jar file and two ColdFusion files. Follow along with the steps below and you will be up and running quickly.

Steps:

  1. Copy geoIP.jar to Jrun4/servers/lib or ColdFusion/runtime/servers/lib (I think that is right for standalone CF it has been a while since I used the standalone version)
  2. Restart ColdFusion or the JRun instance
  3. Create a directory for testing in your webroot and copy index.cfm and application.cfc from the zip file above
  4. Open Application.cfc and modify the entry for REQUEST.GeoIPCityDB to point to the location where you extracted the GeoLiteCity.dat file from above. Make sure you use forward slashes and not backslashes.
    REQUEST.GeoIPCityDB="C:/geoIP/GeoLiteCity.dat";
  5. You should then be able to invoke index.cfm from the example and start resolving IP's to Geographic locations.

I have included an example usage on my site using both the free version and the paid version so you can get a sense of the differences between the two.

You should be able to take this example code and quickly integrate it into your own site. Overall it is pretty simple, if you are not using an Application.cfc file you will just need to add it to your Application.cfm file. Make sure you add logic so that it only is initialized once. The initial load is a bit expensive but it loads the entire database into memory. It is only about 25MB but it is worth the performance gain you get since you can support hundred-thousands of queries a second. The UDF in the index.cfm file is a little bit bloated but there is some reasoning behind it. When I started using this approach I had already been using IP2Location and had a predefined query structure that I had to adapt to. You can probably simplify the approach for the UDF if you choose to. If there are any other questions feel free to post them or email me.

November 14, 2007

Early this year I wrote a blog article about using IP2Location to identify a users location and ISP based upon their IP. You can find the previous articles here:

http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=1078
http://www.bpurcell.org/viewcontent.cfm?contentID=147

The flaw with this approach is that the data was stored into a database of 4 million rows and it was very expensive to do the lookups even with the performance optimizations of splitting the data up across multiple tables. Recent research has turned up a more optimal approach using GeoIP with a binary based solution that will support several hundred requests per second. Yes that is right, several hundred requests per second. The initial setup and configuration takes a bit of time to get going but it is very simple to update and maintain.

GeoIP is a technology from MaxMind that provides developers with a non-invasive way to determine geographical and other information about their Internet visitors in real-time. When a person visits your website, GeoIP can determine which country, region, city, postal code, area code the visitor is coming from. Furthermore, GeoIP can provide information such as longitude/latitude, connection speed, ISP, company name, domain name, and whether the IP address is an anonymous proxy or satellite provider. In my findings and experimentation I have found that GeoIP is also more accurate than IP2Location.

GeoIP features multiple binary files with different features available based on the price that you pay. A listing of the different versions can be found here. For my practical purposes I used both the City and ISP versions. Another great thing that MaxMind offers is a GeoLite City version that is free that you can use to test integration with your system. All of the API's are exactly the same but it is less accurate than the version you purchase.

The final selling point for me with GeoIP is the different API's that they support. You can integrate it with almost any system using (Java, C, Perl, PHP, VB.net, MS Com....and many others). Since I was using ColdFusion I chose to go the Java route. If you are not experienced with Java you may stumble a bit here but I plan on posting the Jar that I built for integration along with sample code to make it very easy to first try the Lite version then use the full version if it works well for you. You can find the Java source here along with the GeoLite version.

If you are experienced with Java and ColdFusion it is pretty straightforward to get up and running. You will just need to compile the java source and build a jar, then place it in the classpath of ColdFusion. It is as easy as instantiating the Java object from CF then making calls to retrieve the information. I recommend encapsulating this into a function and loading the reference to the Java object in an application scope variable that is loaded when the application starts. I did have to work around a few issues in the Java source to get it working properly with CF but there were not too many changes needed.

I have posted a very easy to follow step by step set of instructions on this posting http://www.bpurcell.org/blog/index.cfm?mode=entry&entry=1100 so that you can use to get GeoIP up and running on your site.

November 12, 2007

I ran into a confusing issue with ColdFusion 8 that could affect users that install the enterprise version with the evaluation option and are using multiple instances.

Here is what led up to this issue occuring for me

  1. Installed ColdFusion 8 as a multi server install with the evaluation option
  2. Created an additional instance of ColdFusion
  3. Entered in a valid serial number into the new instance that I had just created.
  4. After the evaluation period expired the server responded with a blank page for requests although some of the requests completed successfully.
  5. Looking in the error log for the new server I found the following error.

11/12 17:49:21 error IP license restriction is in effect.  Can only accept connection from either localhost or five IP addresses, attempted from 192.168.2.9.  Previous accesses were from [ {192.150.x.x}  {192.168.x.x}  {192.168.x.x}  {192.168.x.x}  {192.168.x.x} ].

Of course I had seen this error many times before but in the CF admin (of the new instance I had created) I saw that CF was running with an enterprise license so it should not have the IP restriction. It occured to me that the main CFusion administrative server did not have the license key. After entering the license key in the CFusion admin and restarting both instances everything cleared up. This will probably rarely happen but it could be really confusing if it occurs so I hope this helps someone.

July 23, 2007

A new version of the MySQL driver has been released that detects ColdFusion when it is running with Coldfusion MX 7 (and 8). This should result in much better performance for CF/MySQL users.

Setting "useDynamicCharsetInfo" to "false" now causes driver to use static lookups for collations as well (makes ResultSetMetadata.isCaseSensitive() much more efficient, which leads to performance increase for ColdFusion, which calls this method for every column on every table it sees, it appears).

The driver automatially detects when it is running in a ColdFusion MX server (tested with version 7), and uses the configuration bundle coldFusion, which sets "useDynamicCharsetInfo" to "false" (see previous entry), and sets useLocalSessionState and autoReconnect to true.

The update for this driver should should help with performance. I have personally not tested this driver but wanted to pass this information along.

March 23, 2007

This was something that I meant to write about a while ago but never got around to it. I recieved a question recently by email and wanted to provide some tips and tricks when using ISAPI Rewrite in a multi-tiered load balanced environment. I wrote an article with Frank DeRienzo several years ago about using a multi-tiered load balanced enviroment. I followed this up later with a blog entry on my site for Using ISAPI Rewrite with ColdFusion.

If you are using ISAPI Rewrite to proxy requests from your webserver (IIS) to you ColdFusion server or through a load balancer you will run into issues when accessing various CGI variables. When proxying the ColdFusion server sees the web server as the end client and therefore variables like CGI.HTTP_HOST are set to the IP or hostname of the webserver. To get around this I inject custom headers with ISAPI rewrite, parse them in CF and then stored them in the request scope.

First I start by adding the headers to the main httpd.ini Start->All Programs->Helicon->ISAPI_Rewrite->httpd.ini (you may need to change the read only flag in order to save the file)

#Due to the proxy we add these headers to use in cf through
#GetHttpRequestData().headers.HEADERNAME
RewriteCond %REMOTE_ADDR (.*)
RewriteHeader CLIENT_REMOTE_ADDR: ^$ $1

RewriteCond %SCRIPT_NAME (.*)
RewriteHeader CLIENT_SCRIPT_NAME: ^$ $1

RewriteCond %SERVER_NAME (.*)
RewriteHeader CLIENT_SERVER_NAME: ^$ $1

RewriteCond %SERVER_PORT (.*)
RewriteHeader CLIENT_SERVER_PORT: ^$ $1

RewriteCond %HTTP_HOST (.*)
RewriteHeader CLIENT_HTTP_HOST: ^$ $1

RewriteCond %SERVER_PROTOCOL (.*)
RewriteHeader CLIENT_SERVER_PROTOCOL: ^$ $1

#stores the original URL before any rewriting in a custom header
RewriteCond URL (.*)
RewriteHeader x_rewrite_url_original: ^$ $1

RewriteCond X-Rewrite-Proxy (.*)
RewriteHeader x_rewrite_proxy: ^$ $1

I then create a page in CF called httpheaders.cfm and include it early on in my CF code within Appplication.cfm or within onRequest of Application.cfc

<cfsilent>
<!--- this page is added to handle the custom headers we write with 
ISAPI Rewrite due to the issues we see with proxying requests.
 --->
<cfset httpheaders=GetHttpRequestData().headers>
<cfset REQUEST.proxyheaders=structNew()>
<cfif isdefined("httpheaders.CLIENT_REMOTE_ADDR")>
    <cfset REQUEST.proxyheaders.REMOTE_ADDR=httpheaders.CLIENT_REMOTE_ADDR>
<cfelse>
    <cfset REQUEST.proxyheaders.REMOTE_ADDR=CGI.REMOTE_ADDR>
</cfif>
<!--- I need to find a way to handle SCRIPT_NAME better, with ISAPI 
Rewrite and JRun ones are different --->
<cfif isdefined("httpheaders.CLIENT_SCRIPT_NAME")>
    <!--- <cfset 
REQUEST.proxyheaders.SCRIPT_NAME=httpheaders.CLIENT_SCRIPT_NAME> --->
    <cfset REQUEST.proxyheaders.SCRIPT_NAME=CGI.SCRIPT_NAME>
<cfelse>
    <cfset REQUEST.proxyheaders.SCRIPT_NAME=CGI.SCRIPT_NAME>
</cfif>
<cfif isdefined("httpheaders.CLIENT_SERVER_NAME")>
    <cfset REQUEST.proxyheaders.SERVER_NAME=httpheaders.CLIENT_SERVER_NAME>
<cfelse>
    <cfset REQUEST.proxyheaders.SERVER_NAME=CGI.SERVER_NAME>
</cfif>
<cfif isdefined("httpheaders.CLIENT_SERVER_PORT")>
    <cfset REQUEST.proxyheaders.SERVER_PORT=httpheaders.CLIENT_SERVER_PORT>
<cfelse>
    <cfset REQUEST.proxyheaders.SERVER_PORT=CGI.SERVER_PORT>
</cfif>
<cfif isdefined("httpheaders.CLIENT_SERVER_PROTOCOL")>
    <cfset 
REQUEST.proxyheaders.SERVER_PROTOCOL=httpheaders.CLIENT_SERVER_PROTOCOL>
<cfelse>
    <cfset REQUEST.proxyheaders.SERVER_PROTOCOL=CGI.SERVER_PROTOCOL>
</cfif>
<cfif isdefined("httpheaders.CLIENT_HTTP_HOST")>
    <cfset REQUEST.proxyheaders.HTTP_HOST=httpheaders.CLIENT_HTTP_HOST>
<cfelse>
    <cfset REQUEST.proxyheaders.HTTP_HOST=CGI.HTTP_HOST>
</cfif>
</cfsilent>

After including this code you can access the client's IP with "REQUEST.proxyheaders.REMOTE_ADDR".

One other challenge is detecting if a user is using HTTPS if you have front ended your site with a load balancer and use the SSL accelerator of BIG-IP or Cisco CSS. To the app it looks exactlyt he same. I will save that discussion for another blog posting. Let me know if you have any questions.

There should be a similar solution with mod_proxy in apache by adding headers I just have not researched it. If you have the information post your findings and I will add it to the blog.

September 26, 2006

Most developers do not spend a lot of time reviewing logs so a lot of errors occur without ever knowing about them. If every error ends up in your inbox then you are forced to address them. I use a template similar to the one below for every site I have developed.

<!--- Send an email with information about the error --->
<CFMAIL TO="youremail@host.com" FROM="error@site.com" 
 SUBJECT="Error on http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME#" TYPE="HTML">
A user experienced an error on #ERROR.template#. 
<P>The error information is as follows:<BR>
Diagnostics: #ERROR.Diagnostics#<BR>
Template: #ERROR.template#<BR>
Query String: #ERROR.QueryString#<BR>
Path Info: #CGI.PATH_INFO#<BR>
Referer: #CGI.HTTP_REFERER#<BR>
IP: #CGI.REMOTE_ADDR#<BR>
Date/time: #ERROR.DateTime#<BR>
Browser: #ERROR.Browser#<BR>
URL: <a href="http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME##CGI.PATH_INFO#">
http://#CGI.HTTP_HOST##CGI.SCRIPT_NAME##CGI.PATH_INFO#</a><BR>
Request Method: #cgi.REQUEST_METHOD#
<ul>
<li><b>Users Location:</b> #error.remoteAddress#
  <li><b>Users Browser:</b> #error.browser#
  <li><b>Page Refered:</b> #error.HTTPReferer#
</ul>
#error.diagnostics#
<br>
<cfif cgi.REQUEST_METHOD IS "POST">
Form Scope:
<cfdump var="#form#" label="form"><br>
</cfif>
URL Scope:
<cfdump var="#URL#" label="URL"><br>
Session Scope:
<cfdump var="#session#" label="session"><br>
CGI Scope:
<cfdump var="#CGI#" label="CGI"><br>
Request:
<cfdump var="#Request#" label="Request"><br>
CFERROR:
<cfdump var="#cferror#" label="CFERROR Variables."><br>
</CFMAIL>
<!--- end of error email --->
Place static content in here that you want users to see when there is an error. 
I usually put a saved HTML version of the main website with a notice that an error has occured...etc
<CFABORT>

May 1, 2006

Although it has been quite a while since JRun 4.0 was released the next release is right around the corner. The JRun team has asked me to post the following message to find developers that are interested in test driving the next release of JRun.


The beta release of next version of JRun appserver,  code named Cheetah, is available. Adobe JRun Team is inviting serious evaluators to give feedback on this beta release. Contact vrreddy@adobe.com to be included in the Beta program.

We believe Beta of JRun Cheetah is reasonably stable and reliable. And we plan to reward those who prove otherwise. We intend to give away fully functional JRun licenses to the users who report highest quality issues during the Beta.

What More ! We are throwing open a JRun Sample Apps Challenge. We invite the beta users to develop sample applications exploiting the new JRun Cheetah feature sets. The best apps developed by you will be rewarded, and on qualification, will be featured as part JRun releases in samples section.

Write Code, find Bugs ! Help us serve you better.


Regards,
Vijayan Reddy,
Adobe JRun Team.


March 24, 2006

Steven Erat pointed this link out to me regarding ColdFusion MX and JVM Tuning Links.
http://www.pixl8.co.uk/index.cfm/pcms/site.resources.cfmxtuning/

Here are a few others:
http://devnulled.com/content/2005/09/coldfusion-mx-tuning-and-clustering-roundup/

Free stack trace utility
http://www.seefusion.com/seestack/seestack.cfm

February 20, 2006

In a previous blog posting I discussed how to obtain a users geographical location based on their IP with IP2Location and ColdFusion. In this article I explain how to import the data, break the data into multiple tables for optimization, then create the UDF to perform the lookup. I have had several requests for the stored procedures used to break up the IP2Location data. I have posted them along with the CF code.

You can find the full article here

February 7, 2006

I recently was encountered with a problem where I needed to find what location a user was logging in from based on their IP. There were several reasons why such a system was needed that I highlight below.

Benefits of building such a system

  1. Targeting fraudulent users that share their accounts
  2. Reducing credit card fraud
  3. Display native language and currency
  4. Redirect web pages based on geographical region
  5. Filter access from countries you do not do business with
  6. Geographical targeting for in house ad serving

I first started looking for third party solutions that could be accessed through a webservice but quickly arrived at IP2Location.com. IP2Location offers a downloadable CSV database that you can run on your own system. The cost is not significant depending on the amount of data you need. They offer IP-Country-Region-City-Latitude-Longitude-ZIPCode-ISP-Domain Database if you need that level of information. Anyways&on to the technical part.

The CSV format that is provided is simple to import into any database, I was using MS SQL server and imported the data using DTS. There are over 4 million rows in the table so it does not make sense to query directly against the data that was imported for performance reasons. Instead to make the queries very quick that return location data I split the main table out into 20 tables, this left 200,000 rows in each table and proved to scale much better. Since IP2Location offers regular updates I wanted to be able to handle the update process and splitting of the data with very little work on my part. To do that I created two stored procedures.

1. IP2RangeTable The first stored procedure looks at the main table containing 4 million records and divides it into 20 different ranges. Those ranges are then stored in a range table containing the start, end and table name that will store the data.
2. The second stored procedure uses the IP2RangeTable created previously and bulk inserts the range of data from the main table into the range tables. They were simply called range1 - range20.

Both of the stored procedures were written in such a way that the data could be broken out into X number of tables. It just takes the number of tables as a parameter. In this case I used 20. The further you break it out the better it will perform.

Next, I created a UDF in ColdFusion (could be done in a stored proc as well) that takes an IP as an argument. The IP is converted to an IP Number. IP Numbers are used in the database to store the IP2Location content. An example for conversion follows.

IP Number = 16777216*w + 65536*x + 256*y + z (1)
where
IP Address = w.x.y.z

For example, if IP address is "202.186.13.4", then its IP Number "3401190660" is based on the formula (1).

IP Address = 202.186.13.4

So, w = 202, x = 186, y = 13 and z = 4

IP Number = 16777216*202 + 65536*186 + 256*13 + 4
= 3388997632 + 12189696 + 3328 + 4
= 3401190660 looks at the IP2Range

Once we have the IP number we need to find what table the record is stored in within the range1-rangeX tables. A query retrieves the values stored in IPRangeTable, from that data we can find the correct range table. Next a query is used against the range table to retrieve the location data.

This may sound complicated but it is really simple. Unlimately you could just query the original table that you imported from the CSV but I found the queries to take way to long and caused a lot of stress on the db server under load. Even with the right indexes in place. By breaking the data out into range tables you increase the scalablity exponentially.

Let me know if you have any other questions about this process and the benefits that the data provides.

Later I will explain how the event gateway was used to log this information for every user that logged into the site as a background process.

You can find the technical information in this article

November 25, 2005
I have ran into this several times before but I always forget the exact code so I figure I would blog it so I had a reference to it.  There are several ways to prevent pages from being cached, I have found that a combination of approaches works best.   This will make sure that it will work across all browsers

Set a meta tag for content expiration

<meta http-equiv="expires" content="Mon, 06 Jan 1990 00:00:01 GMT"> 

You can also use CFHEADER to send a header to the browser forcing it not to cache the data

<cfheader name="expires" value="#now()#"> 
<cfheader name="pragma" value="no-cache">
<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">

see also: http://www.web-caching.com/mnot_tutorial/how.html

November 3, 2005

ISAPI Rewrite is an IIS ISAPI filter that I have recommended in the past in place of the JRun connector to cluster with a hardware load balancer in between the application server and web server. I outlined the usage in the following article. ISAPI Rewrite can also be used in conjunction with the JRun connector for several different useful features.

In order to use ISAPI Rewrite in conjunction with the connector it will need to be loaded as an ISAPI filter with a higher priority than the JRun connector. The ISAPI Rewrite filter examines requests before the JRun connector processes them so we can perform pre processing (rewriting, proxying, or blocking requests) among other things. I will provide a quick overview of the structure of the configuration files for ISAPI rewrite as well. After you install ISAPI Rewrite it installs the ISAPI Rewrite filter into IIS at the master level so that it affects all sites on that server. All configurations that you want to affect all sites will go into c:\Program Files\Helicon\ISAPI Rewrite\httpd.ini. ISAPI Rewrite also allows you to configure individual settings for each virtual site on the server. By placing a httpd.ini file in the webroot of a site the filter will process it as well, the master file will be processed first then the configuration in the virtual site.

Back to the many uses of ISAPI Rewrite, at least ones that I have discovered you may have more to contribute. If you have questions on the regular expressions I am using take a look at the ISAPI Rewrite documentation.

Blocking URL's

I have used this approach to secure web based administration tools including the ColdFusion administrator. If you wanted to prevent external access to the ColdFusion Administrator and allow access behind your firewall on a private IP you could do the following. Enable the JRun Webserver (default instance runs on port 8500) and access the administrator through http://internalIP:8500/CFIDE/administrator/index.cfm. With IIS configured to the JRun server you would still have external access to the administrator. This is where ISAPI Rewrite comes in. Within the httpd.ini file we can add the following rule that blocks external access to /CFIDE/administrator/

#Block ColdFusion Administrator
RewriteRule /CFIDE/administrator.* [F,I,O]

We could also block RDS using this same approach

#Block ColdFusion RDS
RewriteRule /CFIDE/main/ide.cfm.* [F,I,O]

You can use this approach to block any URL all that is needed is a simple regular expression.

Rewriting SES (Search Engine Safe) URL's

The following rule will convert search engine safe (SES) URL to a standard URL so you don't have to handle them in your ColdFusion code.

#Convert SES URLs to standard URLs before passing them to ColdFusion
RewriteRule (.*?\.cfm)(\?[^/]*)?/([^/]*)/([^/]*)(.+?)? $1(?2$2&:\?)$3=$4?5$5: [N,I]
RewriteRule (.*?\.cfc)(\?[^/]*)?/([^/]*)/([^/]*)(.+?)? $1(?2$2&:\?)$3=$4?5$5: [N,I]

For example the following URL gets converted

http://host/page.cfm/var1/value1/var2/value2 -> http://host/page.cfm?var1=value1&var2=value2

Rewriting URL's for SEO optimization

I am not going to go into depth on search engine optimization (SEO) as I could spend a year just writing about it. One of the common things I have found is that a URL with keywords early after the hostname is rated better than including them in the query string at the end. You can create URL's that are easier to read as well and make it look like the pages the user is surfing is static content although it is generated on the fly. The following is not a real world example but I will say that I have used this approach with much success for data drill down applications to get search engines to rate the content highly. I don't want to give away any secrets though :-)

Let say we wanted a search engine to crawl our site for specific keyword that would be common search terms. If this were a dynamic ColdFusion page the URL's would look something like this.

http://host/search.cfm?keyword=keyword1
http://host/search.cfm?keyword=keyword1

With the following rule in httpd.ini we could rewrite the above URL

RewriteRule /search/(.*)\.htm /search.cfm\?keyword=$1 [I,O]

The following URL's
http://host/search/keyword1.htm -> http://host/search.cfm?keyword=keyword1
http://host/search/keyword2.htm -> http://host/search.cfm?keyword=keyword2
gets rewritten to the URL's that we examined in the beginning, to ColdFusion it doesn't know the difference. We could provide a page with links to all of the common keywords and let the search engine walk through and index them. It may not seem apparent right away how this is such a cool thing but with a little imagination you can use this approach for a lot of things

Rewriting URL's to hide the file extension

This is similar to the example above except we are just hiding the actual file extension. For example we could rewrite .html requests to .cfm requests.

RewriteRule (.*)/(.*)\.html(.*) /$2.cfm [I]

Proxying Requests to Other Hosts

Lets say you had a single web server and host and multiple backend systems that you wanted to integrate through the same hostname. One system running ColdFusion, another system that is servlet based running on Tomcat. Of course you could integrate them but lets assume that is not an option. With J2EE applications you normally have a context root or prefix to every request. Lets assume that we have a context root of /myapp so all requests look like the following http://host/myapp/page.jsp. Lets also assume that this application is running on a different server other than the one ColdFusion or JRun is running on (192.168.1.50 on port 8080). The following rule would proxy requests from IIS to the server running our other application.

RewriteProxy (/.*myapp.*) http\://192.168.1.50\:8080$1 [I]

Proxying requests to remove the JRun connector

This is the approach I used in my article for JRun clustering with a hardware load balancer in between the webserver and application server. Since the standard protocol for the JRun connector is JRPP it does not work well through a hardware based load balancer. If you are using a context root in your ColdFusion application of / you will need to proxy by extension and can use the following rules. This will handle nearly every extension that CF needs and passes them to the JWS

#Rewrites to proxy requests back to the appserver level (CF)
RewriteProxy (/.*\.cfm.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*\.cfc.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*\.jsp.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*\.jws.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*\.jst.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/flashservices.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*servlet.*) http\://192.168.1.1\:8501$1 [I]
RewriteProxy (/.*CFIDE/GraphData.*) http\://192.168.1.1\:8501$1 [I]

One issue I ran into with this configuration is that a request for http://host will not use the default document in IIS of index.cfm so you can use the following rule to map http://host to http://host/index.cfm

#Fix final slash for /dir
RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [R]

#Append index.cfm to any dir
RewriteRule ((?!.+\.cfm).*/) $1index.cfm [I,O]

I would like to mention that I do not recommend removing the JRun connector unless you expect to handle supporting this configuration yourself. This approach is not directly supported by Macromedia but it does work as I have used it in the past. Don't expect Macromedia support to assist you with issues regarding this configuration.

It is worth mentioning that I am a big fan of Apache and you can do all of this with Apache and never have to buy a third party plug in. Apache has mod_rewrite and mod_proxy to accomplish the same tasks.

November 1, 2005

If you haven't taken a look at the Event Gateway feature in ColdFusion 7 the following will provide you a primer on getting started and a valid use case. Ben Forta outlines the process on his blog in a three part series.

Building an IM Bot Part I
Building an IM Bot Part II
Building an IM Bot Part III

For another view on Ben's configuration you can read Peter Reese's experience with setting up GoogleTalk via the ColdFusion XMPP gateway.

I recently used the Asynchronous CFML gateway to replicate data between two servers in a cluster. Look for more on this topic in the future.

August 3, 2005

One challenge I have always ran into with ColdFusion or JRun is that when the server hung on windows there was no easy way to take a thread dump. While jrun.exe is running as a service there is no direct way to send a signal to the JVM to signal a thread dump. Most of the time you have to start it from a console window and let it run there. When you do that though you run the risk of someone closing you user session and having the server die. It is much safer to run it as a service. This takes us back to the problem at hand.....if the server hangs how do I obtain a thread dump? Mike Collins recently pointed me in the direction of a utility that you could use to obtain a thread dump even while running as a service.

The tool is called StackTrace and it is a swing based utility the provides hooks into a java process running as a service. In order to run it you may need to download the latest 1.4 JDK and run the install, it should ask you during the install if you want to install the JRE to Internet Explorer. Check the box and proceed with the install and it will start when you invoke it from the website.

When you open the StackTrace utility you can browse the running java processes and it should look something like this.

If you have multiple servers running it may be difficult to identify which processID is mapped to a particular JRun server there is another utility that I use called Process Explorer from SysInternals. Once you download Process Explorer and open it, select Options > Highlight Services to see what you're running. Right-clicking on a service and selecting Properties gives you all the information you need on the resources it is using. The following screenshot provides an example of the JRun CFusion server. The process ID is 348 and we could choose this process in the StackTrace utility to obtain a thread dump.


One limitation that you need to be aware of is that you cannot use this utility from Terminal Services. This is not a limitation of the product it is a limitation of windows since the utility cannot attach to process running in a terminal window. You must instead use PC Anywhere or VNC to run the utility or run it directly at the console of the server.

I have not used this utility extensively so I do not know how stable it is nor do I directly endorse it. It was something cool that was pointed out to me so proceed at your own risk.

May 31, 2005

As most of you probably already know this year marks the 10th birthday of ColdFusion. I was reading Tim Buntel's blog and he pointed to a page on the Macromedia website where you could post how ColdFusion has changed your life and details on applications you built with CF 1,2,3 or 4. I wanted to take a moment and share my story

It was 1997 and I didn't know what a web app was. As an Army Officer I was tasked with building a system to exchange information for the Second Infantry Division in South Korea. I expored ASP and CGI and found them too cumbersome. I stumbled upon the Allaire site after looking across the net and found ColdFusion. I downloaded CF 3.0 and printed out the hundreds of pages of docs and read them on a long bus ride over the weekend. That next week I started developing a prototype and had something put together in a two weeks that we used in a battle exercise. Sparing the details the application replaced people from building powerpoint slides of information that was hours old. ColdFusion allowed us to build a web based system that was submitted from laptops across the battlefield on a tactical network providing up to the minute information on equipment, personnel and other tactical information. Developement continued over the next six months to build a fairly large although simple to use application

A few years later I implemented Tacweb at the Third Infantry Division in Fort Stewart Georgia and other units across the army started using it. I recieved emails early this year about it and it was used during the Iraqi war.

You can find more information about TACWEB here
http://www.bpurcell.org/tacwebfiles/tacweb.htm
http://www.bpurcell.org/tacwebfiles/papers/WebNet_98.cfm

If it wasn't for me stumbling across ColdFusion I would have never had the job I have today with Macromedia. I decided it was time to get out of the Army in 2000 and posted my resume on Monster.com and Allaire called me to support ColdFusion working remotely from my home.  Well the rest is history but I have loved my time so far with Allaire and Macromedia and consider myself very lucky to be able to work with the technology, products and people that I work with on a daily basis.

It is too bad I will miss the birthday party on the 13th of July. I will be on sabbatical starting in June, but it will be nice to enjoy the time off.

April 29, 2005

Over the last few months I have blogged very little due to time constraints, travel and vacation. I have been working on the Flex team for about a year and a half now and still continue to do ColdFusion development anytime a chance arises. I have seen a lot of questions recently about ColdFusion and Flex integration and my goal for blogging over the next few months is answering a lot of the common questions.

  1. Deployment options - seperate instances, single instance (deployed as a singe web app, deployed as a seperate web app)
  2. External Webserver configuration options (IIS & Apache)
  3. Data integration (HTTPService - XML, Webservices, RemoteObject (examples and gotchas)
  4. Authentication and Authorization

I am looking for other questions that I can answer as well and can put together code samples. I might even turn this into a dev center article if I can pull enough content together. Please post your comments or thoughts.

March 24, 2005

JRun 4 Updater 5 was released today. You can find a listing of the issues it addresses here. There are several fixes for the connector that you should check out, especially if you are using connector clustering.

December 10, 2004

I have heard requests from developers using ColdFusion and Flex that they would like more information about integrating the two. One of my coworkers Tom Link started a blog and his first few entries cover ColdFusiona and Flex integration. His first three posts cover the following topics

November 10, 2004
I have had a lot of requests for the CF_Acclerate admin code and I have just been too busy to finish it. Either way I will go ahead and release it as is. Also after talking to a lot of people at MAX I promise to start posting more info on CF and Flex in the  next couple of months :-)

This version of the CF_Accerlate admin was written early on during the development of CF_Accelerate and has not had any features added since. Feel free to modify anything and send me a note with feature additions I will integrate changes in that you feel are useful

Features:

Cache Viewer

  • Lists all cached trees and lets you drill down to individual entries
  • Prune a tree at any level or an individual cached entry
  • View the contents of an individual cached entry
  • View the cache date/time, expiration date/time and the content length of a cached entry
  • Add and remove URL's to the cache auto-refresh feature (stored in WDDX file)

Cache Skimmer (Cleans expired Cache)

  • Examines all cached entries and clears out expired cache to manage memory
  • Allows you to (one-click) create a scheduled task that invokes the Skimmer every X minutes
  • Add URL's in the admin to auto-refresh with CFHTTP when the skimmer runs, this keeps the cache fresh

Cache Statistics

  • View total number of Cache entries
  • View detailed number of cache entries for each tree

To install the admin

  1. Extract the zip to your webroot I used /cacheadmin
  2. Modify the Application.cfm file to include your existing Application.cfm file, the admin needs to run in the same scopewhere CF_Accelerate is running to pick up the changes.

The skimmer is a feature that everyone using CF_Accelerate should take advantage of. I have heard complaints of CF_Acclerate hogging memory over time. That is because it does not clean itself out when the cache expires. The skimmer will go through and evaluate all the cached  entries in the tree and clean the cached key using structDelete(). This will allow you to reclaim your memory. It is a pretty simple process  to put this in place

  1. Wherever you installed the admin you will see a subdirectory /cacheadmin/skimmer/ modify the /skimmer/Application.cfm CFINCLUDE so it points to you Application.cfm of the application where you are using CF_Accelerate
  2. You can either add the scheduled task manually pointing to /cacheadmin/skimmer/pruneExpiredCache.cfm or you can use the feature in the CF_Acclerate admin to automatically add it.  If you go to the main page in the admin you will see a link on the left "Skimmer Scheduler". This will bring up a page in the right frame to add the scheduled task that will run by default every 10 minutes. Verify the URL and click the Scheduled Task button.

Thats all that is needed to keep your cache free of stale entries and free up your memory.  I hope this helps you and let me know of anything you think of adding. My time is limited so feel free to provide the code and I will integrate it.

You can dowload the latest version here.

October 14, 2004

Google launched the Beta of its long anticipated Desktop Search tool for Windows today. The application acts as your own personal Google Server and indexes the contents your system by file name, or in the case of select file formats, by the contents of the file. It runs on Windows XP and Windows 2000 (with Service Pack 3).

The free download indexes the full text of email created in Outlook or Outlook Express, Word documents, Excel spreadsheets, PowerPoint presentations, AOL Instant Messages, and caches the pages you view in Internet Explorer so you can revisit the page later "even if its live content has changed or you're offline."

The install is really simple and after you install it starts indexing. If you are working on your system then it will take a while to index. As soon as it realizes the machine is idle it starts churning away. After it indexes the data you are presented with a browser based interface much like the google we all know. Yes is it lightening fast, typing in JRun on my machine turned up 24,107 entries for files and 27,823 for web history, all that in .5 seconds. It looks through basically anything on your machine and indexes it. For free you can't beat this. it is on my short list of the best windows utilities I have ever used.

You can download it here.

August 31, 2004

If you are using J2EE Clustering and session replication with Coldfusion MX 6.1 then Updater 1 offers two important hot fixes that gives you a reason to install it. The following issues are addressed in the Updater

  • 53765 - When Coldfusion MX 6.1 was deployed on clustered Macromedia JRun servers with session replication and J2EE sessions enabled, it would throw a Null pointer exception when the cflock tag was used to lock Session scope.

  • 53913 - In clustered J2EE configurations on JRun if you tried to store a structure in the Session scope and used session replication, the session became corrupted if the request failed over to another server.

The updater can be downloaded at thefollowing location. The issues fixed in the release can befound here

August 23, 2004

Sorry for the inactivity on the blog in the last month but Flex has kept me quite busy lately.

I know that many developers use CFMX on their desktop or laptop for development. Changes in XP SP2 lock down the network functionality of JRun and CFMX. The following technote will walk you through the process of getting CFMX and JRun working properly after installing XP SP2.

Enabling ColdFusion MX with Windows XP SP2

August 10, 2004

I recently updated my article on configuring Installing and Configuring ColdFusion MX 6.1 Multiple Instances with IIS and Apache Virtual Hosts.  There was a problem with the Apache configuration causing errors.  There was an issue highlighted on Steven Erat's blog pointing out that the JRunConfig Apialloc setting must be set in the Virtual Host for second instance, and must be set to false. If not, one in every 4 or 5 requests will return an Apache Internal Server Error to the client with a 500 status code and the Apache error log will record a message such as:

[Thu Jun 24 15:09:33 2004] [notice] jrApache[1635] JRun will not accept request. Check JRun web server configuration and JRun mappings on JRun server.

The article can be found on macromedia.com.  There was only one page updated that dealt with the apache configuration.

June 16, 2004

I have heard the question a lot "Should I enable the Save Class Files option in the ColdFusion MX 6.1 Administrator". Well the answer is, it depends!! If you enable save class files ColdFusion will not need to recompile the files across restarts, instead it will load the class file from disk. This can be both good and bad. I willl attempt to explain.

If you have a lot of CFM files or a lot of ColdFusion applications that add up to a lot of Class files you may end up with thousands of class files in cfclasses. The problem is when ColdFusion restarts it searches through the /cfclasses directory to find the class that is needed to load. If it does not find it, then it will compile the .cfm file and save the class file to disk. This adds up to a lot of file IO along with a search through the file listing to find the class file. Both of these procedures add up to a lot of time as the number of files in /cfclasses increases. With thousands of class files this may take 500+ ms to occur or even longer. It only increases as the number of files increases.

Saving class files to disk gained you a lot more with CFMX 6.0 because of the compiler that was used. It used javac or jikes to compile and was really slow. The new 6.1 compiler converts the CFM files directly from CFML to bytecode and if you have a speedy processor it happens in 100-200ms and loads the class into memory. Load tests have shown this to be faster with large numbers of class files in /cfclasses.

So, the choice for this setting depends on the number of cfm templates you have. The only way to find out is to test which option performs best in your situaion.

June 12, 2004

ColdFusion, JRun and Flex TechNotes are now available as RSS feeds at the following URLs:

June 3, 2004

On Tuesday June 8th I will be presenting at the Syracuse ColdFusion User Group Meeting. I will be presenting on Performance Tuning ColdFusion.  As we all know, your ColdFusion applications can never perform as well as you want them to. This presentation will explain how to measure performance, load test and tune your server to squeeze out every last drop of speed.

I will discuss my experience from lessons learned working with countless customers through the Macromedia professional services and support organizations. The tuning process is described in detail along with information specific to tuning ColdFusion application code and server settings. This includes the process of

  • Monitoring Performance
  • Finding bottlenecks
  • Running load tests
  • Systematically finding optimizations
  • Tuning J2EE application server settings

Hope to see you there. You can find the details on the Central New York Usergroup website. I will driving over from Rochester, are there any ColdFusion users in the Rochester area? I am working on lining up other presentations in the upstate New York area.

May 26, 2004

I have recieved several questions asking how do I bind XML data to a datagrid? The following code binds a simple XML string that is retrieved through the HTTPService using ColdFusion. ColdFusion could be replaced in this case with a JSP or Servlet. Be aware, there is a known issue with the Flex webservice proxy when you try to invoke XML through a webservice. The XML will be encoded incorrectly and will not decode in the Flex application. The workaround is to use HTTPService and create a .cfm or .jsp page that serves as a gateway.

-----xmlService.cfm-----
<CFSILENT>
<CFSAVECONTENT VARIABLE="employees">
 <employees>
  <employee>
   <id>100</id>
   <name>Brandon Purcell</name>
   <title>Principal Engineer</title>
   <phone>617-555-6971</phone>
  </employee>
  <employee>
   <id>101</id>
   <name>Bill Phillips</name>
   <title>VP Engineering</title>
   <phone>617-555-5555</phone>
  </employee>
 </employees>
</CFSAVECONTENT>
</CFSILENT>
<cfheader  name="content-type" value="text/xml">
<cfsetting enablecfoutputonly="yes" showdebugoutput="no"> 
<CFOUTPUT>#employees#</CFOUTPUT> 
-----end xmlService.cfm-----
------datagridXML.mxml------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" 
  backgroundColor="#FFFFFF" 
  verticalGap="0" 
  initialize="myHTTPDetail.send()">
  
<mx:HTTPService id="myHTTPDetail" showBusyCursor="true" method="GET" 
 url="xmlService.cfm">
</mx:HTTPService>
<mx:DataGrid 
 id="orderGrid" 
 dataProvider="{mx.utils.ArrayUtil.toArray(myHTTPDetail.result.employees.employee)}"
 width="375">
 <mx:columns>
 <mx:Array> 
  <mx:DataGridColumn columnName="id" headerText="Id" width="40"/>
  <mx:DataGridColumn columnName="name" headerText="Name" width="115"/>
  <mx:DataGridColumn columnName="title" headerText="Description" width="130"/>
  <mx:DataGridColumn columnName="phone" headerText="Price"/>
 </mx:Array>
 </mx:columns> 
</mx:DataGrid>
</mx:Application>
------end datagridXML.mxml------

May 11, 2004
Macromedia is celebrating our customer community by hosting Community Week, May 17-21, an opportunity to learn, network and interact with Macromedia product managers and our customer community. There will be free online presentations and a worldwide meeting on Wednesday. Go to www.macromedia.com/community for more information. Macromedia Community Week

May 10, 2004

I recently received the question below on Enterprise clustering with ColdFusion MX 6.1 and wanted to share my response.

"I was hoping you could point me in the right direction as far as which options you would recommend. I am setting up an enterprise environment for an application using CFMX J2EE and hardware load balancing. There will be 2 hardware load balancers, 2 webservers running Linux/Apache and 3 app servers running CFMX 6.1. In one of your articles you describe the situation where the hardware load balancers are used to balance the load for the web servers and the connectors are clustered using JRun's connector clustering. In another you describe a situation where there is a load balancer in front of the webservers and a load balancer in front of the app servers. I was hoping you could advise me on which of these are best suited for an enterprise level architecture, I was initially thinking of going for the first option but now I am condsidering the second. Also, from your experience, which HLB would you recommend?"

In the two articles in the links below I outline two different architectures. The first architecture has a hardware load balancer in front of the web servers and uses the JRun web server connector to handle failover and load balancing to the application servers. The second architecture uses a hardware load balancer both in front of the web server and between the web server and application server.

The first architecture is the easiest to setup and scales pretty well. The one pitfall I find is that the JRun connector clustering feature does not offer application awareness. Basically if your application hangs on a ColdFusion server the connector will continue sending requests to it. The most scalable and redundant option is to use multi-tier hardware. It is by far the most difficult to configure but it is worth it if you want to minimize downtime. The multi-tier hardware option gives you true application level failover and load balancing using probes and custom load balancing algorithms. You really only need a single F5 or CSS to accomplish this as well. You can set up a single BigIP to handle all traffic. Basically, traffic flows from the internet into the BigIP then it is sent to the pool of web servers, then proxied back to the BigIP then sent to the pool of ColdFusion servers. This is outlined in the multi-tier hardware article. That is how Frank and I configured our BigIP for the article mentioned below. If you have a second box you can put them in a master/slave setup so if the hardware device fails it will fail over. With a master/slave configuration and multiple web, application and db servers you should 99.9% uptime with your site.

As far as my hardware recomendations, I have primarily worked with only the Cisco CSS and F5 BigIP devices. The CSS is a great box and if you are already familiar with Cisco products it is a great fit. By far though my favorite is the F5 BigIP device. It does almost anything you want and is really easy to use either through the web based admin or command line. It also offers Icontrol which is a really powerful addition worth taking a look at.

Referenced Articles:

  1. Clustering ColdFusion MX 6.1 Enterprise on JRun
  2. Multi-Tier Hardware Load Balancing with ColdFusion MX 6.1

April 22, 2004

Frank DeRienzo and I have had a lot of requests for an article on integrating Microsoft NLB and ColdFusion/JRun clustering. Frank and I set this up in the lab a few months back and sat down to write up the steps. I have to be honest though. I am not a big fan of NLB as a clustering technology because of the lack of application level monitoring.  Then again it is provided free with Windows 2003.  There are less options now that Cluster CATS is being deprecated so NLB is one of the new software based options. Of course if you are looking for the best solution always go with hardware.

After the editing process is complete this article will be featured on the macromedia.com website. You can view the current article here. This process will work for ColdFusion MX 6.1 Enterprise or JRun 4. Feel free to post comments below.....

The latest revision of the article is now live on the macromedia.com website.

April 7, 2004
Macromedia Max 2004 was announced today and it is being held November 1-4 in New Orleans, Louisiana.  You can find more information on http://www.macromedia.com/macromedia/events/max/

April 5, 2004

A few months ago I ran into an issue where after deploying ColdFusion to WAS 5 we could not get it deployed to a second instance running on the server. The feedback the WAS admin gave and the logs was very unhelpful.  It turns out that if you create a second instance throught he admin console you can only use it for clustering.  If you want to create a second instance that will be used for a seperate deploy you need to follow a different procedure. The procedure is outlined in a technote on the macromedia.com website. Thanks to Sarge and John Z for working this issue out.

BTW, these instructions work the same for any J2EE application you deploy on WAS including Flex.

April 2, 2004

I was writing an application in Flex using ColdFusion as the backend. I first started using Webservices for my implementation and was wondering if I could easily switch it to Flash Remoting without modifying any of my other code. After all with CF, a CFC can be exposed either by web services or by Flash Remoting without any changes on the CF end.

My initial code looked like the following in Flex that called the CFC as a webservice

<mx:WebService id="usersCFC" 
wsdl="http://127.0.0.1/myappdir/components/mycfc.cfc?wsdl"
showBusyCursor="true">
 <mx:operation name="getAllUsers"
result="userModel.userResultHandler(event.result)"
fault="userModel.userFaultHandler(event.fault)"/>
</mx:WebService>

Notice I am just pointing the wsdl in the WebService tag directly at CF. Now if I want to use the ColdFusion Flash Remoting gateway instead, I don't have to change any of my other code in my MXML document. I just need to change the data tag. I just comment out the mx:WebService tag and replaced it with the following

<mx:RemoteObject id="usersCFC" 
endpoint="http://127.0.0.1/flashservices/gateway"
source="myappdir.components.mycfc"
   showBusyCursor="true">
 <mx:method name="getAllUsers"
result="userModel.userResultHandler(event.result)
fault="userModel.userFaultHandler(event.fault)"/>
</mx:RemoteObject>

Notice that I am not using the AMF implementation that ships with Flex. Instead I am using the CF flash gateway by modifying the endpoint attribute in the mx:RemoteObject tag.

The only issue that I ran into when doing this was with CF's handling of webservices. All variables returned from a CF webservice are uppercase even if they are not in the cfc file. With Flash remoting they are returned exactly as they are written. MXML is case sensitive so you may run into an issue here. Otherwise I found that this worked very well.  Pretty cool!!!

**Late addition to this entry: I recieved an email noting that if you use Remoting with the endpoint attribute you will not use the proxy that is built into Flex. If the Flash Remoting server is on a different domain from the originating domain the Flex SWF was loaded from then a crossdomain.xml file needs to be used. You can find details on the crossdomain.xml file in the Flash livedocs. Basically you will run into a problem if Flex is on one machine and ColdFusion is on another. It is also worth taking a look at this Flash Devnet article for a second explanation of crossdomain.xml.

April 1, 2004

Macromedia just release the updated DataDirect JDBC version 3.3 drivers which resolve a large list of issues from earlier versions of the drivers. The new drivers provided in the TechNote should replace the 3.2 drivers shipped in ColdFusion MX 6.1 or the 3.1+ drivers.

For a full list of the issues and to download the drivers see the technote on the macromedia.com website.

March 26, 2004

I have had a lot of requests to put this presentation on my site for download. This is the presentation that I gave at Max 2003, Japan Max 2004, User Group Manager meeting, and the Boston ColdFusion UserGroup.  The presentation cover the steps to secure your ColdFusion Application either through a webserver or programatically. Whether it's authentication, authorization, access control, or roles, security is an important and complex topic. Implementing runtime security and access control involves understanding all of the above and more. Using databases, LDAP, Web server, and many other approaches you will learn how to leverage the ColdFusion MX security framework to greatly simplify securing your applications. This is a great start for using CFLOGIN with ColdFusion with an overview of the tags and functions; CFLOGIN, CFLOGINUSER, CFLOGOUT, getAuthUser(), and isUserInRole().

The slides for the presentation can be downloaded here

The code for the presentation can be downloaded here

March 25, 2004

The JRun Closed Connection error can cause a lot of frustration but if you understand how to debug and find the issue that is causing it, then you can resolve the problem quickly. The JRun Closed Connection error is caused by an issue that occurs in the JVM that causes the JVM to close the socket that is open from the external webserver connector (IIS, Apache, Iplanet) to JRun. The JVM problem can occur due to several different issues

  1. outOfMemory or the JVM approaches the max heap
  2. Native code in a CFX or COM objects causes an error in the JVM

The memory condition can occur in several different cases

  1. If debugging is left on in production with CF (make sure you have it turned off in production not just masking the IP's)
  2. Large resultsets are returned from the database taking up a significant amount of memory (reduce the size of database results you are returning)

Diagnosing the issue: In order to diagnose this issue there are several areas to start. By turning on metrics and JVM Verbose GC output you can monitor the memory and find out if memory utilization is the problem. In some cases the memory spikes very quickly and comes back down. A large recordset returned from a query can cause this behavior. The recordset will populate into memory and GC will clean it up quickly. If the size of the recordset pushes the heap beyond the max heap you will see a problem. Although you may not see an outOfMemory error everytime. Any connections that were in use during this spike will get a JRun connection closed error. If you look in the webserver connector logs you may find connection reset by peer errors as well.

Also review all of your logs for long running pages and errors in the Application.log. If you have a number of errors correct each issue also identify and fix any long running pages.

You can also provide a better user experience by modifying the page that displays when the error occurs. Without modifying the connector errorurl the user will get a white HTML page that says "JRun Connection Closed". You can replace this with an HTML page that just asks them to refresh or place javascript in the page that will refresh automatically. In either the httpd.conf or jrun.ini file modify the errorurl to point to an html page on the webroot of the web server.

For example with IIS you need to uncomment the #errorurl parameter and set it to the html page
errorurl=/errorpage.html

While I have not covered every possible issue that can cause JRun Connection Closed errors I have at least provided some quick debugging steps. I will continue to update this entry as I find more approaches for debugging this problem.

March 15, 2004

March 11, 2004

JRun updater 3 was released today. There are many bug fixes and updates to JRun in this release, you can see a full list of the updates and bug fixes here. 

Important Update April 22 2004: If you downloaded the JRun U3 updater before April 14th then you should go back and download it again. There have been several fixes to the connector in this latest update. Specifically the fix that breaks the connector with CF deployed to /. The latest download can be found here.

March 10, 2004

I will be presenting "Securing ColdFusion Applications" at the Boston CFUG meeting on March 23rd. This presentation covers authentication, authorization, access control, roles, using webserver authentication and ColdFusion security tags. For more information see the Boston CFUG website.

March 3, 2004

There are several articles that I would like to recommend reading that were added in February 2004 to the Macromedia Developer Center.  They do not all deal with ColdFusion but I think you will find them quite interesting either way.

RoboDemo:
Applying RoboDemo to Your Web Apps
By Jake Sibley
Simply put, RoboDemo is the easiest way to create interactive demonstrations and software simulations in Macromedia Flash format. You use RoboDemo to record a series of actions on your computer screen as a compact Flash movie (SWF); then you can easily publish the movie online or send it in an e-mail.

ColdFusion/Flash:
Employee Updater Sample: Building a Client/Server Application with ColdFusion and Flash
By Ben Forta
Ben Forta guides you thorough a muli-step process of building a web service-powered data grid with the Data Connection Wizard in Flash MX Professional 2004. This is really a great bridge for ColdFusion devlopers that want to understand how to connect Flash to ColdFusion using the new components in Flash MX Professional 2004.

Central:
The Building Blocks of a Central Application
By Vera Fleischer
I have been meaning to spend some time learing Central but I just have not had to the time to do it. This article provides a simple approach to building a Central App.

March 2, 2004

Steven Erat has added a few notes beyond what I have in my current clustering articles.  If you get stuck with your configuration or run into error I recommend taking a look at his blog entry.

March 1, 2004

It has been a while since I posted to my blog. I have been in Japan for the last two weeks attending Japan Max and working with our MMKK office providing training for our Japan distributors.  It was a great trip and I worked with some of the nicest people I have ever met.  The conference was a great success and well attended. I presented on Securing ColdFusion Applications and manned the support desk answering questions. I also had the pleasure of attending a JCFUG meeting. John Dowdell, Ben Forta and myself handled questions from the group and a lot of positve comments were brought forth.  You can view all of the pictures from the event here.

I will work on posting more items in the future. I have been doing a lot of work on Flex so look for more on that topic.