Hi,

thank you for the answer. I wrote my last mail parallel to yours :)

My decoders work stateless (they get the needed per session state info from session attributes). So I return the decoders as singleton (one single instance over all sessions). This works very well at the moment with upto 15.000 sessions.

The only question is, what happens in the cases of more then one thread? Here I want to use for each thread an own (separate) decoder instance, so that the singleton decoder don't lead to a performance bottleneck in my system.

Must I implement this by myself (how?) or does Mina all the stuff for me right now, when it opens a new thread (by duplicating the filterchain automatically? -> is that the case?).

Thanx in advance for any comments!

Best Regards
Michael



Trustin Lee wrote:

Hi Michael,

On 5/13/06, Michael Bauroth <[EMAIL PROTECTED]> wrote:


Hi,

at the moment there exist two basic possibilities to add a codec to a
chain. In one case there exists for every session one instance of the
decoder. In the other case I can return for the getDecoder() method in
the CodecFactory every time the same instance. At the moment I use the
second way.
My question now is, how can I handle that case, when I use instead of
SimpleByteBufferAllocator the normal ThreadPoolAllocator?
When I'm right, then I have now n parallel working threads with it's
separate own filterchain. Correct?
How can I now realize a behaviuour, that for each thread I have one own
decoder instance? Will each new working thread create it's own
filterchain with new instances of CodecFactory? Then would it mean, that
each of this factories creates it's own instance of the decoder, so all
  should be fine. Is this the case?
Do you know what I mean? :)



Actually I didn't get it.  Anyway... I'll explain what I know to you.

It's OK for you to create a new instance whenever getDecoder() or
getEncoder() is called.  It is called only once per session.  It shouldn't
affect the performance of your application at all.  If your protocol coded
is stateless or stores its state in IoSession's attributes, then you can
create a singleton and return it again and again. But the implementation of
the codec can be complex.  It's completely up to you.

HTH,
Trustin

Reply via email to