sockets - Java: Read/Write compressed objects over TCP -
i have transfer records on tcp though sockets. used objectinputstream
, objectoutputstream
, worked fine. 1 critical think socket opened once , has remain open through whole communication each side reads , writes more once (so more persistent connection).
i tried compress objects before writing them in order increase overall performance , results quite encouraging but, since used gzipoutputstream
, bytearrayoutputstream
, memory overhead large , in case outofmemory error.
i tried deflateroutputstream
didn't seem apropriate writting objects. there way solve problem?
java serialization convenient, rather ineffective both size-wise , in cpu usage. if want high performance, suggest use different communication protocol, example based on protocol buffers or else light-weight.
Comments
Post a Comment