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

  • Home
  • SEARCH
  • 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 9288859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:00:40+00:00 2026-06-18T20:00:40+00:00

I have a script which does a lot of HttpRequsts in a while loop

  • 0

I have a script which does a lot of HttpRequsts in a while loop as follows. It is run in a BackgroundWorker.

CookieContainer cookieJar = new CookieContainer();
string searchURL = "http://blablabla.com/";
bool shouldRun = true; //this is set elsewhere

while (shouldRun)
{
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(searchURL);
    request.ContentType = "application/json";
    request.Method = "POST";
    request.ServicePoint.Expect100Continue = false;
    request.CookieContainer = cookieJar;
    request.Headers.Add("X-HTTP-Method-Override: GET");
    request.Timeout = 1000;

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    // Get the stream containing content returned by the server.
    Stream responseStream = response.GetResponseStream();
    // Open the stream using a StreamReader for easy access.
    StreamReader reader = new StreamReader(responseStream);
    // Read the content.
    string responseFromServer = reader.ReadToEnd();

    JObject o = JObject.Parse(responseFromServer);

    //Do something with the JObject
}

Running the script takes up about 10 % of the CPU (Intel i5 @ 2.5GHz), and I would like to explore other approaches to see if it would be able to reduce the CPU load without reducing the number of requests made per second (current rate is around 3 to 4 requests/s) or whether it would be possible to increase the number of requests per second.

I’ve been looking at asynchronous requests, but would it be able to give me one of the two improvements mentioned above?

  • 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-18T20:00:41+00:00Added an answer on June 18, 2026 at 8:00 pm

    Doing an HTTP request isn’t very CPU intensive, you could do 20+ of these without using 10% of the cpu. What is cpu intensive is what you do with that data. Parsing it (as well as whatever you’re doing with that parsed data) is what’s taking up most of your cpu. You should look into other ways of dealing with that data to save processing power. For example maybe instead of processing the data as you get it, you could save that data and once a minute process all that saved data at once with some script.

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

Sidebar

Related Questions

I have a script that I run which does a lot of tasks and
I have a script in which I have a line which does put the
I have a ColdFusion script that does: <cfset content = replace(content,&##147;,,all)> Which replaces &147;
I have a script which I can run perfectly if I call it manually
Suppose I have a script that does a lot of stuff, and doesn't work
I have a python script which calls a lot of shell functions. The script
My problem is: I have a perl script which uses lot of memory (expected
I have a batch script I run before our performance tests that does some
I have script which allows to display Bing search results. I can call for
i have a script which is for virtual keyboard, i am facing some problem

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.