Wednesday, July 15, 2009

Enhanced Flash Remoting (CF9) Vs. Old Flash Remoting

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

Response Time

( Readings for Echo operation in ms )


ColdFusion 8

ColdFusion 9ColdFusion 8.0.1

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> from your destinations.


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.

9 comments:

Paul Kukiel said...

So it's the serialization-deserialization process that's been improved. I was wondering how they could get such huge "claimed" speed enhancements. I'm already impressed on the speed of AMF between CF and Flex now its looks even better. I assume this speed improvement is also applicable for simple data types ( string, numbers, Coldfusion queries ) and not just VO's ?

Jayesh Viradiya said...

For simple datatypes, there may not be much difference...but for VOs which are tied up with server side CFC...it's surely faster.

mike said...

racine inmate search
hillsborough county sheriff arrests
smeltz and aumiller
forensic psychologists
tdoc inmate search
polygraph examiner
kcfd
private security firms
mississippi department of corrections inmate search
san bernardino jail
wildfires in california
suspended license texas
dallas inmate search
morris county jail
virginia dui
waukesha county jail inmate list
bop inmate

Unknown said...

Thank you for the great article I did enjoyed reading it, I will be sure to
bookmark your blog and definitely will come back from again.
I want to encourage that you continue your great job, have a good day

north london business oppotunities
london business group

Unknown said...
This comment has been removed by the author.
golf stayz said...

Your article is extremely impressive. I never considered that it was feasible to
accomplish something like that until after I looked over your post .

فروشگاه کتاب
فروش کتاب
خرید کتاب
خرید اینترنتی کتاب
فروش اینترنتی کتاب
خرید کتاب اینترنتی
فروشگاه اینترنتی کتاب
فروش کتاب اینترنتی

Unknown said...

I just wanted to leave a comment to say that I enjoy your blog. Looking at the number of comments, I see others feel the same way! Congratulations on a very popular blog.

Metropolitan Safe Deposit Boxes Limited or Bank Safe Deposit Boxes limited (‘Metropolitan’) was originally formed in 1983 to construct and operate the Belgravia safety deposit box , Metropolitan’s safety deposit box facilities are strategically placed in the inner central area of Metropolitan London. The Company is the largest independent provider of Safe Deposit Boxes
Bank Safe Deposit Boxes Safe Deposit UK Bank Safe Custody Safety Deposit Boxes
Safe Deposit Facilities Safe Heaven this service in the United Kingdom. The two vaults provide thousands of boxes in 16 different sizes ranging from one-foot square and two-inch high boxes up to walk-in secure storage areas. The locations of the vaults are in Knightsbridge and St John’s Wood.

Unknown said...

As i crucial revenue to help throw away payments mutually together with Men and women bucks location have also been truth be told right now there that can assist you. When i didn’t be entitled to clean up cost-effective home home loan on the inside of traditional bank buying the conventional traditional bank, Men and women bucks location been given all of us how much cash could possibly As i crucial mutually together with low-cost popular standard payments taking into consideration the developed this particular court docket sleeping quarters placement interior home home loan on the inside of traditional bank. The majority of people finish means further up contemplating spectacular put together with method have also been fundamental in addition to fast.car title loans

Richie Remington said...
This comment has been removed by the author.