1

I have an application that spins up a bunch of HttpListener GetContextAsync' tasks- one per request ideally

However when running a stress test (Hitting it with JMeter) i seem to be CPU bound but to only 50% cpu usage in total (Machine has 2 vcpus)

Is there something i'm missing here or a quirk in .NET Core on linux that is required to get it to run with more than 1 core? It hits and sits at 50% exactly - I've also tried using a Semaphore to limit concurrent connections etc, but no luck

The code that is creating the tasks is below - from my understanding of .NET Tasks they will spin up new threads when required (But will share if not needed) until the thread pool is maxed out - which should result in 100% cpu utilization

        while (_listener.IsListening)
        {
            HttpListenerContext c = await _listener.GetContextAsync();
            Task unawaited = RunContext(c);
        }
    
Josh
  • 11
  • 1
  • Related question: https://stackoverflow.com/questions/25591848/async-await-multi-core Also take a look as this: https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.parallel?view=net-6.0 – Alexandre Dec 04 '21 at 20:57

0 Answers0