Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8375619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:13:25+00:00 2026-06-09T15:13:25+00:00

I’m working on an ASP.NET web service application which makes heavy use of CPU.

  • 0

I’m working on an ASP.NET web service application which makes heavy use of CPU. I’ve noticed on a 4 core server, the CPU is underutilized. So I’ve come up with a simple service to see if it is possible to reach 100% CPU. Here it is.

The calling client attacks this server with concurrent threads and repeated messages. Each request takes between 0.5 and 2 seconds to complete (depending on # of threads). The highest CPU usage it reaches is 80% across all 4 cores. I get the same result if I use 4 threads or 16 threads, 1 client or 2 clients. A 2 core box has the same problem.

So, is it possible to reach 100% CPU on a multi-core IIS server with code that isn’t in an endless loop?

public class MyHttpHandler : IHttpHandler
{
    public bool IsReusable  { get { return true; } }

    public void ProcessRequest( HttpContext context )
    {
        switch( context.Request.HttpMethod )
        {
            case "GET":
            {
                string s = "";
                for( int i = 0; i < 999999; ++i )
                {

                    s = s.Substring( s.Length / 2 );
                    s += i.ToString();
                }
                context.Response.Output.WriteLine( "<html><body><h1>Web Service - " + s + "</h1></body></html>" );
                context.Response.StatusCode = 200;
                break;
            }
            default:
            {
                context.Response.StatusCode = 405;
                break;
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:13:27+00:00Added an answer on June 9, 2026 at 3:13 pm

    You are generating garbage at full speed. This triggers lots of GCs. Before and after a GC can happen, for a brief duration all threads must be stopped. This is preventing the process from saturating the CPU.

    Put in an arithmetic loop. Thread.SpinWait does not guarantee CPU usage because internally it asks Windows to deschedule the current thread. It is not a simple “infinite” loop.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.