In the previous project that I worked, we had a similar problem. We had a C # web service that received media requests. Media can vary from files to images and are stored in a database using BLOB columns. Initially, a web method that handled media extraction requests read a fragment from a BLOB and returned to the caller. It was one round trip to the server. The problem with this approach is that the client has no feedback on the progress of the operation.
The computer has no problems of science, which cannot be solved by an additional level of indirection.
We started by refactoring the method in three ways.
Method1 to set up a conversation between the caller and the web service. This includes request information (such as media identifier) ββand exchange of capabilities. The web service responded with a ticking identifier, which is used by the caller for future requests. This initial call is used to allocate resources.
Method2 is called sequentially until more is received for the media. The call includes information about the current offset and the marked identifier that was provided when calling Method1 . Return updates the current position.
Method3 is called to complete the request when Method2 reports that the reading of the request material has been completed. This frees up allocated resources.
This approach is practical because you can immediately inform the user about the progress of the operation. You have a bonus that splits requests for Method2 in different threads. Progress than can be communicated in a piece, as some BitTorrent clients do.
Depending on the size of the BLOB, you can load it from the database at a time or by reading it in pieces as well . This means that you can use a balanced mechanism based on a given watermark (BLOB size) that allows you to load it in one go or chunks.
If there is a performance problem, consider packing the results using GZipStream or reading message encoders, and in particular, pay attention to the binary and message transfer optimization (MTOM) mechanism.
source share