![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |