Bug 31292 - Poor Concurrent Performance with HTTP
Summary: Poor Concurrent Performance with HTTP
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: master
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2015-06-22 12:12 UTC by Chris Mcvittie
Modified: 2015-07-14 16:37 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Chris Mcvittie 2015-06-22 12:12:45 UTC
It seems like the threadpool is losing the plot with a fairly basic multi-threaded HTTP request.  This goes back to 2.10.8, but is the same in master on github as of today.

$ mono load-test.exe
27113ms

$ MONO_THREADPOOL=microsoft mono pps-load-test.exe
5842ms


I think the MS Threadpool should be the default based on this example.

Thanks, 
Chris


Code to reproduce.

```
 class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(System.Net.ServicePointManager.DefaultConnectionLimit);
            ServicePointManager.ServerCertificateValidationCallback = (z, y, x, v) => true;
                
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            RequestParallelCustom(1);
            RequestParallelCustom(50);

            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedMilliseconds + "ms");
            Console.ReadKey();
        }


        public static void RequestParallelCustom(int count)
        {
            var tasks = new List<Task>();

            for (int i = 0; i <= count; i++)
                tasks.Add(Task.Factory.StartNew(() =>
                                                {
                                                    var c = i;
                                                    var stopwatch = new Stopwatch();
                                                    stopwatch.Start();
                                                    var wc = new WebClient();
                                                    wc.DownloadString("http://ip.jsontest.com/");
                                                    stopwatch.Stop();
                                                    Console.WriteLine(c + ":  " + stopwatch.ElapsedMilliseconds + "ms");
                                                }));


            Task.WaitAll(tasks.ToArray());


        }

    }
```
Comment 1 Ludovic Henry 2015-07-14 16:37:57 UTC
The MS threadpool is now the default