开发者

Silverlight binary / faster serialization

We currently use Silverlight 4 with WCF services and try to read large arrays of users objects from service. In our code it takes about 0.5 (and less) seconds to generate 700 objects, arranged by hierarchy (a lot of loops).

And it takes about 4-5 seconds for Silverlight/WCF to communicate that data - on localhost.

I've measured timings in my code / service call, used Fiddler to see data (5MBs!), and when I tried to pass a simplified object with plain attributes (instead of nested lists, etc), it took much less amount of data and was very quick - like, a second.

I've read many articles on the subject - there's no simple way, the best I could find is to return byte[] from WCF method (and have types in the separate assembly), or highly manual serializers (like protobuf) that require to write custom attributes, etc.

OK I tried those. protobuf-net is extremely hard (adding numbers to 200 existing classes isn't fun), and v2 is not here yet, and binaryMessageEncoding redu开发者_如何学运维ced data load from 5.5MB to 4.5MB, not too much.

But, I can't believe, is there any out-of-the-box WCF/Silverlight solution to stream large amounts of data? Isn't it supposed to be a nice modern technology for enterprise solutions?

How do I tell Silverlight/WCF to stream my data faster and smaller, rather than 5MBs in 5 seconds? Can I just say in config: "use small and fast serializer"?


I've found the SharpSerializer package very easy to use for fast binary serlization in Silverlight: http://www.sharpserializer.com/en/index.html. The resulting serialized data size is much smaller than using the DataContract serializer or other text-based serializers.


Does IIS have compression enabled. This will however impact CPU and you might need to double check if silverlight honors the deflate http header?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜