473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Making 10 POST requests from ASP.NET asynchronously

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
14 2504
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
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
"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
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

"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

"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
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

"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
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
"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
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
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

"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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Fuzzyman | last post by:
In a nutshell - the question I'm asking is, how do I make a socket conenction go via a proxy server ? All our internet traffic has to go through a proxy-server at location 'dav-serv:8080' and I...
1
by: Brad | last post by:
A long-time JScript/IE programmer friend of mine shared a technique with me recently that puzzles me. He has a series of functions that perform POSTs, with each function returning a dummy value. ...
2
by: Christopher Benson-Manica | last post by:
Is there a more crossbrowser-friendly means to make HTTP requests using script than the XML methods? I need to do this in IE 5.0, and it doesn't seem to have the ActiveX control that can make XML...
2
by: Robert Oschler | last post by:
I am working on a PHP 4 app that interacts with an external authorization server. The external server does "third-party" authorization of users. So I do the following: 1) Each of my PHP scripts...
3
by: Yong | last post by:
I get a general network error when I try to make asynchronously call ExecuteNonQuery on long sql statements that run in parallel. Here is the background info on what I'm trying to accomplish: I...
34
by: Asfand Yar Qazi | last post by:
Hi, I'm creating a library where several classes are intertwined rather tightly. I'm thinking of making them all use pimpls, so that these circular dependancies can be avoided easily, and I'm...
4
by: rzimerman | last post by:
I'm hoping to write a program that will read any number of urls from stdin (1 per line), download them, and process them. So far my script (below) works well for small numbers of urls. However, it...
14
by: FMDeveloper | last post by:
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like: <code>...
3
by: Phillip B Oldham | last post by:
In my attempt to learn python in a weekend, I've fallen foul at line 10 of my second scripting attempt. Basically I'm writing a simple spider, but currently I'm unable to find any documentation on...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.