Again a question about compression on wcf services.
I’m using netnamedpipe binding to send some entity objects to my calling application.
I know, that’s a bad idea, but that’s the way my customer wants it to be implemented.
So right now, I have to send about 45000 datasets (entity objects) via netnamedpipe.
That’s really really slow. I’ve implemented a class which compresses the data objects to
byte[] before sending, but 45000 sets are still taking ’bout 45 seconds to send/receive.
I’m compressing like this:
public static byte[] Compress<T>(T data)
{
byte[] result = null;
using (var memory = new MemoryStream())
{
using (var zip = new DeflateStream(memory, CompressionMode.Compress, true))
{
var formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
formatter.Serialize(zip, data);
}
result = memory.ToArray();
}
return result;
}
Is there a way to improve that? 45 seconds are too much 🙁 I think, main reason could be serialization of my entity objects.. but how to speed that up?
try using DTO pattern. Send only those fields which are required