简体   繁体   English

TCP上的对象或字符串(xml)

[英]Object or String(xml) over TCP

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? 我想问一下,通过TCP连接发送序列化对象或纯长字符串(在客户端将被解析为XML)与性能方面有何不同?

I am talking in Milliseconds terms. 我以毫秒为单位说话。

thanks, ray. 谢谢,雷。

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 (eg XStream, JAXB, parsing via SAX etc.) and that alone will affect your results significantly. 特别是,您尚未指定XML序列化方法(例如XStream,JAXB,通过SAX进行解析等),仅此一项将对您的结果产生重大影响。

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. 我也很感兴趣您正在考虑(我认为)Java对象序列化与XML,并建议您还考虑使用JSON或Google Protocol Buffers之类的方法,仅举两种。

Finally, see question such as this , which provide a wealth of further info. 最后,查看诸如this之类的问题,该问题提供了大量的进一步信息。

If you're talking about milliseconds, forget about serializing/deserializing Object to XML. 如果您谈论的是毫秒,则无需将对象序列化/反序列化为XML。

First of all, the serialization/deserialization of Object to XML is already taking sometime. 首先,对象到XML的序列化/反序列化已经花费了一段时间。 As noted by @Brian Agnew, you also need to diligently check about your XML serialization approach. 正如@Brian Agnew指出的那样,您还需要认真检查XML序列化方法。

Secondly, XML (String) over TCP would not be bandwidth friendly and hence taking longer time to transfer. 其次,基于TCP的XML(字符串)将不具有带宽友好性,因此传输时间更长。 Google Protocol Buffers offers some advantage on this, though it really depends on the size of your message. Google协议缓冲区在这方面提供了一些优势,尽管它实际上取决于消息的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM