[Twisted-web] Ampoule vs PerspectiveBroker

Glyph glyph at twistedmatrix.com
Thu Oct 13 13:01:51 EDT 2011

On Oct 13, 2011, at 11:41 AM, Jacek Furmankiewicz wrote:

> Which is the recommended way for interprocess communication these days?
> Is it the existing PerspectiveBroker or Ampoule (which uses AMP as the underlying RPC protocol)?
> Are there drawbacks/benefits to either of them?

Somebody should probably write an AMP vs. PB wiki page or something, this does come up every so often.

Briefly: PB's strength is that it allows you to serialize and synchronize large, complex object graphs with relatively little effort, but more safely and explicitly than (for example) Pickle would allow you to do.  Doing this with AMP would require specifying a large protocol with lots of object IDs, and you'd have to manage their mappings yourself.

AMP's strength is that it's simple and visualizing the wire format is easy.  Most importantly you can visualize the wire format by looking at static declarations of commands and their responses, without ever examining any code.  This allows you to easily provide AMP interfaces between multiple languages (for example, C#: <http://amp-protocol.net/AmpSharp>).  This also means that AMP is a bit more performant (on current trunk, on CPython, ~2300 AMP/sec as opposed to ~1300 PB/sec).

A bit more effort has been going into AMP lately because many core Twisted developers now believe that AMP covers more and more common use-cases, and that should generally be the default choice for most new protocol work.

Bottom line: you should try AMP first, and if you find it's too tedious, maybe give PB a shot and see if it simplifies your protocol code.

More information about the Twisted-web mailing list