Optimizing Amfphp

This page includes some tips for advanced users. If you move around large amounts of data and need the best performance you can get, read this.

Try Baguette AMF

Baguette AMF is a PHP extension written in C that converts PHP objects to and from AMF. As it is written in C it is extremely fast. It has a plugin to integrate seamlessly with amfPHP. Disclaimer: Baguette AMF is a commercial product created by the team lead for Amfphp. http://baguetteamf.com

Tweaking Amfphp for speed

Get rid of any plugins that you don’t need, as they only slow you down.

Set checkArgumentCount in your config to false. (version 2.0.1 and onwards)

Better use of bandwidth

- Try using gzip compression. It will slow down your server, but can reduce size. It’s a tradeoff here, so the best is to try it and see what works best.

- Object Traits: If you’re sending large arrays of information using AMF, for example 1000 different version of array( one => randomStuff, two => moreRandomStuff), consider using a strongly typed class. For example:

<span style="font-family: Consolas, Monaco, monospace; line-height: 18px;">class MyVO{</span>
  <span style="font-family: Consolas, Monaco, monospace; line-height: 18px;">public $one;</span>
  <span style="font-family: Consolas, Monaco, monospace; line-height: 18px;">public $two;</span>
<span style="font-family: Consolas, Monaco, monospace; line-height: 18px;">}</span>

You can then send 1000 copies of MyVO.

Without the indication that each time this is the same data sent in the form of MyVO, Amfphp sends key/value pairs each time for one and two. However if it knows that its a MyVO, it will just send the values, along with the information that it’s a MyVO.

So the first case looks something like this:

Obj one bla two bla2 obj one bla3 two bla4

whereas case 2 looks something like this:

MyVO bla bla2 MyVO bla3 bla4

This is of course only true for AMF, as other formats don’t have such advanced encoding features.

Comments

  1. mmostafa

    November 11, 2012

    getting rid of any plugin makes errors in entry point page
    also changing checkArgumentCount to false does not differ in performance..
    i found that the performance of httpservice is better than amfphp !!!
    so how can i make amfphp better perfomed than the http service?
    any help

  2. mmostafa

    November 20, 2012

    another issue
    i have constructed an array of objects in php to receive in flex.
    but when i received the array in flex , i found that each object in the array contains only one field of the object fields.
    i wonder why this happens?

Add a comment

You must be logged in to comment.

Groups