Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex - Remoting vs HTTPService - when to use what?

I have been using Flex for a while and have not used remoting as of yet. Currently my apps use a webservice that generates xml that I use for databinding.

What would be the benefit to using remoting over an xml webservice in this use case? Is there a general guideline when I should choose remoting over webservices?

Why would I want to use remoting?

I have downloaded http://www.fluorinefx.com/, but have yet to do any real tinkering...

Thanks.

like image 727
mmattax Avatar asked Oct 30 '08 12:10

mmattax


4 Answers

Speaking personally I use remoting because I prefer AMF to SOAP/XML for the simple reason of speed and packet size.

Ted has a good discussion in the relative merits of XML vs. AMF here

Something to consider is what you have already in place on the server and where you think the future of your clients lies. Do you anticipate replacing or extending your clients? If yes then Web Services are a good architectural choice. If you are committing to Flex in the short/medium term then you may be able to squeeze better performance out of remoting with AMF3 vs. your web services.

P.S. I once had a link to a very good site which had measurements of the relative performance of AMF and SOAP - I'll see if I can find it and post a link.

P.P.S. here it is, but it seems not to be working at the moment.

like image 184
Simon Avatar answered Oct 25 '22 14:10

Simon


Web services are great if you are only using simple data transfers between the client and host. You form up the XML message, send it to the server and get a simple XML message, back. You then deserialise it and act upon the data accordingly. AS3 support for XML is superb, you can use it to communicate with any data service and you are in full control at the client end.

Where web services fall down is when the data structures passed back and forth become too complex, or when the number of different data structures passed back and forth become too large. Remoting overcomes these problems by providing a heavyweight framework that handles the serialisation for you. Define your .NET/ PHP/ Java or whatever classes, and the framework should provide tools to generate the equivalent AS classes. That way you can send complex object structures back and forth without needing to know how the data is being serialised. Because you don't need to know, it can compress the structure to make it pretty much non-human-readable, or even use binary data so you get speed increases too.

Remoting is not suitable for small scale or varied server protocol stuff though. You have to synchronise class structures between server and client; you can only communicate with a compatible remoting servers and the framework adds overhead to the client size and complexity.

There is no right answer as to which to use, when. Both have advantages and disadvantages. As a rule of thumb though, use web services for simple stuff and remoting for complex stuff (which is pretty vague advice ;)

like image 45
David Arno Avatar answered Oct 25 '22 14:10

David Arno


Remoting is meant to make the transfer of data from a remote service to a Flash or Flex app easier and faster. When using remoting there is no need to parse or deserialize the data received from the service. This is because data is sent to the application in native bytecode.

One of my main reasons to use remoting is that it is more lightweight than an XML service. This is because XML is a bad format memory-wise, especially for large data sets. XML is great as an exchange format, but once inside your application, due to the verbose tags and possible whitespace, will most likely consume more memory than values expressed in native bytecode.

like image 22
Matt W Avatar answered Oct 25 '22 15:10

Matt W


This is a really good live benchmark test that compares AMF remoting with Web Services and HTTP Services. You can even download the source code to run this test in your own environment.

I'd also agree with some of the earlier posts that AMF remoting really shines when you are running large data sets. For smaller data sets you probably won't see a significant difference.

like image 45
Kathleen Erickson Avatar answered Oct 25 '22 14:10

Kathleen Erickson