[en] Compression on by default? (solved)

Topics: Technical Support
Jun 23, 2013 at 11:49 AM
Hello,
I'm playing with newest Zyan version.
I'd like to know: is compression on by default?
If not, how can I switch on/integrate message compression?

Thanks
Reinhold
Jun 23, 2013 at 6:05 PM
ok, my fault. Just TcpBinary has no compression property :-
Coordinator
Jun 24, 2013 at 1:17 PM
Hi, TcpBinary doesn't support compression and encryption.
Please use TcpCustom or TcpDuplex protocol instead if you need compression.

Compression is on by default, and you can even use client and server with different compression settings.
For example, client compresses all data sent to server, and server sends the data as is.
Jun 28, 2013 at 8:27 AM
Hello yallie,
I have done some tests with tcpex and http channel. And there is something strange with the compression setting.
When using HttpCustomServerProtocolSetup I can monitor the traffic with fiddler.
Now I noticed, that these settings produce exactly the same traffic amount:

httpProtocol = new HttpCustomServerProtocolSetup(httpPort, new NullAuthenticationProvider(), false)
{ CompressionMethod = Zyan.Communication.ChannelSinks.Compression.CompressionMethod.None };

and

httpProtocol = new HttpCustomServerProtocolSetup(httpPort, new NullAuthenticationProvider(), false)
{ CompressionMethod = Zyan.Communication.ChannelSinks.Compression.CompressionMethod.Default};

Am I doing something wrong?

In my test application both settings (on server and client) produce this result in fiddler:

Request Count: 61
Bytes Sent: 387.305 (headers:18.853; body:368.452)
Bytes Received: 271.600 (headers:8.182; body:263.418)

Fiddler in general measures real bytes passed. So compression should produce at least 50% less traffic.

thanks
Reinhold
Coordinator
Jun 28, 2013 at 10:22 AM
Edited Jun 28, 2013 at 10:24 AM
Hi, Reinhold,

compression is only enabled for messages larger than CompressionThreshold.
The defaulf value of the threshold is 1 << 16 (64 kilobytes),
so it must be the reason why you don't notice any compression.

The idea behind the CompressionThreshold is that smaller messages
don't benefit from compression (you gain just a handful of hundred bytes),
but might slow your the application down noticeably, especially under heavy load.

Try sending larger messages or adjust the CompressionThreshold
setting of your protocol setup value like this:
protocol.CompressionThreshold = 1024; // one kilobyte
It must be done before creating ZyanConnection.
Please note that setting CompressionThreshold to 0
disables the compression, so the minimum value for this property is 1 byte.

Regards,
yallie