I have a file controller that is responsible for processing uploaded files into chunks (1 MB chunks). I spent my time testing this in development, and everything was as expected. The following is a pseudo action code:
logger.Log("Getting InputStream");
var stream = Request.InputStream;
logger.Log("Got InputStream");
var bytes = GetByteArray(stream);
await FilesService.AppendToFileAsync(key, fileName, owner, bytes);
private byte[] GetByteArray(Stream stream)
{
var bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
return bytes;
}
Specificity is not very important. I get bytes, then add them to a file on disk.
In production, however, everything is strange. This is the timeline for requesting one downloadable fragment (during production):

With the help of registration, I am absolutely sure that all the waiting time is spent on Request.InputStreamprop.
The waiting time is from 1 minute to 3 minutes.
My question
- Does this mean that the server just spends so much time loading the request? (although I really doubt it)
- Or is it that I am doing something wrong here?
: Request sent, ?
, , , - , ?
,, ?
EDIT:
, , , , .
- , appdomain chunk ( ), , . , ,
Request.InputStream.
2:
GetBufferlessInputStream , . , . , , . , , , .
, , :
2015-09-15 23:23:12.6419|Entered upload chunk
2015-09-15 23:23:12.6419|Got bufferless stream
2015-09-15 23:23:12.6419|Stream length: 1048576 (1 MB)
2015-09-15 23:23:12.6419|Reading stream...
2015-09-15 23:23:38.8211|Read stream of size 1048576 bytes (1 MB)
:
var b = new byte[s.Length];
var read = 0;
var c = 0;
while ((c = s.Read(b, read, b.Length - read)) != 0)
{
read += c;
}