I have an application that pushes entities up to a web service and some of these entities contain byte[] which get stored as varbinary(max). The files themselves are not extremely large, usually 100KB or so but there are often 10 to 20 in a single push. Where I see potential improvements in performance is the whole entity gets encoded into JSON and pushed up. For the byte[]/varbinary field this makes the JSON object quite large and it is just slow - on the magnitude for 3+ minutes to send 5 image entities. I havent found a lot of stuff on whether it is this serialization/serialization and message size causing such a problem or not. One thought I had was to send image entities as straight binary data instead. I havent really seen much else in terms of suggestions so I was curious if anyone had better ideas or arguments about performance one way or another.
Asked
Active
Viewed 1,260 times
2 Answers
0
I would switch compression on (unless you already did).
Here is a hint:
What header should be used for sending GZIP compressed JSON from Android Client to Server?
0
I used Web API in a recent project and streamed binary objects (images/files etc) using MultipartMemoryStreamProvider, my code was derived from an example similar to --> this
My API signature, pass any data related to the binary, in this case just an int:
[HttpPost]
public async Task<HttpResponseMessage> CreateAttachment(int componentId)
{
/* Code for reading stream and storing goes here */
/* Very similar to code in link above */
}

Tommy Grovnes
- 4,126
- 2
- 25
- 40