HighTechTalks DotNet Forums  

HttpWebRequest not performing?

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss HttpWebRequest not performing? in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
PwsIQ
 
Posts: n/a

Default HttpWebRequest not performing? - 11-26-2007 , 05:10 PM






Hoping someone can provide some insight or alternatives on this issue. We
make heavy use of a 3rd party data provider to obtain quote data for a
commercial web application. We obtain the data via the function shown below
basically using HttpWebRequest.

We are having performance issues and are trying to isolate the problem.
About 10% of the time, this call can take up to 15 to 20 seconds. We have
set a timeout value of 3 seconds - any longer is unacceptable.

We have ruled out network latency by kicking of tracerts to the destination
at times that the request is slow. Another possibility is that the provider
itself is having issues serving the data. We have doubts about that as well
becuase we have been able to take the request URL, paste it into a browser
and view the resulting xml result in a sub-second timeframe while executing
the same call below in code will take 15 seconds to return.

Has anyone else had issues with this and have any suggestions for how to 1)
diagnose where the problem is 2) improve the code, or 3) rewrite it using
something else that might be faster.

Much appreciated.

Sample request URL:
http://208.47.215.190/predictws/detailed_quote.html

Function Call:
public bool GetQuote(string requestURL, ref string quoteXML)
{
bool success = true;
PredictWallStreet.Common.ErrorHandler handler;

System.Diagnostics.Stopwatch stopwatch = new
System.Diagnostics.Stopwatch();

stopwatch.Start();

try
{
HttpWebRequest request =
(HttpWebRequest)(WebRequest.Create(requestURL));

request.Timeout = QuoteTimeOut;

HttpWebResponse response =
(HttpWebResponse)(request.GetResponse());

StreamReader streamReader = new
StreamReader(response.GetResponseStream());

quoteXML = streamReader.ReadToEnd();

streamReader.Close();
response.Close();

stopwatch.Stop();
}
catch (Exception ex)
{
string errorText;
if (stopwatch.IsRunning) stopwatch.Stop();
errorText = "*Error* Generic-" + ex.Message + "-Ticks:" +
stopwatch.ElapsedTicks + "-MS:" + stopwatch.ElapsedMilliseconds;
quoteXML = errorText + quoteXML;
// Log the error
handler =
new PredictWallStreet.Common.ErrorHandler
(
new ApplicationException("Error completing
Comstock request in GetComstockQuote. Error Info:\n" + quoteXML + "\n", ex)
, HttpContext.Current.Request
);
handler.LogError();
return false;
}
--
PwsIQ
PwsIQ (AT) discussions (DOT) microsoft.com

Reply With Quote
  #2  
Old   
PwsIQ
 
Posts: n/a

Default RE: HttpWebRequest not performing? - 12-03-2007 , 04:02 PM






Is it possible that I have posted this question in an inappropriate
discussion group? If this is a managed newsgroup should I expect a response?


Thank you in advance.
--
PwsIQ
PwsIQ (AT) discussions (DOT) microsoft.com


"PwsIQ" wrote:

Quote:
Hoping someone can provide some insight or alternatives on this issue. We
make heavy use of a 3rd party data provider to obtain quote data for a
commercial web application. We obtain the data via the function shown below
basically using HttpWebRequest.

We are having performance issues and are trying to isolate the problem.
About 10% of the time, this call can take up to 15 to 20 seconds. We have
set a timeout value of 3 seconds - any longer is unacceptable.

We have ruled out network latency by kicking of tracerts to the destination
at times that the request is slow. Another possibility is that the provider
itself is having issues serving the data. We have doubts about that as well
becuase we have been able to take the request URL, paste it into a browser
and view the resulting xml result in a sub-second timeframe while executing
the same call below in code will take 15 seconds to return.

Has anyone else had issues with this and have any suggestions for how to 1)
diagnose where the problem is 2) improve the code, or 3) rewrite it using
something else that might be faster.

Much appreciated.

Sample request URL:
http://208.47.215.190/predictws/detailed_quote.html

Function Call:
public bool GetQuote(string requestURL, ref string quoteXML)
{
bool success = true;
PredictWallStreet.Common.ErrorHandler handler;

System.Diagnostics.Stopwatch stopwatch = new
System.Diagnostics.Stopwatch();

stopwatch.Start();

try
{
HttpWebRequest request =
(HttpWebRequest)(WebRequest.Create(requestURL));

request.Timeout = QuoteTimeOut;

HttpWebResponse response =
(HttpWebResponse)(request.GetResponse());

StreamReader streamReader = new
StreamReader(response.GetResponseStream());

quoteXML = streamReader.ReadToEnd();

streamReader.Close();
response.Close();

stopwatch.Stop();
}
catch (Exception ex)
{
string errorText;
if (stopwatch.IsRunning) stopwatch.Stop();
errorText = "*Error* Generic-" + ex.Message + "-Ticks:" +
stopwatch.ElapsedTicks + "-MS:" + stopwatch.ElapsedMilliseconds;
quoteXML = errorText + quoteXML;
// Log the error
handler =
new PredictWallStreet.Common.ErrorHandler
(
new ApplicationException("Error completing
Comstock request in GetComstockQuote. Error Info:\n" + quoteXML + "\n", ex)
, HttpContext.Current.Request
);
handler.LogError();
return false;
}
--
PwsIQ
PwsIQ (AT) discussions (DOT) microsoft.com

Reply With Quote
  #3  
Old   
Vadym Stetsiak
 
Posts: n/a

Default Re: HttpWebRequest not performing? - 12-04-2007 , 03:33 PM



Hello, PwsIQ!

How many connections are being made to that web server? By default
HttpWebRequest will use the connection pool consiting of 2 connections.
This value can be increased in ServicePointManager.

Also you can try to request that data manually using plain Sockets.
Or use unmanaged libraries like WinInet through P/Invoke
--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote on Mon, 26 Nov 2007 15:10:02 -0800:

P> Hoping someone can provide some insight or alternatives on this
P> issue. We make heavy use of a 3rd party data provider to obtain
P> quote data for a commercial web application. We obtain the data via
P> the function shown below basically using HttpWebRequest.

P> We are having performance issues and are trying to isolate the
P> problem.
P> About 10% of the time, this call can take up to 15 to 20 seconds. We
P> have set a timeout value of 3 seconds - any longer is unacceptable.

P> We have ruled out network latency by kicking of tracerts to the
P> destination at times that the request is slow. Another possibility
P> is that the provider itself is having issues serving the data. We
P> have doubts about that as well becuase we have been able to take the
P> request URL, paste it into a browser and view the resulting xml
P> result in a sub-second timeframe while executing the same call below
P> in code will take 15 seconds to return.

P> Has anyone else had issues with this and have any suggestions for how
P> to 1)
P> diagnose where the problem is 2) improve the code, or 3) rewrite it
P> using something else that might be faster.

P> Much appreciated.

P> Sample request URL:
P> http://208.47.215.190/predictws/detailed_quote.html

P> Function Call:
P> public bool GetQuote(string requestURL, ref string quoteXML)
P> {
P> bool success = true;
P> PredictWallStreet.Common.ErrorHandler handler;

P> System.Diagnostics.Stopwatch stopwatch = new
P> System.Diagnostics.Stopwatch();

P> stopwatch.Start();

P> try {
P> HttpWebRequest request =
P> (HttpWebRequest)(WebRequest.Create(requestURL));

P> request.Timeout = QuoteTimeOut;

P> HttpWebResponse response =
P> (HttpWebResponse)(request.GetResponse());

P> StreamReader streamReader = new
P> StreamReader(response.GetResponseStream());

P> quoteXML = streamReader.ReadToEnd();

P> streamReader.Close();
P> response.Close();

P> stopwatch.Stop();
P> }
P> catch (Exception ex)
P> {
P> string errorText;
P> if (stopwatch.IsRunning) stopwatch.Stop();
P> errorText = "*Error* Generic-" + ex.Message +
P> "-Ticks:" +
P> stopwatch.ElapsedTicks + "-MS:" + stopwatch.ElapsedMilliseconds;
P> quoteXML = errorText + quoteXML;
P> // Log the error handler =
P> new PredictWallStreet.Common.ErrorHandler
P> (
P> new ApplicationException("Error
P> completing
P> Comstock request in GetComstockQuote. Error Info:\n" + quoteXML +
P> "\n", ex)
P> , HttpContext.Current.Request
P> );
P> handler.LogError();
P> return false;
P> }
P> --
P> PwsIQ
P> PwsIQ (AT) discussions (DOT) microsoft.com




Reply With Quote
  #4  
Old   
PwsIQ
 
Posts: n/a

Default Re: HttpWebRequest not performing? - 12-04-2007 , 03:49 PM



Vadym,

We are getting about 12 requests per second to that web server. We have
already increased the size of the connection pool from 2 to 20 and have seen
no increase in performance.

Is there any way to 1) figure out why this is taking so long, or 2) optimize
it. Has anyone else seen these kinds of issues? Do we need to use sockets
to get an efficient robust implementation? And if so, why?

Regards,

Stephanie.
--
PwsIQ
PwsIQ (AT) discussions (DOT) microsoft.com


"Vadym Stetsiak" wrote:

Quote:
Hello, PwsIQ!

How many connections are being made to that web server? By default
HttpWebRequest will use the connection pool consiting of 2 connections.
This value can be increased in ServicePointManager.

Also you can try to request that data manually using plain Sockets.
Or use unmanaged libraries like WinInet through P/Invoke
--
With best regards, Vadym Stetsiak.
Blog: http://vadmyst.blogspot.com

You wrote on Mon, 26 Nov 2007 15:10:02 -0800:

P> Hoping someone can provide some insight or alternatives on this
P> issue. We make heavy use of a 3rd party data provider to obtain
P> quote data for a commercial web application. We obtain the data via
P> the function shown below basically using HttpWebRequest.

P> We are having performance issues and are trying to isolate the
P> problem.
P> About 10% of the time, this call can take up to 15 to 20 seconds. We
P> have set a timeout value of 3 seconds - any longer is unacceptable.

P> We have ruled out network latency by kicking of tracerts to the
P> destination at times that the request is slow. Another possibility
P> is that the provider itself is having issues serving the data. We
P> have doubts about that as well becuase we have been able to take the
P> request URL, paste it into a browser and view the resulting xml
P> result in a sub-second timeframe while executing the same call below
P> in code will take 15 seconds to return.

P> Has anyone else had issues with this and have any suggestions for how
P> to 1)
P> diagnose where the problem is 2) improve the code, or 3) rewrite it
P> using something else that might be faster.

P> Much appreciated.

P> Sample request URL:
P> http://208.47.215.190/predictws/detailed_quote.html

P> Function Call:
P> public bool GetQuote(string requestURL, ref string quoteXML)
P> {
P> bool success = true;
P> PredictWallStreet.Common.ErrorHandler handler;

P> System.Diagnostics.Stopwatch stopwatch = new
P> System.Diagnostics.Stopwatch();

P> stopwatch.Start();

P> try {
P> HttpWebRequest request =
P> (HttpWebRequest)(WebRequest.Create(requestURL));

P> request.Timeout = QuoteTimeOut;

P> HttpWebResponse response =
P> (HttpWebResponse)(request.GetResponse());

P> StreamReader streamReader = new
P> StreamReader(response.GetResponseStream());

P> quoteXML = streamReader.ReadToEnd();

P> streamReader.Close();
P> response.Close();

P> stopwatch.Stop();
P> }
P> catch (Exception ex)
P> {
P> string errorText;
P> if (stopwatch.IsRunning) stopwatch.Stop();
P> errorText = "*Error* Generic-" + ex.Message +
P> "-Ticks:" +
P> stopwatch.ElapsedTicks + "-MS:" + stopwatch.ElapsedMilliseconds;
P> quoteXML = errorText + quoteXML;
P> // Log the error handler =
P> new PredictWallStreet.Common.ErrorHandler
P> (
P> new ApplicationException("Error
P> completing
P> Comstock request in GetComstockQuote. Error Info:\n" + quoteXML +
P> "\n", ex)
P> , HttpContext.Current.Request
P> );
P> handler.LogError();
P> return false;
P> }
P> --
P> PwsIQ
P> PwsIQ (AT) discussions (DOT) microsoft.com





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.