473,398 Members | 2,165 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,398 software developers and data experts.

Monitoring asp.net async calls

Hi,
I implemented asynchronous calls to a web resource (using HttpWebRequest)
from asp.net 2.0.
The request it's made asyncronously (I see that beginGetResponse returns
immediately).
The number of worker thread and completionPortThreads are over 300.
Making 200 calls I see that 100 are queued.
There's a counter telling how much async calls are handled?
How can I raise the number of request handled?

Thanks in advance for your help

--
Carlo Folini
Feb 1 '07 #1
7 5046
the default settings only allow 2 concurrent connections to a web server
(proper net-etiquette). you need to bump these up. also iis has a max
number of open connections (MaxConnections), you need to bump this up.
also network driver has a limit (MaxUserPort). you will need to bump
this up.
-- bruce (sqlwork.com)


Carlo Folini wrote:
Hi,
I implemented asynchronous calls to a web resource (using HttpWebRequest)
from asp.net 2.0.
The request it's made asyncronously (I see that beginGetResponse returns
immediately).
The number of worker thread and completionPortThreads are over 300.
Making 200 calls I see that 100 are queued.
There's a counter telling how much async calls are handled?
How can I raise the number of request handled?

Thanks in advance for your help
Feb 1 '07 #2
Hello Carlo,

For your scenario, if you're using the "BeginGetResponse" to send http
request asynchronously at client-side, that means the client-side http
request calling is under asynchronous mode. At server-side, the ASP.NET
runtime engine will still treat each comming requests(from your
asynchronous client) as normal requests and process them synchronously.
Therefore, you can still use those standard performance counters to trace
the requests being processed. e.g.

==============================
Requests Executing
The number of requests currently executing.

Requests Failed
The total number of failed requests. Any status codes greater than or equal
to 400 will increment this counter. Requests that cause a 401 status code
increment this counter and the Requests Not Authorized counter. Requests
that cause a 404 or 414 status code increment this counter and the Requests
Not Found counter.

Requests Succeeded
The number of requests that executed successfully (status code 200).
===============================

You can find more ASP.NET specfiic performance counters in the following
reference:

#Performance Counters for ASP.NET
http://msdn2.microsoft.com/en-us/lib...92(VS.71).aspx

BTW, are you performing some performance test against your ASP.NET
application? As Bruce has mentioned, by default each .net client has a
maxconnection limit(2) to given remote site(request from local machine
doesn't have this limitation). If your client app is sending request to
remote machine, you need to take care of this:

http://msdn2.microsoft.com/en-us/lib...ion.connection
managementelement.maxconnection.aspx

Also, for ASP.NET server-side threading, since the <processModel>'s
"maxWorkerThreads" and "maxIoThreads" limit the concurrent threads of each
ASP.NET worker process, you can monitor your server machine's CPU
utilization. If the CPU utlization is still low and there are lots of
queued requests, that means you can still enlarge the max worker/io threads
number to improve your application's throughput.

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 2 '07 #3
Hi Bruce hi Steven,
in my scenario the client is an ASP.NEt 2.0 aspx page and the server is a
SOAP toolkit isapi.
In my aspx page I'm creating the soap payload 'manually' and send it via
HttpWebRequest.
I'm stress testing this solution.
The IIS 6 serving aspx page under load takes 40% of CPU so I have plenty of
room to augment the number of concurrent requests.

I tweaked all the parameters you told me.
My question is about monitoring the asynchronous behavior of the aspx page.
When the aspx page send the request to the ws the processing is stopped and
put back in a IIS queue.
Is it this queue the same that handles the 'normal' requests? (i think it's
a different one? I call it 'async queue' to differentiate from the IIS normal
request queue)
Is there some perf counter to monitor how much request are inthe 'async
queue'?

I'm also calling different ws that behaves differently in terms of
performance (sometimes a subsystem gets slow). I need to separate the request
for the various subsystem (i use connectiongroups to use different
connections).
In this scenario if a subsystem gets slow the request to the corresponding
ws remains queued in the 'async queue'. The IIS queue is free to serve the
other requests or the request limit cause the 'Server Too Busy' error?

--
Carlo Folini
"Steven Cheng[MSFT]" wrote:
Hello Carlo,

For your scenario, if you're using the "BeginGetResponse" to send http
request asynchronously at client-side, that means the client-side http
request calling is under asynchronous mode. At server-side, the ASP.NET
runtime engine will still treat each comming requests(from your
asynchronous client) as normal requests and process them synchronously.
Therefore, you can still use those standard performance counters to trace
the requests being processed. e.g.

==============================
Requests Executing
The number of requests currently executing.

Requests Failed
The total number of failed requests. Any status codes greater than or equal
to 400 will increment this counter. Requests that cause a 401 status code
increment this counter and the Requests Not Authorized counter. Requests
that cause a 404 or 414 status code increment this counter and the Requests
Not Found counter.

Requests Succeeded
The number of requests that executed successfully (status code 200).
===============================

You can find more ASP.NET specfiic performance counters in the following
reference:

#Performance Counters for ASP.NET
http://msdn2.microsoft.com/en-us/lib...92(VS.71).aspx

BTW, are you performing some performance test against your ASP.NET
application? As Bruce has mentioned, by default each .net client has a
maxconnection limit(2) to given remote site(request from local machine
doesn't have this limitation). If your client app is sending request to
remote machine, you need to take care of this:

http://msdn2.microsoft.com/en-us/lib...ion.connection
managementelement.maxconnection.aspx

Also, for ASP.NET server-side threading, since the <processModel>'s
"maxWorkerThreads" and "maxIoThreads" limit the concurrent threads of each
ASP.NET worker process, you can monitor your server machine's CPU
utilization. If the CPU utlization is still low and there are lots of
queued requests, that means you can still enlarge the max worker/io threads
number to improve your application's throughput.

Hope this helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 2 '07 #4
Thanks for your reply Carlo,

Now we got that your httpwebrequests call(asynchronous) are actually made
in the client ASP.NET web application. Yes, such asynchronous call will
significantly affect the ASP.NET runtime's workerthreads and application
throughput.

As you mentioned that you use HttpWebRequest.BeginGetResponse to make
asynchrous method call, then after the call, have you block the thread to
wait for the response or just simply ignore the response(let it be a
one-way style method call)? If you doesn't block it and wait for the
response(call EndGetResponse), the ASP.NET main workerthread will run as
normal and be returned to the threadpool after the page lifecycle end.
Also, asynchronous call such as HttpWebRequest.BeginGetResponse(or any
other BeginXXX like call) will use threads from .NET managed thread pool.

Therefore, for your scenario, there are two operations that will consume
..net CLR thread-pool threads:

** the ASP.NET requests which need thread-pool thread to handle it

** your httpwebrequest's asynchronous call is running in thread-pool
thread.

Thus, if your maxWorkerThread and maxIOThread is not configured to the
proper value, you may encounter thoughput bottleneck.

Actually, ASP.NET runtime/.NET runtime doesn't care whether your ASP.NET
page is using asynchronous call, from its viewpoint, it only care whether
your task need a thread-pool thread to process. If so, it pickup a thread
from pool to process it. So what you need to take care is the currently
available thread-pool threads. This s quite easy to get through the
ThreadPool class, and .net doesn't add built-in counter for this, you can
simply create a custom counter as below:

#How To: Monitor the ASP.NET Thread Pool Using Custom Counters
http://msdn2.microsoft.com/en-gb/library/ms979194.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 5 '07 #5
Hi Steven,
I didn't understand well what you are saying.

What I do on my aspx page is depicted in this post from Fritz Onion:
http://pluralsight.com/blogs/fritz/a...0/19/2892.aspx

I think that asp.net is aware of my async call.
When the "async point" is reached the aspx request is put back in the queue.
When the response from the ws come back the aspx request is picked up again
and handled by a (maybe different) worker thread to complete the rendering
phase.

Do you agree?

What it's not clear to me is where this aspx request is sent. Is it put back
in the http.sys queue or is the I/O thread pool managed by the .net runtime?

When I undertand this, I would like to know if there's a counter that counts
those async calls

--
Carlo Folini
"Steven Cheng[MSFT]" wrote:
Thanks for your reply Carlo,

Now we got that your httpwebrequests call(asynchronous) are actually made
in the client ASP.NET web application. Yes, such asynchronous call will
significantly affect the ASP.NET runtime's workerthreads and application
throughput.

As you mentioned that you use HttpWebRequest.BeginGetResponse to make
asynchrous method call, then after the call, have you block the thread to
wait for the response or just simply ignore the response(let it be a
one-way style method call)? If you doesn't block it and wait for the
response(call EndGetResponse), the ASP.NET main workerthread will run as
normal and be returned to the threadpool after the page lifecycle end.
Also, asynchronous call such as HttpWebRequest.BeginGetResponse(or any
other BeginXXX like call) will use threads from .NET managed thread pool.

Therefore, for your scenario, there are two operations that will consume
.net CLR thread-pool threads:

** the ASP.NET requests which need thread-pool thread to handle it

** your httpwebrequest's asynchronous call is running in thread-pool
thread.

Thus, if your maxWorkerThread and maxIOThread is not configured to the
proper value, you may encounter thoughput bottleneck.

Actually, ASP.NET runtime/.NET runtime doesn't care whether your ASP.NET
page is using asynchronous call, from its viewpoint, it only care whether
your task need a thread-pool thread to process. If so, it pickup a thread
from pool to process it. So what you need to take care is the currently
available thread-pool threads. This s quite easy to get through the
ThreadPool class, and .net doesn't add built-in counter for this, you can
simply create a custom counter as below:

#How To: Monitor the ASP.NET Thread Pool Using Custom Counters
http://msdn2.microsoft.com/en-gb/library/ms979194.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 5 '07 #6
Thanks for your reply Carlo,

Well, now I've got your actual scenario. Previously, I misunderstood your
"async page", as you mentioned "BeginGetResponse", I assumed that you're
using normal page request to call the HttpWebRequest.BeginGetResponse to
perform asynchronous operation.

For Async page you used, yes, you're right, when the async execution
begin(after PreRender event and before PreRenderComplete event), the worker
thread(for processing the page) is release and put back to managed
thread-pool. However, here in the async execution, you use Httpwebrequest
to perform another asynchronous operation, and based on my experience, such
asynchronous httpwebrequest call will also consume .NET threadpool thread.
I've checked the reflectored code of HttpWebRequest.BeginGetResponse, it
will check the current ThreadPool's available workerthreads and IO threads.
Therefore, what I would suggest you do is create a custom counter which
use the " ThreadPool.GetAvailableThreads" method to monitor the current
available worker threads and IO thread in your ASP.NET application
process's CLR thread pool(as the following articles mentioned). This is the
most important statistics that will determine your ASP.NET application's
throughput (if there is no available threadpool thread, all the sequential
comming requests will be queued).

#How To: Monitor the ASP.NET Thread Pool Using Custom Counters
http://msdn2.microsoft.com/en-gb/library/ms979194.aspx

If you find that there is no significant improvement after using
asynchronous page execution, I think that means the WebRequest call will
also consume thread-pool thread so that using asynchronous execution won't
help much here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.


Feb 6 '07 #7
Hello Carlo,

Have you got any further idea or progress on this issue? As mentioned in
the previous message, the ThreadPool statistics are the primary flag of
your web applciation's throughput status. If you still haven't been able to
get it work or the performance monitor result doesn't quite reflect the
application's real status, there may has something else that impact the
performance. If you need to further thorough troubleshooting, I would
suggest you consider contact CSS for continual support. Please feel free
to let me know if there is still anything we can help.

http://msdn.microsoft.com/subscripti...t/default.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 8 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Vanessa | last post by:
I have a question regarding async mode for calling Microsoft.XMLHTTP object. Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work again after half an hour or so without doing...
6
by: Amy L. | last post by:
I am working on a project where I will have a ton of async DNS calls in a console application. I would like to process the results of the Aync calls on the same thread that made the async call. ...
1
by: Claire | last post by:
We've had problems with a third party dll that communicates over a network and would like to be able to monitor each function call. We thought of using a 2nd thread which would log an alert if the...
11
by: ryan | last post by:
Hi, I've omitted a large chunk of the code for clarity but the loop below is how I'm calling a delegate function asynchronously. After I start the each call I'm incrementing a counter and then...
1
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
7
by: Shak | last post by:
Hi all, I'm trying to write a thread-safe async method to send a message of the form (type)(contents). My model is as follows: private void SendMessage(int type, string message) { //lets...
0
by: Kursat | last post by:
Hi, We have a network monitoring application wich generates some messages at unpredictable times. Our Windows Forms based client applications grab these messages and show them our clients. We...
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.