Terrel Shumway wrote:
> "Love, Jay" wrote:
>
> > Ideally, we want to have the sending stream that servlets write to be a
> > buffered object that is written to, and optionally the data can be sent as
> > it is written. The same technique could be used for receiving input data, as
> > you have asked. This will not be terribly difficult to do, I just haven't
> > gotten to it yet.
> >
>
> How difficult would it be to expose all of the medusa tools (producers,
> continuations, et. al.) and make things asynchronous throughout? I
> would like to be able to say: "here is what I want done, I don't care
> how or when you do it." I realize that it is a model most people are
> not familiar with. Maybe we could create a class such as
> AsyncServlet.... servlet.write would map to channel.push.
> Hmm... how does one do an asynchronous SQL query?
>
> My ignorance is showing. Sendfile is an obvious application, but
> anything that requires computation requires a lot of work to break
> it up. I need to play with this some more.
>
> -- Terrel
The asynchronous model is nice for I/O-bound operations, such as reading and writing the sockets. But I think it's an inappropriate model for the servlets because it would force you to code your servlets in small chunks of activity, which is very unnatural compared to simply writing whatever code you need and letting the OS's threads handle switching between servlets.
AsyncThreadedAppServer does about the best you can do, I think -- it uses the async model for socket communications, but uses a thread pool to actually execute the servlets. The async model for socket communications should really help if the sockets are slow, although in the typical situation where you're using a web server and WebKit on the same machine, it doesn't seem like it would make much difference.
(That's why I wrote the experimental HTTP-serving version of WebKit based on AsyncThreadedAppServer rather than ThreadedAppServer -- because I assumed that if we're serving HTTP directly, the sockets could be going over the internet and could therefore be very slow, so you'd rather let the async loop handle the sockets instead of tying up the threads.)
--
- Geoff Talvola
Parlance Corporation
gtalvola@...
|