Richard Searle's Blog

Thoughts about software

Play 2 Server Sent Events and Ajax performance

Posted by eggsearle on October 20, 2012

Consider a “dumb client” Single Page App where the domain logic resides on the server.
The UI events are delivered via Ajax, with the server responses flowing over SSE to update the UI.
This minimizes the size of Javascript code while (hopefully) retaining the responsive interaction.

The key question is thus latency and server load.

A simple experiment wires an Ajax call to the SSE event handler, where the call delivers a new data element over the SSE connection, forming an infinite loop.
That provides a simple measurement of the total request/response chain.

Both Play 2 and Jetty Continuations based implementations were tested, using Fedora Core 17, Google Chrome running on AMD Phenom II X6 1100T.

Implementation latency (ms) CPU Load (%) JRE Load (%)
Play 16 52 7
Jetty 12 5 1

CPU Load is reported by top and JRE Load by JConsole.

Play uses Iteratees and NIO, which are both designed for concurrency rather than raw throughput.
A 10x difference is a surprising high cost to pay for the concurrency and expressiveness of the Play API.

The proposed user case would have less than a score of clients, which would be feasible even with a vanilla block Servlet implementation.

Advertisements

4 Responses to “Play 2 Server Sent Events and Ajax performance”

  1. […] Play 2 Server Sent Events and Ajax performance […]

  2. […] Play 2 Server Sent Events and Ajax performance […]

  3. Fulano Tal said

    Hi,

    could you share the code for your test, please? Maybe a link to a github or bitbucket repo?

    Cheers

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: