Performance Testing Flex Remoting (AMF) with JMeter

[UPDATE] this has since been resolved! JMeter support rocks :D
URL: http://svn.apache.org/viewvc?rev=661141&view=rev
Log: Bugs 44808 & 39641 – Proxy support for binary requests

You may still find the ruby proxy idea interesting …

The Action Message Format (AMF) is a binary protocol that Flex applications use to remotely communicate with the server. I’ve tested recording of this using LoadRunner which picks up the binary format nicely as part of the HTTP POST.

It will look a little like this:

web_custom_request("amf_3",
"URL=http://host.under.test.com/messagebroker/amf",
"Method=POST",
"Resource=0",
"RecContentType=application/x-amf",
"Referer=http://ost.under.test.com/messagebroker/client/main.swf",
"Snapshot=t13.inf",
"Mode=HTML",
"EncType=application/x-amf",
"BodyBinary=\\x00\\x03\\x00\\x00\\x00\\x02\\x00\\x04null\\x00\\x02/3\\x00\\x00\\x01\\x0F\n\\x00\\x00\\x00\\x01\\x11\n\\x81\\x13Mflex.messaging.messages.CommandMessage\\x13operation\\x1BcorrelationId\tbody\\x13messageId\\x11clientId\\x15timeToLive\\x13timestamp\\x0Fheaders\\x17destination\\x04\\x08\\x06\\x01x06\r"
"my-amf\\x01\\x06#labelPrintService",
LAST);

I understand that Segue Silk Performer also has this capability to natively record binary protocols arbitrarily attached to the POST. Unfortunately the native JMeter proxy (when used for recording) doesn’t pick up this data reliably.

This defect is current being tracked at the ASF Bugzilla

After looking around for some proxying software that would assist, products such as Charles Proxy looked tempting. But to be honest, if you’re reading this and using JMeter, you’re probably not interested in paying any license fees.

Read on for a free alternative when using JMeter.

The first thing I wanted to setup was a proxy that could catch the necessary HTTP header requests (and responses), and store a copy of any amf content types to the filesystem when recording a typical user transaction. I did this using Ruby and the webrick/httpproxy gem.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'webrick/httpproxy'
 
i= 1
server = WEBrick::HTTPProxyServer.new(
  :Port=> 9090,
  :RequestCallback => Proc.new{
  |req,res|
    if req.raw_header.to_s.match(/x-amf/) == nil
		  puts req.request_line,req.raw_header
		else
	    amf = req.body
	    file = File.new("./#{i}.amf","w")
	    file.write(amf)
	    file.close
		  res['Content-Type'] = "application/x-amf"
		  i = i+1
		end
    puts "------------------"
  })
trap "INT" do server.shutdown end
server.start

So if you run that proxy from a terminal, it will listen on port 9090 (or whatever you like) for any traffic. Then I just use Firefox (with the FoxyProxy add-on for fast proxy switching :) ) and conduct my normal transactions through the flex app via the browser.

What you will then see in the terminal, is a copy of all the headers for the requests/responses printed to screen. If it sees any headers with an x-amf content type, it will save a copy of the AMF data to a sequentially number file called #{n}.amf

Once you’ve run the transactions, you can create a thread group in JMeter and start adding all the HTTP Request samplers that have POST actions with AMF data. You might still want to use the standard JMeter proxy to record all the normal HTTP stuff (minus the AMF) to save time. Then just amend your test plan to include the POST actions with AMF, such that they look something like this.
http request post with amf

Of importance is the file that you are sending with the post. This should be the full path to the AMF file previously recorded. Also make sure the MIME type is applicaton/x-amf.

Make sure you add the AMF files you saved earlier with the proxy in the correct order to the test plan. That should be all you need to do to test from JMeter. In my case I also had to add standard config elements such as the HTTP Cookie Manager and a User Parameters (to correlate jsessionids).

8 comments to Performance Testing Flex Remoting (AMF) with JMeter

  • Bruno

    Cool! I am having the same problem to make loading/stress tests in Flex apps… any other experience you have discovered since them? Have you added all by hand in JMeter? Thanks

  • Tim

    No I haven’t progressed beyond this post. The app I was looking at was quite simple, perhaps 5 – 10 unique binary blobs of data that I had to capture, so it didn’t warrant any further development. You could if you were interested look at perhaps modifying the HTTP recording proxy code in JMeter to cater for the amf mime type. Or alternatively knock up a Ruby or Perl script to help create template jmx files (after all, they are just an xml text file).

    Regards,
    Tim

  • Bruno

    Thanks Tim. Have you seen this ticket (https://issues.apache.org/bugzilla/show_bug.cgi?id=39641)? They say AMF can be recorded in JMeter, but I could not make it work.
    Thanks.

  • Tim

    Thanks for the bug reference, I wasn’t aware it was being tracked. Good to see progressive development continuing with JMeter. As you’ve highlighted, it looks like the HTTP proxy does not yet support recording of binary data, so hopefully someone with more nouse than me can fix that up in JMeter.

    Although that would just solve one problem. The correlation or parametization of data inside those binary blobs might be difficult to achieve once JMeter successfully records it using the proxy. You would then have to perhaps modify the pre/post-processors to modify the data in the correct format. I’m not sure just running the regular expression extractor for example would work as intended on binary data … In other words, there’s still probably some manual work to do at the end in any case.

    Regards,
    Tim

  • You are right! The first step is make the proxy save the binary data. A second problem would be handle these data that could be needed in some special cases. Thanks.

  • S

    Hi,

    I’m testing a web-service done with Flex (Flex uses REST to get info such as picture URLs from a data base server and then displays the info in a browser as a web page). I was wondering would you have any advice on how to interpret the results of JMerer testing.

    For a regular HTTP-page It is enough to have one sampler which loads the whole page including images etc. So all the uploads are taken in one sample. This is as it should be, thinking from users’ experienced performance point of view.

    But with Flex I need to add each picture upload etc. as a separate sampler in JMeter. This gives much faster response times as I get the response times for individual picture uploads (rather than the response time for the loading of the entire web-page).

    Hope I stated the problem clearly.

    Any help much appreciated,
    S

  • jpl

    Hi,

    JMeter 2.3.2 supports binary content.

    But in my knowledge jmeter does not allow to accomplish seriously load tests with the protocol amf.

  • Aina

    hi all

    I’ve tried to load test a flex app with JMeter. Actually, JMeter can record the scenario but when playing it back : i have 100% errors on some of my swf :’(

    do you know whether JMeter has problems handling flex app components ? or some kind of Session problems whithin Flex perhaps ?

    thanks a lot …

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">