0

I am implementing a low latency real time application which should push excessive messages.

I would like to ask how different from the performances aspect would be sending Serialized objects or plain long string (which will be parsed as XML in the client side) over TCP connection?

I am talking in Milliseconds terms.

thanks, ray.

rayman
  • 20,786
  • 45
  • 148
  • 246

3 Answers3

1

As with all these sorts of questions, I would prototype some approaches and measure the results.

In particular, you've not specified your XML serialisation approach (e.g. XStream, JAXB, parsing via SAX etc.) and that alone will affect your results significantly.

I'm also interested that you're considering (I presume) Java object serialisation vs. XML, and would suggest you also consider approaches such as JSON or Google Protocol Buffers, to name but two.

Finally, see question such as this, which provide a wealth of further info.

Community
  • 1
  • 1
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
  • am sorry I have edit my question(instead 'of' I added 'or). I wasnt talking about serialized xml but serialized regular objects. what would be better from those two? – rayman Jun 13 '12 at 09:58
1

If you're talking about milliseconds, forget about serializing/deserializing Object to XML.

First of all, the serialization/deserialization of Object to XML is already taking sometime. As noted by @Brian Agnew, you also need to diligently check about your XML serialization approach.

Secondly, XML (String) over TCP would not be bandwidth friendly and hence taking longer time to transfer. Google Protocol Buffers offers some advantage on this, though it really depends on the size of your message.

Wins
  • 3,420
  • 4
  • 36
  • 70
  • I am sorry I have edit my question(instead 'of' I added 'or). I wasnt talking about serialized xml but serialized regular objects – rayman Jun 13 '12 at 09:57
  • 1
    @rayman then Wins' answer means: Go for the serialized "regular" objects, i.e. object instances serialized into binary streams. Wins says the overhead of creating and especially parsing XML is a big performance hole compared to pushing binary data. (XML is supposed to be human-readable, yet nop human would need to read a message dump ever, right?) – TheBlastOne Jun 13 '12 at 10:05
  • And if you would compare Google Protocol Buffers which is kind of optimized xml protocol against Java objects. you still think in the total the Java object way of transfer would be better within performances aspect? – rayman Jun 13 '12 at 10:08
  • @rayman As far as I know, google Protocol Buffers is not kind of optimized xml. It transform your Java object into a stream of binary which is optimized for transport layer. The good thing about it is that you don't really need to update all your nodes whenever the data structure is modified which if you're using XML binding, you have to deploy the latest generated to all nodes before you can really use it. Apart from Google Protocol Buffers, you may consider to "dump" your Java object into middleware such as Solace which is blazing fast and let the other node to pick up as fast as they can. – Wins Jun 14 '12 at 02:29
1

Check out https://github.com/eishay/jvm-serializers/wiki/Home/25fd014e66738268670adaf44ff5408ba2244d37 where object serialization frameworks in java are compared

jontro
  • 10,241
  • 6
  • 46
  • 71