I am using Fritz Onion's "Asynchrono us Pages" approach as mentioned in
the article http://msdn.microsoft.com/msdnmag/is...g/default.aspx
to increase the performance of my ASPX page.I am using the Custom
thread pool as given in the article's sample.
Implementation:
===============
In AsyncPage.aspx I inhereted AsyncPage class instead of
System.Web.UI.P age.
SyncPage.aspx is like any other Web page which inherits
System.Web.UI.P age.
Problem/Issue:
===============
When I run Application Center test (ACT) on two different environments
I am getting following test results.
Environment 1:
---------------
ACT client is running on Windows XP and Web server(where ASPX pages
are hosted) is running on Windows 2003 advanced server.
ACT is running for 5 minutes with 100 simultanious browser
connections.
Results on Environment 1:
--------------------------
AsyncPage.aspx page is processing a total of 7500 (approx.)reques ts.
SyncPage.aspx page is processing a total of 2500 (approx.)reques ts.
THESE ARE THE EXPECTED RESULTS.EVERYTH ING IS WORKING AS EXPECTED.
Environment 2:
---------------
ACT client is running on Windows XP and Web server(where ASPX pages
are hosted) is running on Windows 2003 server/Windows 2000 Server.
ACT is running for 5 minutes with 100 simultanious browser
connections.
Results on Environment 2:
--------------------------
AsyncPage.aspx page is processing a total of 7500 (approx.)reques ts.
SyncPage.aspx page is processing a total of 7500 (approx.)reques ts.
IAM NOT ABLE TO RESOLVE THE ISSUE IN ENVIRONMENT 2.WHY BOTH THE PAGES
ARE ABLE TO PROCESS APPROXIMATELY SAME NUMBER OF REQUESTS?IS THERE ANY
TYPE OF CACHING ON CLIENT SIDE OR SERVER SIDE? PLEASE
SUGGEST........ ......
AsyncPage.aspx Code:
=============== ========
public Class AsyncPage : AsyncPage
{
private void Page_Load(objec t sender, System.EventArg s e)
{
System.Threadin g.Thread.Sleep( 3000);
Response.Write( "This is Async Page after 3 seconds sleep");
}
}
SyncPage.aspx Code:
=============== ======
public Class SyncPage : System.Web.UI.P age
{
private void Page_Load(objec t sender, System.EventArg s e)
{
System.Threadin g.Thread.Sleep( 3000);
Response.Write( "This is Sync Page after 3 seconds sleep");
}
}
ASyncPage class Code:
=============== ======
public class AsyncPage : Page, IHttpAsyncHandl er
{
static protected DevelopMentor.T hreadPool _threadPool;
static AsyncPage()
{
_threadPool = new DevelopMentor.T hreadPool(2, 25, "AsyncPool" );
_threadPool.Pro pogateCallConte xt = true;
_threadPool.Pro pogateThreadPri ncipal = true;
_threadPool.Pro pogateHttpConte xt = true;
_threadPool.Sta rt();
}
public new void ProcessRequest( HttpContext ctx)
{
// not used
}
public new bool IsReusable
{
get { return false;}
}
public IAsyncResult BeginProcessReq uest(HttpContex t ctx,
AsyncCallback cb, object obj)
{
AsyncRequestSta te reqState = new AsyncRequestSta te(ctx, cb, obj);
_threadPool.Pos tRequest(new
DevelopMentor.W orkRequestDeleg ate(ProcessRequ est), reqState);
return reqState;
}
public void EndProcessReque st(IAsyncResult ar)
{
}
void ProcessRequest( object state, DateTime requestTime)
{
AsyncRequestSta te reqState = state as AsyncRequestSta te;
// Synchronously call base class Page.ProcessReq uest
// as we are now on a thread pool thread. Once complete,
// call CompleteRequest to finish
base.ProcessReq uest(reqState._ ctx);
// tell asp.net we are finished processing this request
reqState.Comple teRequest();
}
}
class AsyncRequestSta te : IAsyncResult
{
public AsyncRequestSta te(HttpContext ctx, AsyncCallback cb,
object extraData )
{
_ctx = ctx;
_cb = cb;
_extraData = extraData;
}
internal HttpContext _ctx;
internal AsyncCallback _cb;
internal object _extraData;
private bool _isCompleted = false;
private ManualResetEven t _callCompleteEv ent = null;
internal void CompleteRequest ()
{
_isCompleted = true;
lock (this)
{
if (_callCompleteE vent != null)
_callCompleteEv ent.Set();
}
// if a callback was registered, invoke it now
if (_cb != null)
_cb(this);
}
// IAsyncResult
//
public object AsyncState { get { return(_extraDa ta); } }
public bool CompletedSynchr onously { get { return(false); } }
public bool IsCompleted { get { return(_isCompl eted); } }
public WaitHandle AsyncWaitHandle
{
get
{
lock( this )
{
if( _callCompleteEv ent == null )
_callCompleteEv ent = new ManualResetEven t(false);
return _callCompleteEv ent;
}
}
}
}
=============== ======= END OF
POST=========== =============== =============== =====