One may wonder, what is this deal about in ColdFusion 9 for “Enhanced Flash Remoting”? Or One may also wonder what was wrong with Old Flash Remoting (CF8 style) that we needed to enhance Flash remoting in ColdFusion 9?
To find answers for these questions, let’s first explore, what was wrong with CF8 style flash remoting. Mainly there was one problem and that was the “Circular reference serialization-deserialization” bug.
This bug was long standing problem for Advanced CF-Flex developers who tried to send nested or related ActionScript Objects having circular reference to each other, over wire to ColdFusion from Flex Clients, resulting in following error.
[Flex]Exception when invoking service 'remoting-service': flex.messaging.Message
Exception: java.lang.StackOverflowError
.
.
.
Exception: flex.messaging.MessageException: java.lang.StackOverflowError
at coldfusion.flash.messaging.ColdFusionAdapter.getFlexError(ColdFusionA
dapter.java:361)
at coldfusion.flash.messaging.ColdFusionAdapter.invoke(ColdFusionAdapter
.java:273)
.
.
.
--> This Bug is fixed in ColdFusion 9 – Enhanced Flash Remoting feature. So Developers are no more blocked writing advanced Flex-CF Applications with having AS Objects with circular references.
Let’s discuss another advantage of using new Enhanced Flash Remoting. Fixing the circular reference bug wasn’t an easy task, many radical changes were required to be done to fix this issue and most of the ActionScript-CF datatype translation or serialization-deserialization process has to be re-written in many ways. This gave us the opportunity to improve the entire process, resulting in faster AS-CF datatype translation which made New Enhanced Flash Remoting faster many times against Old Flash Remoting.
--> A Significant Performance Boost for Flash Remoting.
- Enhanced Flash Remoting is 6 -7 times faster against CF 8.0.1
- Enhanced Flash Remoting is 10-11 times faster against CF 8.
So How did I measure this Performance Gain?
To measure this performance gain, I created a small Flex Application which will send an Actionscript Object to ColdFusion 9 and ColdFusion 9 will echo it back to Flex application. So making an entire server trip and back will give an appropriate idea about the serialization-deserialization process both ways.
The below Actionscript Object that I used for this purpose has most of the common datatypes of AS.
package com
{
[RemoteClass(alias="perf.DataSamples")]
public class DataSamples
{
public var firstname:String = "";
public var lastname:String = "";
public var city:String = "";
public var zip:uint;
public var email:String = "";
public var ContactNos:Object;
public var designation:String = "";
public var experience:int;
public var salary:Number;
public var CompaniesWorkedFor:Array;
public var dateOfBirth:Date;
public var IsMarried:Boolean;
public var Children:Object;
public function DataSamples()
{
}
}
}
As you observe that, this DataSample class has properties of varying datatypes like String / uint /int / Objects(CFC mapped Objects, Plain AS objects) / Number / Array (Indexed, Associative) / Dates / Boolean. Also observe that this DataSample AS class also maps with a ColdFusion server side CFC “perf\DataSamples.cfc”. So most common Flex app scenarios are being covered through this AS class.
I am assuming here that similar sort of AS object would broadly represent a Flex application’s Custom AS Class.
Now, so in what quantum or magnitude I should send this DataSample objects I should use to find out the performance difference between Enhanced Flash Remoting and Old Flash remoting. Sending a Few DataSample objects may not give a real idea about the performance gain, so in order to measure the real difference in speed, we have to magnify it by replicating a high traffic Flex application which sends DataSamples Objects around in the range of 10,000 – 50,000. See the following stat metrics that has been gathered in similar environments ( Win2k3 R2 + Intel Xeon CPU 2GHz + 2GB RAM) for ColdFusion 8 / ColdFusion 8.0.1 and ColdFusion 9.
No. of CFCs |
| ||||||||
10 K | 14599, 14301, 13890, 14203, 13725 | 1278, 1297, 1285, 1266, 1250 | 7203, 7609, 7062, 7125, 7235 | ||||||
20 K | 29484, 32531, 27188, 27219, 27600 | 2821, 2812, 2815, 2500, 2828, 2515, 2703, 2516 | 14328, 14672, 14375, 14437, 14523 | ||||||
30 K | 41907, 41078, 41355, 41688 | 3969, 4032, 3765, 4031, 3719, 4031, 3718 | 21703, 22312, 22578, 22469 | ||||||
40 K | 55032, 54782, 55392, 55189 | 5000, 5328, 5219, 5313, 5000, 5344 | 30625, 30641, 30516, 30629, 30593 | ||||||
50 K | 70312, 69890, 70891, 70234 | 6562, 6281, 6500, 6297, 6578, 6297, 6265 | 42297, 41516, 39610, 39188, 38010 | ||||||
Each of the reading given in the metrics represents an average of 10-20 server cycles response time. Why I opted to it this way, instead of just taking 1 server cycle, is to get an average time which will be most nearer to the actual figure. For 10K/20K CFCs, average is for 20 server cycles, and for higher 30K-50K CFCs, average is for 10 server cycles.
So If you observe the stats, it suggest that ColdFusion 9 is significantly faster over CF8(10-11 times) and CF801(6-7 times).
A few Basics Questions One may have in mind…..
--> Does ColdFusion 9 also support Old Flash Remoting ?
Yes. It supports, CF8 style, “Old Flash Remoting” for backward compatibility purpose. As “Enhanced Flash Remoting” of ColdFusion 9 requires a few structural changes in the WEB-INF\flex\ XML configuration files at Channel as well as Destination level. By default ColdFusion 9 installation supports new Enhanced Flash Remoting.
--> What are these changes at Channel and Destination level in flex Configuration files from previous CF releases to CF9?
The following properties have been moved from Destination to Channel level. You need to move these properties under <channel-definition > --> <properites> --> <coldfusion>
For more details, refer Documentation, Changes in the XML configuration files for New Flash Remoting in ColdFusion 9.
<access>
<use-mappings>
<method-access-level>
</access>
<use-accessors>
<use-implicit-accessors>
</use-accessors>
<use-structs>
<property-case>
<force-cfc-lowercase>
<force-query-lowercase>
<force-struct-lowercase>
</property-case>
</use-structs>
--> So What happens, while migrating from previous CF installs to ColdFusion 9, if I just simply drop my old WEB-INF\flex XML configuration files, without above changes, over ColdFusion 9 installation?
With Old style XML Flex configuration files, it will continue to work but in this case ColdFusion 9, will use Old Flash Remoting and not the Enhanced Flash Remoting.
One must follow above suggested XML changes, in order to take advantages offered by Enhanced Flash Remoting.
