[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework

WebRequest Performance Overhead

sternr

10/16/2008 7:14:00 AM

Hey,
I use HttpWebRequest to poll data from a local web page using the GET
mechanism, but no matter how fast or small my request is, the time it
takes to create and get the response is always at least 200-ms even
from my local (localhost) development server!!!

Here's a code sample:

string fullUrl = "http://localhost/getData?id=2";
HttpWebRequest request = HttpWebRequest.Create(fullUrl) as
HttpWebRequest;
request.Method = "GET";
WebResponse res = request.GetResponse();
StreamReader reader = new StreamReader(res.GetResponseStream());
string result = reader.ReadToEnd();
reader.Close();
reader.Dispose();
res.Close();
return result;

I'm using .Net 3.5, and the webserver is based on Python CGI libraries
(GAE), and according to its console the processing time for each
request takes a maximum of 30 ms.

Are there any performance tweaks necessary for the HttpWebRequest?
Why is the overhead that big?

Any help?

Thanks ahead

--sternr

1 Answer

Jason Keats

10/16/2008 9:30:00 AM

0

sternr wrote:
> Hey,
> I use HttpWebRequest to poll data from a local web page using the GET
> mechanism, but no matter how fast or small my request is, the time it
> takes to create and get the response is always at least 200-ms even
> from my local (localhost) development server!!!
>
> Here's a code sample:
>
> string fullUrl = "http://localhost/getData?id=2";
> HttpWebRequest request = HttpWebRequest.Create(fullUrl) as
> HttpWebRequest;
> request.Method = "GET";
> WebResponse res = request.GetResponse();
> StreamReader reader = new StreamReader(res.GetResponseStream());
> string result = reader.ReadToEnd();
> reader.Close();
> reader.Dispose();
> res.Close();
> return result;
>
> I'm using .Net 3.5, and the webserver is based on Python CGI libraries
> (GAE), and according to its console the processing time for each
> request takes a maximum of 30 ms.
>
> Are there any performance tweaks necessary for the HttpWebRequest?
> Why is the overhead that big?
>
> Any help?
>
> Thanks ahead
>
> --sternr
>

Assuming the above is running on Windows, that you're using IIS, and
that JIT compilation (and Python script interpretation) have been
eliminated as part of the problem, then I would guess that the use of
CGI is the main reason for the overhead. Using FastCGI, instead, should
help.