Improve the Scalability of website and 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. It’s particularly used in web pages that include time
consuming code that queries database.
.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 and its executing the time consuming code. The additional
requests will be queued; if a limit is reached we will be getting “503 Server
The possible waiting scenarios are: Large data
from slow DBRead a file from Remote locationWeb service object…
If we create Asynchronous pages with time
consuming code executing in a separate thread pool which will free up the ASP.NET
thread pool to allow it for processing other requests. Once a 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.
<%@ Page Async=”true” …%>
be implemented instead of
_(Addressof BeginTask), New EndEventHandler (Addressof EndTask))
This will be called when the page loads.
BeginEventHandler - Launches
EndEventHandler - Handles
callback from Asynchronous task.
EndTask are the methods assigned to the above delegates.
The page lifecycle will be as follows:
- End Task()
- Initial ASP.NET thread
- Another ASP.NET thread
- Thread outside of ASP.NET thread pool