ColdFusion vs Flash (Part III)

I haven’t had time to focus on this for the last few days because I’ve been working on MAXBloggers.com, and on finishing up the ColdFusion portion of the Community Resource Directory application. The CF side is completely done now, which includes both the CF server-side code (the web services and everything “below” the web services), and the client-side code (that which interacts with the web services, and everything “above” it).


The architecture is such that the ColdFusion front-end can be installed on another server, and still work seamlessly with the rest of the application through web services. I wrote it that way because I wanted to be able to install the front-end of the application on multiple servers throughout the company, not so much for performance reasons (although this architecture does allow for a form of scalability), but for convenience.While I was developing the CF front-end of the application, I was very impressed by how well it performed considering the fact that it was using web services and several layers of components. In fact, there was no perceptible delay beyond what you would expect from any web application (time to make the request, render the results in the browser, etc). Once I installed it on an internal production server, however, and imported over 200 records from an Excel spreadsheet, I started getting the type of performance I had been expecting. The reason it was so fast during development is that I was only sending a few test records over the wire at any given time.How slow is slow? Well, using only components to retrieve a query object with 206 rows takes between 61 and 110 milliseconds (pretty darn fast, I think). Retrieving an identical query object through web services takes anywhere from 877 milliseconds to 1400 (pretty darn not fast, I would say). Considering that using web services can be up to about 20 times slower, one might jump to the conclusion that this was not the smartest way to design my application. Allow me to explain.Web services are amazingly convenient and useful. One of the reason they are so convenient and useful is that they work across so many different technologies. The reason they work across so many different technologies is because they are so abstract, and typically with abstraction comes overhead. One could say, therefore, that with convenience often comes overhead. To a certain extent, that’s ok. For instance, people don’t write web applications in C or assembly because although they might execute faster on the server, they would take too long to develop and maintain. Developers are generally willing to give up speed for convenience in most circumstance, at least up to a certain threshold, and although using web services for the application makes it around 20 times slower than if I were just using local components, it’s worth the convenience of my application being more easily distributed.The absolute best way to write an application like this would be to make it configurable enough that you could have it use either web services or local components. I should have thought of that from the beginning. Oops. Oh, well. It won’t be hard to re-factor. Before I do that, though, the next step is to write the Flash front-end and compare developing the front end with CFML, HTML, JavaScript and CSS to building it in Flash. My Flash skills are a little rusty, so there will be a little learning curve, but I should have something to report back soon after MAX.

8 Responses to ColdFusion vs Flash (Part III)

  1. Brian says:

    I don’t know. I understand the need for Web Service interoperability in Flash but one large caveat remains: crossdomain.xml. I beleive that if you assert that crossdomain.xml access is neccessary for your service then you are asserting that you have access to the server in some fashion. Esp if you are the one developing the service.Ok. So thats all a given and obvious. But what isn’t obvious to me is why you wouldn’t use Flash Remoting to access the service and enjoy the performance boost. If you don’t have direct access to the service, meaning you cannot set the crossdomain.xml then you have to create a service proxy on your own server. Once again, why not use Flash Remoting????Is there *really* a valid reason?Because you want to use Web Services and expose your service to other clients? Fair enough, you can do that because the only change is how your client accesses the service not within the service itself.So back to my question: why and when should one use webservices with Flash in a practical real world application?!

  2. Dave says:

    I agree with Brian… why would you ever use web services over remoting? I guess if everyone started throwing out crossdomain.xml files on their servers as standard practice, but until then, like Brian said, developers are likely to just proxy off the server that the client is “on”.When you add the performance benifits of remoting, especially with complex objects, I can’t see a reason to use web services over remoting.I really don’t see why the push in MX’04 was web services when the push in Player 7 made them less useful (crossdomain.xml). I think maybe Macromedia is worried about being labeled as pushing proprietary technology, but with all the opensource AMF stuff, I really doubt that would happen.

  3. It’s not so much that we were worried about being criticized for pushing proprietary technology as we were trying to meet the demand for open standards. There are a lot more people out there in the world using web services than using Flash Remoting (generally speaking), so we wanted to make sure Flash was able to integrate with those technologies as well as our own technologies. I chose to use web services for this project primarily because I’m experimenting with creating a single ColdFusion interface for two different clients — a ColdFusion client, and a Flash client. Since a ColdFusion client obviously can’t communicate with a ColdFusion back-end using Flash Remoting, I decided to use web services. Maybe I will build the Flash client in such a way that it can use either web services or Flash Remoting (the ColdFusion back-end should not have to change), and I can measure which technique is more efficient.Believe me, I have nothing against Flash Remoting. I love it. In fact, the poll on my weblog uses Flash Remoting to communicate with a ColdFusion server, and it works great.

  4. Dave says:

    Well, since you have to put a crossdomain.xml on the server that has the interface, and that will open up the flash gateway the same as it will open up webservices, there still isn’t a compelling reason in my mind why you would use web services for the flash client. Remoting will always be faster and more effecient, the only reason you would ever HAVE to use web services in flash is to talk to a server that doesn’t support flash remoting but DOES have a crossdomain.xml… a situation that seems like it will be quite rare.

  5. Kevin Hoyt says:

    I would suggest that if your core complaint in the Flash Remoting v Web Services debate is performance, then you may be barking up the wrong tree.You’re sacrificing standards, which has obvious benefits, for propriety (which has implied benefits that may or may not be delivered). If web services is slow today, does that mean it will always be slow? I’m not talking about faster processors either, but better [logical] ways of dealing with web services. Just as an example, a lazy deserialization of processing the SOAP packets could dramatically improve client performance at the least, and open the doors for additional optimization techniques in the future.With Flash Remoting (AMF), what you get is what you get. Standards are garunteed to evolve to suit the needs of the community, and right now the community is calling for efficiency in web services. I would stay tuned on this…Note that I’m not trying to start a way here on FR v WS – that’s been done. I’m just offering my perspective/opinion on why one might design with web services in mind.Also in Christian’s defense, a web services component is provided with Flash MX Professional 2004 and integrates very nicely with ActionScript v2. Developing with Flash Remoting in Flash MX Professional 2004 means developing with AS1. This could have a definite impact on comparison of developing a rich client v. an HTML client. Especially if you’re a Java-centric developer.

  6. Brian says:

    Kevin, so you know, the ability for AS 2.0 Flash Remoting has been community supported since aprox 2 weeks after 2004 was released by both Joey Lott (person13.com) and Justin Watkins (amfphp.org). As a java centric developer I’d expect you to know that.;) j/kAt any rate, if the SOAP standard changes to improve serialization performance– then a new Flash Component will need to be developed. I don’t know about you but I’d rather edit a text file– or a Remoting Service Proxy– than recompile a Flash movie any day. The point is moot when the now exhausted crossdomain.xml argument is brought into play.I don’t think there is any war between Web Services and Flash Remoting. The war is developers trying to make your company recognize that they are different tools for different jobs.The point here is that the situation illustrated by Christian’s example is cool but not realistic. Honestly, after investing a the past year in Macromedia’s RIA world its been more than a little hard to swallow Remoting being all but completely ignored even when it is obviously a better technology for 90% of the jobs we are doing. The WS support is a great boon to Flash development– no doubt about it. I tell every non-flash developer skeptic I meet about it and they nod in approval. This ultimately is the only thing WS support is really good for in practice. And while AMF may be proprietary but it certainly *is* a standard. Don’t’ believe me? Ask these guys:http://www.amfphp.org/http://www.openamf.org/http://www.simonf.com/flap/And there are .NET alternatives out there though I do not know about them.And Christian, I think it would be a great idea to build an alternate Flash client that uses Remoting. If only to see the difference in performance.. and perhaps so you can the difference in development.I want you to know this is not a post intended to be disrespectful or hostile. I love Macromedia and read this blog every day and I really do appreciate your efforts and your companies products. I think myself and many developers that support your company feel a little insulted by this shift. I want you to know we support the decision and move to WS for the next generation of Flash. Its really good- for all of us. All we ask is that you recognize the previous platform that we’ve all invested in and if you can find the time maybe even support it too.Thanks again,

  7. Ruben says:

    Congratulations to your fantastic Site. Thanks

  8. Rob Burn says:

    I’ve just started out with flash 7 prof/ CF7 and the problem I see it is painfully slow on larger datasets, what i mean by larger? like 100 records with about 30 fields… not very large actually, about a fraction of a sec for a sql query to obtain from the datbase server. It’s bad enough that flash comes back after 5 seconds and say’s hey this is a slow query.. wanna continue?I’m very unimpressed by the speed, it’s a killer in what I’m trying to accomplish, I’ll move back to the FR and go that way. I did think about quering out only like 10 records at a time or so and requery for each page etc… hmm