Mark Vickery
Mark Vickery

Reputation: 1955

WCF best practises in regards to MaxItemsInObjectGraph

I have run into the exception below a few times in the past and each time I just change the configuration to allow a bigger object graph.

"Maximum number of items that can be serialized or deserialized in an object graph is '65536'. Change the object graph or increase the MaxItemsInObjectGraph quota."

However I was speaking to a colleague and he said that WCF should not be used to send large amounts of data, instead the data should be bite sized.

So what is the general consensus about large amounts of data being returned?

Upvotes: 0

Views: 543

Answers (2)

tom redfern
tom redfern

Reputation: 31780

In my experience using synchronous web service operations to transmit large data sets or files leads to many different problems.

Firstly, you have performance related issues - serialization time at the service boundary. Then you have availability issues. Incoming requests can time out waiting for a response, or may be rejected because there is no dispatcher thread to service the request.

It is much better to delegate large data transfer and processing to some offline asynchronous process.

For example, in your situation, you send a request and the service returns a URI to the eventual resource you want. You may have to wait for the resource to become available, but you can code your consumer appropriately.

Upvotes: 1

PMC
PMC

Reputation: 4766

I haven't got any concrete examples but this article seems to point to WCF being used for large data sets, and I am aware of people using it for images.

Personally, I have always had to increase this property for any real world data.

Upvotes: 1

Related Questions