Re: Asynchronous socket operations and threadpool

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



| The wait is on a WaitHandle for an operation performed during a callback.
| For example, you get a big chunk of data for the user (via the async call)
| and realize you need to perform a database lookup to satisfy the request.
| You kick off the DB Request async, do as much more of the user request as
| you can, then wait for the DB Request to complete. Once it's done, you
send
| the user back his data, and put the socket back into BeginRead.

Thanks. I see what your doing. However, the waitHandle really turns you back
into a blocking server instead of an async. If db requests will be handled
by every client, this could starve the IOCP TP pretty fast as you said in
other posts. Why not do the db lookup async and in the callback do the
beginwrite back to the client. All state driven, and a pain, but no
blocking threads on IO. That said, you pointed out some potential issues
that could be very hard to diag with using a lot of async. So maybe the
pipe-line server deserves another look.


| One thing I'm not clear on, given what you describe - when you get data
from
| a socket, and realize you have something significant to do (and you want
to
| do it async), how do you do it? You can't just post it to the ThreadPool,
as
| there aren't enough threads in there. You don't want to manage a ton of
| threads manually if you can help it...

Just update your state and kick off another async like above then do the
next "thing" in the callback (i.e. write to client, next stage, etc).

Cheers Chris.
--wjs


.



Relevant Pages

  • Re: Threading issue
    ... while the i/o is be handled by the os, the invoking thread can continue to do other work. ... say you needed to call 3 different webservices to process a request, you can make all three calls at the same time, wait on completion, then continue processing the request, all with one thread. ... if you goal is background processing then you should use a pooled worker threads to which you can pump messeages, or start one background thread and have it do async calls. ... the callback is done to the same thread. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Surprising error in PFN_HSE_IO_COMPLETION Function
    ... You need to queue up an async operation prior to returning ... are you making an async WriteClient prior to ... I'm not certain why you even need to "wait for the callback". ... you MUST call HSE_REQ_IO_COMPLETION for each request that is going to ...
    (microsoft.public.inetserver.iis)
  • Re: W2K3 IIS 6.0 ASP.NET Requests Per Second Limits?
    ... >> The way I understand async programming is if u need to do other ... >> request to webservice nothing more can be done until the result ... > The thread executing code literally calls into Function1, ... > the act of sending back the response using data that has been ...
    (microsoft.public.inetserver.iis)
  • Re: W2K3 IIS 6.0 ASP.NET Requests Per Second Limits?
    ... allow the page to tell ASP.Net "don't send a response yet until I tell ... this request is "leaked" and will never ... It is when the callback executes with both the async function call ... The thread executing code literally calls into Function1, execute code, ...
    (microsoft.public.inetserver.iis)
  • Re: W2K3 IIS 6.0 ASP.NET Requests Per Second Limits?
    ... I think I grasp the concept between the two scenarios sync and async. ... Web Page displays the content of the HTTP response ... Now with this example when I send the request to temperature webservice ... > queue's up the HTTP request and immediately returns back and can ...
    (microsoft.public.inetserver.iis)