Adobe MAX 2008

    Introduction to AMF
    Wednesday, December 3rd
    Tom Hensel




                                ...
Terms

    AMF
         Action Message Format

    Remote Procedure Call (RPC)
         An inter-process communication...
De nition

    AMF is a binary format based loosely on the Simple Object Access
     Protocol (SOAP). It is used primaril...
Purpose - AMF0

    AMF was introduced in Flash Player 6 in 2001 and remained unchanged
     with the introduction of Act...
Purpose - AMF3

    In Flash Player 9, Action Script 3.0 was introduced along with a new
     ActionScript Virtual Machin...
Speci cations

    Adobe Systems published the AMF binary data protocol speci cation on
     December 13, 2007 and announ...
Bene ts - Efficiency

    AMF objects are very small
         Efficient Encoding and Decoding
              AMF data is par...
Bene ts - Efficiency

    Lower bandwidth and CPU usage means
         Lower latency
              Improved User Experien...
Bene ts - Reference Tables

    In AMF 3, Strings, Complex Objects and an Object Type's Traits can be sent
     by refere...
Bene ts - Ease of Use

    Well-documented
         Speci cations available
         Many examples and code samples ava...
Bene ts - Pitfalls

    Ubercomplex types can not be serialized
         DisplayObject
         and all of it‘s descend...
Downsides (and workarounds)

    Binary Format
         Not readable by humans
              Use a HTTP transport chann...
Benchmarks

    Apache JMeter
         Capture AMF packets containing the clients requests rst (tcpdump, Charles, ...)
 ...
Benchmarks

    James Ward‘s „Census“ Benchmark
     www.jamesward.com/census/
         Source Code available (GPLv2)
  ...
Transport - Basic

    No additional Port required
         Most of the time Port 80 is used
         No rewall issues ...
Transport - Advanced

         Advanced HTTP and AMF Channels
              ‚Piggybacking‘ provides lightweight pseudo p...
Server Side

    PHP
         PHP Extension
              AMFEXT
                Written in C, fast encoding and decod...
Server Side

              SabreAMF
                Server and Client
                PHP5 only
                Compli...
Server Side

    Cold Fusion
         Supports serialization to AMF
         Easy to use
         Supported by Adobe

...
Server Side

    .NET
         amf.net
              Implemented as an HttpHandler, easy to install
              Very...
Server Side

    Python
         PyAMF
              Integration with Python web frameworks like Django, Pylons, Twiste...
Server Side

    Ruby
         Ruby on Rails
              RubyAMF
                Very easy for Rails Developers to g...
Server Side

    Java
         RED5
              Mainly for Audio- and Video Streaming
              Supports AMF Rem...
Server Side

         Granite Data Services (GraniteDS)
              Lightweight and stable, scales well
             ...
Server Side

    Currently, only Adobe LiveCycle Data Services ES implement all protocols,
     channel types and securit...
Tools

    Client Development
         Flex SDK is everything you need
              Flex Builder
              Flash ...
Tools

    Debugging, Testing
         Firebug
              Recommended for every day use
              Does not deco...
Tools

    Debugging, Testing
         ServiceCapture
              Similar to Charles but more simple, Shareware
     ...
Showcase

    Mercedes Benz - Focus on Fashion
         Server Tiers
              Application Server
                ...
Showcase

    mercedes-benz.de/focus-on-fashion




                                                                     ...
Showcase

    mercedes-benz.de/focus-on-fashion




                                                                     ...
Showcase

         User Experience
              Quick response times
                Server-side caching of database q...
Summary

    Efficiency
         Enhanced User Experience
         Greater User Acceptance
         Helps to save the pl...
Questions and Answers

    Please ask!




                                                                              ...
Keep in touch

    Elephant Seven
     www.e-7.com
    Yeebase Open Source Publishing
     www.yeebase.com


    EMail
...
®




Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential.
                                 ...
Upcoming SlideShare
Loading in …5
×

Introduction To AMF

3,189 views

Published on

Slides from my speech at the Adobe MAX 2008 in Milano: The Action Message Format (AMF) is a binary format used to serialize ActionScript objects. It is used primarily to exchange data between an Adobe Flash application and a remote service, usually over the internet.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,189
On SlideShare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction To AMF

  1. 1. Adobe MAX 2008  Introduction to AMF  Wednesday, December 3rd  Tom Hensel ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 1
  2. 2. Terms  AMF  Action Message Format  Remote Procedure Call (RPC)  An inter-process communication technology that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction [wikipedia]  Serialization  In computer science, in the context of data storage and transmission, serialization is the process of converting an object into a sequence of bits so that it can be stored on a storage medium (such as a le, or a memory buffer) or transmitted across a network connection link. When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object [wikipedia]  Often referred to as decoding and encoding of objects ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 2
  3. 3. De nition  AMF is a binary format based loosely on the Simple Object Access Protocol (SOAP). It is used primarily to exchange data between an Adobe Flash application and a database, using a Remote Procedure Call (RPC)  AMF allows to serialize (and deserialize) ActionScript object graphs  Once serialized an AMF encoded object graph may be used to persist and retrieve the public state of an application across sessions or allow two endpoints to communicate through the exchange of strongly typed data  AMF0 also supports sending complex objects by reference which helps avoid sending redundant instances in an object graph as well as allowing endpoints to restore relationships and avoid circular references ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 3
  4. 4. Purpose - AMF0  AMF was introduced in Flash Player 6 in 2001 and remained unchanged with the introduction of ActionScript 2.0 in Flash Player 7. The version header of this format was set to 0 and thus this version of the format is referred to as AMF0 ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 4
  5. 5. Purpose - AMF3  In Flash Player 9, Action Script 3.0 was introduced along with a new ActionScript Virtual Machine (AVM+) - the new data types and language features made possible by these improvements prompted AMF to be updated  Given the opportunity to release a new version of AMF, several optimizations were also made to the encoding format to remove redundant information from serialized data  This new version of the format is referred to as AMF3 ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 5
  6. 6. Speci cations  Adobe Systems published the AMF binary data protocol speci cation on December 13, 2007 and announced that it will support the developer community to make this protocol available for every major server platform  Speci cation of AMF0 download.macromedia.com/pub/labs/amf/amf0_spec_121207.pdf  Speci cation of AMF3 download.macromedia.com/pub/labs/amf/amf3_spec_121207.pdf ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 6
  7. 7. Bene ts - Efficiency  AMF objects are very small  Efficient Encoding and Decoding  AMF data is parsed directly to and from objects  Small Overhead  Binary Format  Optional compression (zlib)  Bandwidth and CPU usage is lower compared to  HTML  JSON  YAML  XML  SOAP  WDDX ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 7
  8. 8. Bene ts - Efficiency  Lower bandwidth and CPU usage means  Lower latency  Improved User Experience due to quicker response times  Key Factor for User Acceptance  Essential for Near-Real-Time-Applications, e.g.  Data Processing and Visualization  Multi-User Applications  Online-Games, MMO  Interface and Sensor Input (i.e. Kiosk-Applications)  Bandwidth Usage  Bandwidth is still not free (and maybe never will)  Scales well (no accumulating overhead)  Suitable for low-bandwidth requirements  POTS, ISDN, GPRS, ... ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 8
  9. 9. Bene ts - Reference Tables  In AMF 3, Strings, Complex Objects and an Object Type's Traits can be sent by reference  Complex Objects are de ned as  Anonymous Objects, typed Objects  Arrays  Dates  XMLDocument, XML  ByteArrays  Instead of sending redundant information AMF can simply refer to an earlier occurrence of a complex object  Transparent Reference Caching  No Client-side logic required  Again, lower bandwidth and CPU usage, lower latency ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 9
  10. 10. Bene ts - Ease of Use  Well-documented  Speci cations available  Many examples and code samples available  Promoted by Adobe (supported)  Easy to implement  Most of the work is done automagically  No Parsing required  Less possibly erroneous logic needed  Dont Repeat Yourself (DRY)  Strong-typed result objects  Syntax Completion everywhere  Smooth Team-Work  Error handling is included ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 10
  11. 11. Bene ts - Pitfalls  Ubercomplex types can not be serialized  DisplayObject  and all of it‘s descendants  Native Types and Custom classes are supported  Mapping a AMF serialized object back to a custom class is possible, but  The custom class needs to be instanced when the AMF object is unserialized  Compression (zlib)  Lower bandwidth usage, but  Higher latency and CPU usage  Compressing binary data is not as efficient as compressing text (i.e. XML)  Do not use compression on larger chunks of data if near real-time response times are required ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 11
  12. 12. Downsides (and workarounds)  Binary Format  Not readable by humans  Use a HTTP transport channel for testing, or  Use suitable tools to capture and decode  Less complex clients means a more complex backend  Higher skill requirements for the backend developers (J2EE, Python, Ruby, ...)  Client design can not x faulty backend design  Plan and design both ends carefully and verify your decisions  Create diagrams and documentation  Embrace team-work  Lack of understanding in not-so-agile enterprises  Do not push your bosses, convince them by facts (they might save time and money) ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 12
  13. 13. Benchmarks  Apache JMeter  Capture AMF packets containing the clients requests rst (tcpdump, Charles, ...)  JMeter replays packets and measures response times  Produces nicely looking graphs  Integration in NetBeans (great for J2EE Backend Developers)  Not for beginners! ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 13
  14. 14. Benchmarks  James Ward‘s „Census“ Benchmark www.jamesward.com/census/  Source Code available (GPLv2)  Perfect to convince your bosses that AMF is the right thing  Thanks James! ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 14
  15. 15. Transport - Basic  No additional Port required  Most of the time Port 80 is used  No rewall issues on basic setups  Various Transport Channel Types  Flex SDK offers ne-grained channel con guration  Simple AMF or HTTP channels  AMF channels transport data in the binary AMF format and HTTP channels transport data in AMFX, a text-based XML representation of AMF  AMF channels provide better performance Using a HTTP channel instead of an AMF channel is only recommended when  there are auditing or compliance requirements that preclude the use of binary data over the network  or the contents of messages should be easily human-readable over the network (debugging) ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 15
  16. 16. Transport - Advanced  Advanced HTTP and AMF Channels  ‚Piggybacking‘ provides lightweight pseudo polling: Rather than the client channel polling the server on a xed interval the client sends a non-command message to the server which sends any pending data along with the response to the client message  ‚Long-polling‘ sends a request to the server, but a response is not returned to the client until one is available (similar to „Comet“)  Streaming RTMP, AMF, and HTTP channels  Less protocol overhead (connection is kept alive)  RTMP allows message pushing  No polling at all  Lowest latency ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 16
  17. 17. Server Side  PHP  PHP Extension  AMFEXT  Written in C, fast encoding and decoding of AMF0 and AMF3 messages  Looking for a new maintainer since July 2008  PHP Frameworks  AMFPHP  Simple and powerful  Works since Flash MX 2004  Optional support for AMFEXT  CakeAMFPHP  Easy to use with CakePHP, requires AMFEXT  Development stalled ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 17
  18. 18. Server Side  SabreAMF  Server and Client  PHP5 only  Compliant to PHP Strict Mode  WebORB for PHP  Well documented, commercial support available  Management Console includes Service Browser, Testing and Security Management  Code Generators for ActionScript Remoting, Cairngorm and PureMVC  Zend AMF  Easy to use with Zend Framework  PHP is very widespread  Promoted by Adobe ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 18
  19. 19. Server Side  Cold Fusion  Supports serialization to AMF  Easy to use  Supported by Adobe  WebORB for Cold Fusion  Supports AJAX, Flash, Flex and Silverlight  Provides easy to use interfaces to Features of Cold Fusion  Coming soon! ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 19
  20. 20. Server Side  .NET  amf.net  Implemented as an HttpHandler, easy to install  Very simple  WebORB for .NET  Easy to install (only on Microsoft IIS)  Commercial support available  FluorineFx  Supports RTMP  Template based code generator  Includes a Service Browser  Blaze Data Services for .NET (BlazeDS.NET)  Upcoming port, announced on MAX 2008, stay tuned ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 20
  21. 21. Server Side  Python  PyAMF  Integration with Python web frameworks like Django, Pylons, Twisted, CherryPy, ...  Scales well if used with mod_python, mod_wsgi, ...  Possible to run on Google App Engine  RTMPy is a protocol for Twisted  Based on PyAMF  Implementing RTMP  Still in development ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 21
  22. 22. Server Side  Ruby  Ruby on Rails  RubyAMF  Very easy for Rails Developers to get started  Flexible and extensible  Scales well if Rails is used with Thin, lighttpd, nginx, Phusion Passenger (mod_rails), ...  WebORB for Rails  Based on Ruby on Rails  Tight integration of ActiveRecord  Commercial support available  RubyIZUMI  RTMP Server for streaming Flash video/audio (H.264)  Based on EventMachine (fast single-threaded socket engine)  Experimental - not ready for production use ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 22
  23. 23. Server Side  Java  RED5  Mainly for Audio- and Video Streaming  Supports AMF Remoting, too  Blaze Data Services (BlazeDS)  Open Source (GPLv3)  Shares codebase (messaging and remoting) with LiveCycle Data Services SE  Rich set of features  Supports streaming channels over HTTP  Includes Tomcat 6 Application Server (easy to deploy)  LiveCycle Data Services Community Edition  Certi ed builds of BlazeDS  Developer and Enterprise Support ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 23
  24. 24. Server Side  Granite Data Services (GraniteDS)  Lightweight and stable, scales well  Dedicated Service Factories: integrates with EJB3, Seam, Spring, Guice, Warp, POJO, ...  ‚Granite Eclipse Builder‘ for Code Generation in Eclipse  Includes a Client-side framework (‚Tide‘)  Service Locator Pattern (inspired by Cairngorm)  Offline Data Caching (similar to Live Cycle Data Services ES)  Supports ‚Long polling‘ Data Push over HTTP (‚Gravity‘)  Server-side compilation of MXML (‚Granite Web Compiler‘)  Upcoming support for GlassFish and TopLink (instead of Hibernate)  WebORB for Java  Integrates with Spring, EJB, Pojo, ...  Commerical support available (Enterprise Edition)  Supports Microsoft Silverlight, too ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 24
  25. 25. Server Side  Currently, only Adobe LiveCycle Data Services ES implement all protocols, channel types and security options shown  Feature Comparison of LiveCycle Data Services ES and BlazeDS  sujitreddyg.wordpress.com/2008/01/31/blazeds-and-lcds-feature-difference/  Adobe LiveCycle Data Services ES  Based on J2EE  Very powerful  Data Synchronization  Con ict Resolution  Offline Data Caching  Very expensive  One-CPU license available for production use (formerly know as LiveCycle Data Services Express); Multi-CPU developer licenses available on request ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 25
  26. 26. Tools  Client Development  Flex SDK is everything you need  Flex Builder  Flash CS4  Power asher FDT  Your choice!  Frameworks  PureMVC  Cairngorm  Guttershark  Mate  Many, many more ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 26
  27. 27. Tools  Debugging, Testing  Firebug  Recommended for every day use  Does not decode AMF  Limited to HTTP (AMFX)  Charles  Multi-protocol local proxy  Deciphers SSL/TLS  Supports RTMP  Decodes AMF  Easy to use  Affordable Shareware ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 27
  28. 28. Tools  Debugging, Testing  ServiceCapture  Similar to Charles but more simple, Shareware  tcpdump  Weapon of choice for UNIX experts (geeks)  WireShark  Full edged network analyzer  Captures and dissects mostly everything on the wire  Does not decode AMF ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 28
  29. 29. Showcase  Mercedes Benz - Focus on Fashion  Server Tiers  Application Server  MySQL 5  Ruby on Rails 2.0  ActiveRecord  RubyAMF Plugin  Web Server (Assets)  Streaming Server (Videos)  Application  Adobe Flash Platform  Application built using Flex 3 SDK  PureMVC Framework (Model-View-Controller Pattern)  uses RemoteObject over a AMF channel  Content Modules built in Flash CS3 ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 29
  30. 30. Showcase  mercedes-benz.de/focus-on-fashion ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 30
  31. 31. Showcase  mercedes-benz.de/focus-on-fashion ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 31
  32. 32. Showcase  User Experience  Quick response times  Server-side caching of database queries  Application-side caching  Assets (Browser-Cache)  Data (RAM)  Rich and mixed media  Stylish people, fast cars  Developer Experience  Rapid implementation of a prototype  Lightweight application logic  Transparent, strong-typed data model (Value Objects everywhere)  Interdisciplinary team-work  PureMVC rocks ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 32
  33. 33. Summary  Efficiency  Enhanced User Experience  Greater User Acceptance  Helps to save the planet (lower energy consumption)  Ease of Use  Intuitive way of working with data  Less hassle, higher quality  Have more time for creative ideas, or  Spend more time with your loved ones  AMF is not always the right thing  Consider alternatives (E4X, SWX, JSON, ...)  Proof your design by a working prototype ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 33
  34. 34. Questions and Answers  Please ask! ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 34
  35. 35. Keep in touch  Elephant Seven www.e-7.com  Yeebase Open Source Publishing www.yeebase.com  EMail tom.hensel@e-7.com  XING www.xing.com/pro le/Tom_Hensel ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 35
  36. 36. ® Copyright 2008 Adobe Systems Incorporated. All Rights Reserved. Adobe Con dential. 36

×