Asynchronous Pages:
Objective:
Improves the Scalability of website & Efficient design for time consuming process. Note: It should not be confused with Asynchronous request from Client side.AJAX used to improve the end user interface,where as Asynchronous pages handled in server side to provide efficient way of handling the request. Its particularly used in webpages that includes time consuming code that queries database. Problem:
.Net maintains a pool of threads to handle the incoming requests, when a request is received asp.net assigns a thread from its pool to process the request.Let’s say we have a code that involves significant waiting time, so if all available threads were assigned to the incoming requests & its executing the time consuming code. The additional requests will be queued, if a limit is reached we will be getting “503 Server Unavailable errors”. The possible waiting scenarios are:Large data from slow DBRead a file from Remote locationWeb service object….. Resolution:
If we create Asynchronous pages with time consuming code executing in seperate thread pool which free up the ASP.net thread pool to allow it for processing other requests.Once separate thread completes its work Asp.net assigns an available thread to complete the operation. This is not going to improve the performance by any way, tricky way to handle all requests effectively making your application scalable. Sample: Step 1: <%@ Page Async=”true” …%>IHttpAsyncHandler will be implemented instead of IHttpHandler Step 2:AddOnPreRenderCompleteAsync(New BeginEventHandler _(Addressof BeginTask), New EndEventHandler (Addressof EndTask)) This will be called when the page loads, BeginEventHandler - Launches Asynchronous task.EndEventHandler - Handles callback from Asynchronous task.BeginTask & EndTask are the methods assigned to the above delegates.
The page lifecycle will be as follows:
Init Load Controlevents Prerender BeginTask()- Asynchonous task End Task() PreRenderComplete Savestate Render Color:Initial Asp.net threadAnother asp.net thread Thread outside of asp.net thread pool.
Revision number 2, Saturday, October 30, 2010 2:41:15 PM by codenickel
You must Login to comment.
|
Thu, Jun 2, 2011 7:54 AM
by giridhara
|
How to make customErrorsmode =off working in Async enabeld pagees? Thanks, Giri
|
|
Tue, Jun 7, 2011 2:47 AM
by yrb.yogi
|
Not Getting any point except implementing the IHttpAyncHandler & call up methods of this interface.
Provide more detail with at lease example which help lots.
|
Revision #15
Sat, Feb 5, 2011 4:50 PM
by
|
AJAX
Asynchronous JavaScript and XML - It's Ajax and it's everywhere. Start at the ASP.NET Ajax site and work from there...there's a ton of resources at your disposal. Ajax Showcase - Check out some of the great sites that been built using Ajax. Ajax
|