You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Chris Markle <cm...@comcast.net> on 2009/06/19 08:09:43 UTC

Tomcat Comet and threading?

Say I am running the NIO connector and using Comet by my servlet
implementing CometProcessor... What is the relationship between my
servlet, threading and what is blocking vs. non-blocking? I am trying
to understand this better so I can see where I might want to use my
own threads or not. If I hit my servlet with a lot of requests, will
my event() method always be running on a single thread? If it runs on
multiple threads, what configuration parameter if any controls how
many of those threads there are? I presume writes from the servlet
back to the client may block - is this correct?

Thanks in advance...

Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Comet and threading?

Posted by Chris Markle <cm...@comcast.net>.
Filip,

Thanks for the reply.

> You can do the actions on the worker thread or on your own thread.

Can you clarify your terminology here please? Is the "worker thread"
then one where the event() method is running? Can there be more than
one of those threads that are running the event() method for one
servlet, so that under load I'll see my one servlet's event() method
running on more than one thread? If this is the case, what
configuration items control this threading?

> You can read non blocking when you receive a READ event by calling available()>0 before you do a read.

When handling READ events, can I do one read before checking
available()>0 or is it possible that READ may have fired but
available()==0? I ask because I think I saw at least one sample where
one read is done before checking available()>0...

Thanks in advance!

Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Tomcat Comet and threading?

Posted by Filip Hanik - Dev Lists <de...@hanik.com>.
You can do the actions on the worker thread or on your on thread.
You can read non blocking when you receive a READ event by calling 
available()>0 before you do a read.
Writes are blocking when the TCP send buffer fills up, just like a 
regular servlet

Filip

Chris Markle wrote:
> Say I am running the NIO connector and using Comet by my servlet
> implementing CometProcessor... What is the relationship between my
> servlet, threading and what is blocking vs. non-blocking? I am trying
> to understand this better so I can see where I might want to use my
> own threads or not. If I hit my servlet with a lot of requests, will
> my event() method always be running on a single thread? If it runs on
> multiple threads, what configuration parameter if any controls how
> many of those threads there are? I presume writes from the servlet
> back to the client may block - is this correct?
>
> Thanks in advance...
>
> Chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org