fdimuccio / play2-sockjs

A SockJS server implementation for Play Framework.
Apache License 2.0
62 stars 11 forks source link

Play2-sockjs performance #12

Open TheChifer opened 10 years ago

TheChifer commented 10 years ago

I have just moved from native play websockets to Play2-sockjs. Firefox & IE seems to be much more stable with sockjs & I get wss over https(something play natively lacks dearly) However I see a performance decrease around 10-20% across all browsers for both ws & wss traffic(no difference between ws & wss) when compared to native play plain websockets. The test was perfomed using a minimalistic echo server where the client does a sock.send(...) in 'onmessage'.

fdimuccio commented 10 years ago

Hi, some overhead must be taken into account when using SockJS. Everytime a message is received or sent from ws (or wss) it must be deserialized or serialized from/to json to be transmitted over a SockJS connection, also for a simple echo server. However when benchmarking make sure to warm up the jvm to let the jit compiler make the right optimizations. I will do some profiling to see if it can be optmized.

TheChifer commented 10 years ago

Thanks for your response.

I actually did not use SockJS client in my testing, rather used a native browser Websocket with explicit websocket endpoint(wss:////websocket/) created by SockJS server component(play2-SockJS in this case). This is for 2 reasons, first to make sure client test code is uniform across stest & secondly I am interested only in Websockets. In this case I assume no json parsing is done either way?

Please let em know if there is anyway I can help

fdimuccio commented 10 years ago

I see, so you are using the raw websocket transport (without SockJS framing), in this case the performance should be very close to the native Play plain websockets (no json parsing is being done).

If you push the code that you used to benchmark I can use it to profile the library.