0

I have the problem that my self hosted web api transfers large binary datas very slow. It takes 10 seconds to transfer an 10MB file. That is how i host the service:

var config = new HttpSelfHostConfiguration(url);
config.MaxReceivedMessageSize = long.MaxValue;
config.MaxBufferSize = int.MaxValue;
config.ReceiveTimeout = new TimeSpan(1, 0, 0);

config.TransferMode = TransferMode.Streamed;

config.Routes.MapHttpRoute(
     "API Default", "api/{controller}/{id}",
     new { id = RouteParameter.Optional });

HttpSelfHostServer server = new HttpSelfHostServer(config);

server.OpenAsync().Wait();

that is how i send the request:

Stopwatch time = new Stopwatch();  time.Start();

var blobObj = new BlobObject() { Blob = bt, Id = ui }; response =
await client.PostAsJsonAsync("api/archive", blobObj);

Console.WriteLine("ElapsedMilliseconds: " +
time.ElapsedMilliseconds.ToString());

Does anyone has an idea, what i am doing wrong?

enter image description here

System specification:

8GB Ram (2,7GB Free) 256GB SSD Intel i5 1st Generation 2.4GHz Windows 8.1 x64

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
BendEg
  • 20,098
  • 17
  • 57
  • 131
  • are you sure the data goes through the local loop? have you tried looking at what goes through the wire with wireshark? – Filip Sep 06 '14 at 12:05
  • I will check the traffic with wireshark, the web api is hosted and called under: http://localhost:50121 – BendEg Sep 06 '14 at 12:06
  • What is specification of your machine? In operation with self-hosted server, many process switching occurs, so speed of process switching, response and speed of disks, usage of memory and probability of memory swapping affect performance. If amout of memory is small, frequent page fault and disk I/O make system slow greatly. Detail of your system may give you some hint to solve your problem. – Fumu 7 Sep 06 '14 at 12:22
  • @Fumu7 Added my system specification to the question – BendEg Sep 06 '14 at 12:37
  • You need know not only hardware specification but software and system specification. How many memory faults are occured in a second? What processes made memory fault fequently? You need all these information to understand situation you are facing to. If you don't know, how you can explain to persons on StackOverflow? – Fumu 7 Sep 06 '14 at 12:48
  • how long does it take inside the service? Have you measured that? – Filip Sep 06 '14 at 15:02
  • @Filip that should not need any time, beacuse in my test the service does nothing with the byte-array. – BendEg Sep 06 '14 at 15:33
  • I see. Are you at least able to tell whether it´s the upload or download that takes so long? – Filip Sep 06 '14 at 19:17
  • @Filip it is the upload. i will test the download. – BendEg Sep 06 '14 at 19:18
  • have you tried http://stackoverflow.com/questions/451376/file-download-through-wcf-slower-than-through-iis ? through this is related to download, the behavior will likely be the same – Filip Sep 06 '14 at 19:23

0 Answers0