By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,850 Members | 967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,850 IT Pros & Developers. It's quick & easy.

Making 10 POST requests from ASP.NET asynchronously

P: n/a
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I have
been working on this problem for a few days now, and I seem to keep running
up against IIS limitations. Basically here's the process as it works now
(synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
....
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
....
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in any
order asynchronously. The problem is that each request can take up to 800
ms to respond, times 10 synchronous requests = 8 seconds... way too long...
The idea is that if I can send all ten requests asynchronously, the results
should start being returned much faster.

Is this even possible with ASP.NET and IIS?
Nov 14 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Have you looked up threading yet?

http://msdn2.microsoft.com/en-us/lib...hreadpool.aspx

http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

--
--
Regards

John Timney (MVP)
VISIT MY WEBSITE:
http://www.johntimney.com
http://www.johntimney.com/blog
"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here's the process as it
works now (synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in
any order asynchronously. The problem is that each request can take up to
800 ms to respond, times 10 synchronous requests = 8 seconds... way too
long... The idea is that if I can send all ten requests asynchronously,
the results should start being returned much faster.

Is this even possible with ASP.NET and IIS?

Nov 14 '06 #2

P: n/a
If 2.0 you could also try the Async methods of the WebClient object...

AFAIK if those requests are not seen by the external server as belonging to
the same session (which is likely the case unless you do something special),
it should work. I don't think you'll have this limitation on your own server
(as your server act as a client to the external web site).

--
Patrice

"Mike C#" <xy*@xyz.coma écrit dans le message de news:
y6*************@newsfe11.lga...
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here's the process as it
works now (synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response

What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request

The above is just an example - the responses should be able to arrive in
any order asynchronously. The problem is that each request can take up to
800 ms to respond, times 10 synchronous requests = 8 seconds... way too
long... The idea is that if I can send all ten requests asynchronously,
the results should start being returned much faster.

Is this even possible with ASP.NET and IIS?

Nov 14 '06 #3

P: n/a
"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here's the process as it
works now (synchronously):
It is an IIS limit, as you say. It has nothing to do with ASP.NET.

The only ASP.NET relation is that you probably aren't calling Dispose on
your proxy objects, so you're not closing the connections.

John
Nov 14 '06 #4

P: n/a
Thus wrote Mike C#,
Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously?
I have been working on this problem for a few days now, and I seem to
keep running up against IIS limitations. Basically here's the process
as it works now (synchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com receives response
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives response
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives response
What I would like to happen is (asynchronously):

Person visits mywebsite.com and fills out a form
mywebsite.com POSTs one request to providerwebsite.com
mywebsite.com POSTs a second request to providerwebsite.com
mywebsite.com receives a response to first request
...
mywebsite.com POSTs a tenth request to providerwebsite.com
mywebsite.com receives a response to ninth request
mywebsite.com receives a response to tenth request
The above is just an example - the responses should be able to arrive
in any order asynchronously. The problem is that each request can
take up to 800 ms to respond, times 10 synchronous requests = 8
seconds... way too long... The idea is that if I can send all ten
requests asynchronously, the results should start being returned much
faster.
That is not likely -- the processing time for an individual request does
not improve by a client-side optimization. If resource contention comes into
play, it may even get worse. Yet, the overall processing time for the page
that kicks off those 10 requests should be reduced unless you have a severe
bottleneck in your system (such as a deadlock).
Is this even possible with ASP.NET and IIS?
The 10 connections limitation only applies for non-server Windows versions.
It is not an IIS issue per se.

For an asynchronous implementation of your web requests, look at asynchronous
pages, a feature introduced in ASP.NET 2.0: http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Nov 14 '06 #5

P: n/a

"John Timney (MVP)" <x_****@timney.eclipse.co.ukwrote in message
news:fY********************@eclipse.net.uk...
Have you looked up threading yet?
Not only did I look it up, I implemented it two different ways and both
times it crapped out with an error code 403, subcode 9.

Nov 15 '06 #6

P: n/a

"Patrice" <sc****@chez.comwrote in message
news:em****************@TK2MSFTNGP04.phx.gbl...
If 2.0 you could also try the Async methods of the WebClient object...

AFAIK if those requests are not seen by the external server as belonging
to the same session (which is likely the case unless you do something
special), it should work. I don't think you'll have this limitation on
your own server (as your server act as a client to the external web site).
1.1. Error 403.9 after 4 async requests. Thanks.
Nov 15 '06 #7

P: n/a
Thus sayeth Joerg Jooss,
That is not likely -- the processing time for an individual request does
not improve by a client-side optimization. If resource contention comes
into play, it may even get worse. Yet, the overall processing time for the
page that kicks off those 10 requests should be reduced unless you have a
severe bottleneck in your system (such as a deadlock).
I'm not trying to reduce the processing time for individual requests. That
is a constant I have no control over, like the speed of light. I am trying
to reduce the load time of my page by making 10 requests asynchronously
instead of 1 request...wait...1 response...1 request...wait...etc.
synchronously.
>Is this even possible with ASP.NET and IIS?

The 10 connections limitation only applies for non-server Windows
versions. It is not an IIS issue per se.
I ran into this particular problem on Windows Server 2003. I'm told by a
co-worker that there are some limitations built into the HTTP standard which
may be the root of my problem. He also suggested there is some registry
setting to get around it, but he couldn't tell me where he found this
information, so I'll keep Googling it.
For an asynchronous implementation of your web requests, look at
asynchronous pages, a feature introduced in ASP.NET 2.0:
http://msdn.microsoft.com/msdnmag/is...10/WickedCode/
2.0 is not an option right now. Thanks.
Nov 16 '06 #8

P: n/a

"John Saunders" <john.saunders at trizetto.comwrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...
>Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here's the process as it
works now (synchronously):

It is an IIS limit, as you say. It has nothing to do with ASP.NET.

The only ASP.NET relation is that you probably aren't calling Dispose on
your proxy objects, so you're not closing the connections.

John
I'm properly disposing of everything, so it falls back to IIS? Thanks.
Nov 16 '06 #9

P: n/a
It seems like a few of us are jumping to conclusions without actually
seeing how you are attempting to enqueue the calls for async
invocation.
Mike C# wrote:
Thus sayeth Joerg Jooss,
That is not likely -- the processing time for an individual request does
not improve by a client-side optimization. If resource contention comes
into play, it may even get worse. Yet, the overall processing time for the
page that kicks off those 10 requests should be reduced unless you have a
severe bottleneck in your system (such as a deadlock).

I'm not trying to reduce the processing time for individual requests. That
is a constant I have no control over, like the speed of light. I am trying
to reduce the load time of my page by making 10 requests asynchronously
instead of 1 request...wait...1 response...1 request...wait...etc.
synchronously.
Is this even possible with ASP.NET and IIS?
The 10 connections limitation only applies for non-server Windows
versions. It is not an IIS issue per se.

I ran into this particular problem on Windows Server 2003. I'm told by a
co-worker that there are some limitations built into the HTTP standard which
may be the root of my problem. He also suggested there is some registry
setting to get around it, but he couldn't tell me where he found this
information, so I'll keep Googling it.
For an asynchronous implementation of your web requests, look at
asynchronous pages, a feature introduced in ASP.NET 2.0:
http://msdn.microsoft.com/msdnmag/is...10/WickedCode/

2.0 is not an option right now. Thanks.
Nov 16 '06 #10

P: n/a
"Mike C#" <xy*@xyz.comwrote in message
news:8b****************@newsfe12.lga...
>
"John Saunders" <john.saunders at trizetto.comwrote in message
news:u9**************@TK2MSFTNGP03.phx.gbl...
>"Mike C#" <xy*@xyz.comwrote in message
news:y6*************@newsfe11.lga...
>>Hi all,

Is it possible to make 10 POST requests from ASP.NET asynchronously? I
have been working on this problem for a few days now, and I seem to keep
running up against IIS limitations. Basically here's the process as it
works now (synchronously):

It is an IIS limit, as you say. It has nothing to do with ASP.NET.

The only ASP.NET relation is that you probably aren't calling Dispose on
your proxy objects, so you're not closing the connections.

John

I'm properly disposing of everything, so it falls back to IIS? Thanks.
It still has nothing to do with IIS, especially not on Windows Server 2003.
IIS is not involved - the network message goes straight from HTTP.SYS into
the ASP.NET worker process (w3wp).
Nov 16 '06 #11

P: n/a
Thus wrote Mike C#,
Thus sayeth Joerg Jooss,
>That is not likely -- the processing time for an individual request
does not improve by a client-side optimization. If resource
contention comes into play, it may even get worse. Yet, the overall
processing time for the page that kicks off those 10 requests should
be reduced unless you have a severe bottleneck in your system (such
as a deadlock).
I'm not trying to reduce the processing time for individual requests.
That is a constant I have no control over, like the speed of light. I
am trying to reduce the load time of my page by making 10 requests
asynchronously instead of 1 request...wait...1 response...1
request...wait...etc. synchronously.
>>Is this even possible with ASP.NET and IIS?
The 10 connections limitation only applies for non-server Windows
versions. It is not an IIS issue per se.
I ran into this particular problem on Windows Server 2003. I'm told
by a co-worker that there are some limitations built into the HTTP
standard which may be the root of my problem. He also suggested there
is some registry setting to get around it, but he couldn't tell me
where he found this information, so I'll keep Googling it.
Ah, silly me. Forgot that all these requests access the same site.

Yes, HTTP 1.1 recommends to limit the number of persistent and non-persistent
connections to a site to 2 and 4 respectively. In ASP.NET, this value is
10 by default.

You can override this value using ServicePointManager.DefaultPersistentConnectionLim it
or in config:

<configuration>
<system.net>
<connectionManagement>
<add address = "*" maxconnection = "2" />
</connectionManagement>
</system.net>
</configuration>

BTW, the registry keys you're looking for have been described in microsoft.public.dotnet.languages.csharp
just two days ago.

Cheers,
--
Joerg Jooss
ne********@joergjooss.de
Nov 16 '06 #12

P: n/a
Thus wrote Joerg,

[...]
Ah, silly me. Forgot that all these requests access the same site.
Geez,

make that "requests originate from the same site".

--
Joerg Jooss
ne********@joergjooss.de
Nov 16 '06 #13

P: n/a

"John Saunders" <john.saunders at trizetto.comwrote in message
news:uK**************@TK2MSFTNGP03.phx.gbl...
It still has nothing to do with IIS, especially not on Windows Server
2003. IIS is not involved - the network message goes straight from
HTTP.SYS into the ASP.NET worker process (w3wp).
I gave up on it and created a separate class that calls WinHTTP directly.
It's a lot more work, but it's fasssst.

Thanks.
Nov 17 '06 #14

P: n/a

"Joerg Jooss" <ne********@joergjooss.dewrote in message
news:94**************************@msnews.microsoft .com...
Ah, silly me. Forgot that all these requests access the same site.

Yes, HTTP 1.1 recommends to limit the number of persistent and
non-persistent connections to a site to 2 and 4 respectively. In ASP.NET,
this value is 10 by default.

You can override this value using
ServicePointManager.DefaultPersistentConnectionLim it or in config:

<configuration>
<system.net>
<connectionManagement>
<add address = "*" maxconnection = "2" />
</connectionManagement>
</system.net>
</configuration>

BTW, the registry keys you're looking for have been described in
microsoft.public.dotnet.languages.csharp just two days ago.
Thanks Joerg. I went ahead and wrote a class to access WinHttp functions
directly. It's hella fast, and works great.
Nov 17 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.