Server latency is large only in production

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; // Here is the wait.
logger.Log("Got InputStream");
var bytes = GetByteArray(stream); // This is always less than 1 MB.
await FilesService.AppendToFileAsync(key, fileName, owner, bytes); // Write to the file.

// The GetByteArray method
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): Request Timeline

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 // This is the action.
2015-09-15 23:23:12.6419|Got bufferless stream // var s = Request.GetBufferlessStream()
2015-09-15 23:23:12.6419|Stream length: 1048576 (1 MB) // s.Length
2015-09-15 23:23:12.6419|Reading stream... // Here is the wait, this time it was not much (~26 secs) but it still a lot.
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;
}
+4
1

, , .

+1

Source: https://habr.com/ru/post/1607531/


All Articles