logo
Tags down

shadow

WebRequests are slow (taking 4 seconds) how do I speed them up?


By : Shubh
Date : October 15 2020, 11:12 PM
will help you I'm doing a web request that is too slow. It takes around 3.2 seconds to GetResponseStream() and .8 seconds to ReadToEnd() , The line
code :


Share : facebook icon twitter icon

Two-join query is taking 540 seconds to run - how can I speed this up?


By : Masedri
Date : March 29 2020, 07:55 AM
With these it helps A particular query is taking a very long time to run, around 540 seconds (yes, 9 minutes!). This is causing load spikes. , Try placing a simple (non-composite) index on tab2.element_id.

Log Slow Pages Taking Longer Than [n] Seconds In ColdFusion with Details


By : Andybluey
Date : March 29 2020, 07:55 AM
seems to work fine You can easily add some logging to your application for any requests that take longer than 10 seconds.
In onRequestStart():
code :
    request.startTime = getTickCount();
    request.endTime = getTickCount();

    if (request.endTime - request.startTime > 10000){
        writeLog(cgi.QUERY_STRING);
    }

how to handle 10 webrequests with Task.Any when the bandwhich is too slow


By : Rakshit_Dx
Date : March 29 2020, 07:55 AM
will help you I'm querying asynchronously 10 webrequests using httpClient.GetAsync and I'm using Task.Any to process data as soon as one of the 10 request finished downloading , You could move this inside your loop:
code :
int tasksToRunAtOnce = 3;
var quotesTasks = new List<Task<IEnumerable<Quote>>(); 
for(int i=0; i<10;i++)
{
     quotesTasks.Add(GetQuotesAsync(i)); 

     if (i < tasksToRunAtOnce - 1)
         continue;

     var quotesFinished = await Task.WhenAny(quotesTasks);
     quotesTasks.Remove(quotesFinished);

     // process data for quotesTasks
     // update the UI
}

while(quoteTasks.Any())
{
     var quotesFinished = await Task.WhenAny(quotesTasks);
     quotesTasks.Remove(quotesFinished);

     // process data for quotesTasks
     // update the UI
}

C# Speed up parallel webrequests using async


By : Edwin Tan
Date : March 29 2020, 07:55 AM
wish helps you Converting the CallRequests method to an async is really just a case of switching the sync method calls for async ones with the await keyword and changing the method signature to return Task.
Something like this:
code :
public static async Task CallRequestsAsync(string data1, string data2)
{
    var cookie = new CookieContainer();
    var postData = Parameters[23] + data1 +
                    Parameters[24] + data2;

    HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(Parameters[25]);
    getRequest.Accept = Parameters[26];
    getRequest.KeepAlive = true;
    getRequest.Referer = Parameters[27];
    getRequest.CookieContainer = cookie;
    getRequest.UserAgent = Parameters[28];
    getRequest.Method = WebRequestMethods.Http.Post;
    getRequest.AllowWriteStreamBuffering = true;
    getRequest.ProtocolVersion = HttpVersion.Version10;
    getRequest.AllowAutoRedirect = false;
    getRequest.ContentType = Parameters[29];
    getRequest.ReadWriteTimeout = 5000;
    getRequest.Timeout = 5000;
    getRequest.Proxy = null;

    byte[] byteArray = Encoding.ASCII.GetBytes(postData);
    getRequest.ContentLength = byteArray.Length;
    Stream newStream =await getRequest.GetRequestStreamAsync(); //open connection
    await newStream.WriteAsync(byteArray, 0, byteArray.Length); // Send the data.
    newStream.Close();

    HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse();

    if (getResponse.Headers["Location"] == Parameters[30])
    {
        //These are simple get requests to retrieve the source code using the same format as above.
        //I need to preserve the cookie
        GetRequets(data1, data2, Parameters[31], Parameters[13], cookie);
        GetRequets(data1, data2, Parameters[32], Parameters[15], cookie);
    }
}
var tasks = Enumerable.Range(0, maxsize).Select(index => CallRequestsAsync(data1, data2));
Task.WaitAll(tasks.ToArray());
var actionBlock = new ActionBlock<int>(async index =>
{
    await CallRequestsAsync(data1, data2);
}, new ExecutionDataflowBlockOptions
{
    MaxDegreeOfParallelism = 30,
    BoundedCapacity = 100,
});
for (int i=0; i <= maxsize; i++)
{
    actionBlock.Post(i); // or await actionBlock.SendAsync(i) if calling method is also async
}

actionBlock.Complete();
actionBlock.Completion.Wait(); // or await actionBlock.Completion if calling method is also async

cURL on DreamHost Slow taking ~20 seconds


By : photon
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Adding a curl_getinfo after the curl_exec showed that the connect_time was very slow.
Related Posts Related Posts :
  • How can I get back a previously created Excel ListObject?
  • What API can be used to read OAB Files?
  • In linq to entity, how to retrieve objects matching a list of conditions without looping?
  • RESTful web service in C# code
  • C#, Process.Start hide?
  • Multi resolution
  • Alternatives for Crystal Report
  • Lucene.NET, StandardAnalyzer, stopwords and thread-safety
  • How to implement CCAvenue payment gateway option
  • Silverlight and WCF: NotFound error!
  • C# How can I get a list of country codes?
  • Intellisense - Javascript in a string
  • How to change the opacity value of a 3D object
  • Assembly.ReflectionOnlyLoadFrom not working
  • C# Audio - How to time stretch (different tempo, same pitch)
  • Getting certain lines of text c#
  • Can we display Hyperlink from Javascript alert on ASP.NET Page?
  • Can you see programmatically how much amperage a USB device is requesting in windows?
  • What is a way to do a Generic Repository with Entity Framework 4.0 where I have function imports?
  • C# How to determine if a date is within 180 days of now
  • Programmatically hiding properties in a PropertyGrid
  • How do I get a list of fields returned by an OdbcDataReader?
  • ASP.Net Creating Server Side Posting to external website with redirect
  • Adding a tool bar to a web page
  • Convert Audio file into MP3 format using C#
  • Check if a windows service is running?
  • Assembly re-direction in .NET
  • Parse and filter javascript array
  • How to handle a generic dictionary whose types are unknown and don't matter?
  • Distribute images with C# Setup project
  • Is there a way to publish rdl reports programmatically with C#?
  • How to call base.base.method()?
  • How to install Emgu CV wrapper?
  • Interview question - c#
  • .NET Remoting client config creates local object, not remote
  • Is there a possibility to differ virtual printer from physical one?
  • Print barcode which has high scan rate
  • Query string value having "&"
  • Which is best for perfomance?
  • Can we make overloaded controller method in ASP .NET MVC
  • Nested loop in StringTemplate
  • How to get SSID and RSSI for Win7 using C#
  • Send messages to applications on the network (.Net)
  • Detect and prevent/delay windows mobile power off
  • How X509 Certificate renewal does not impact the code?
  • Silverlight: How to make my custom control act like a button
  • C# basic Dictionary Ordering Just need to clear an error
  • Common c# idioms including coalesce ?? operator
  • Why Does Thread.CurrentThread.CurrentCulture Change between Page Rendering and HttpModule.PostRequestHandlerExecute?
  • COM Exception 0x8004005
  • How do I show a message box from inside a class in a class library?
  • LINQ Distinct Query
  • Issue with number guessing game c#
  • Usage of a using statement
  • Building a forms system using DDD
  • How can I programmatically tell in C# if an unmanaged lib is x86 or x64?
  • How do I get an Excel range using row and column numbers in VSTO / C#?
  • .NET 4.0 Memory Mapped Files Performance
  • db4o Indexing problem - Not Working? Poor performance?
  • Realtime Console Output Redirection using Process
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org