Salut,
Matteo Mazzotti wrote:
> Hi all,
> I've come across your framework more or less by chance.
> I've read some blogs about it and some tutorials, but I need a final
> clarification from you on whether this is actually the right framework for
> my use case.
>
> I have to (re)write a TCP server (no HTTP) that is able to serve hundreds of
> clients at the same time.
> What is not clear to me is whether Asynchronous and permanent connections
> (which is what I need) are two contradictory terms, that is if one must
> choose between one approach or the other.
When we use the term asynchronous, we just means that you don't need one
thread per connection, but instead use threads only when there is an
event occurring. Asynchronous is also used when a request is suspended
waiting for an server event, and resumed when a specific event happen.
> I need a permanent connection because the client must be pushed data by the
> server (I'd say asynchronously, as the updates sent by the server don't
> necessarily follow a client request).
Indeed.
>
> At the moment, my server implementation is based on the old
> thread-per-connection paradigm, which I understand is a wasteful approach
> and doesn't scale up. So the thread-per-event seems to be the right one
> here.
Yes.
> Aother question: in the thread-per-event solution, a thread pool is used to
> take a thread from the pool, serve an event, "wake up" the appropriate
> Handler (which is a thread too), then go back to sleep waiting for a new
> event. If a Handler is a thread, and I have a Handler per client, in the end
> I still have a thread per connection, so what's the key difference ? Am I
> missing something here? (maybe there can be a thread pool for Handlers too?)
You handle doesn't need to block on a thread, right? You can put your
handler in a pool and resume its execution *only* when there is a
something to execute for that handler. If there is no event, you usually
try to avoid "wasting" a thread.
Does it makes sense?
>
>
> Thank you in advance,
> Matteo
>
> Ps: I'm from Italy and I couldn't find any resource on grizzly on the
> Italian blogosphere. I think I'll blog about it as soon as I get
> knowledgeble enough
That would be great!
A+
-- Jeanfrancois
>
>
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>