On 2/13/11 11:41 AM, Guy Itzhaki wrote:
(Sorry for my pre mature email an hour ago - my mistake)

The ProtocolCodecFilter does an expensive process much more than the
handler, it is the ProtocolCodecFilter duty to read&  persist incoming
messages, same goes for sending messages - the  codec is responsible to
read the message from the disk and send it.
ok, two things here :
- I guess the decoding itself is not costly, so no need of using an executor for decoding. - You can add an executor to process the write operation only, but it should be placed *after* the codec filter, as the filters are executed in the reverse order when writing information.


I wonder where is best to place the ExecutorFilter? Is it before the
ProtocolCodecFilter or after? It seems to me that given what I explained
before I should use two executorFilters one to be placed before the
codec to digest incoming messages and the other after (for the sake of
the outgoing messages).
You can't have 2 executors in the chain. That's by design. Probably bad, but you have to deal with it...



chain.addLast("sslFilter", sslFilter)

chain.addLast("logger", new LoggingFilter())

chain.addLast("readPool", new ExecutorFilter(coreSize,
maxSize,keepAliveTime, TimeUnit.MILLISECONDS,
IoEventType.MESSAGE_RECEIVED))

chain.addLast("codec", protocolCodecFilter)

chain.addLast("writePool", new ExecutorFilter(coreSize,
maxSize,keepAliveTime, TimeUnit.MILLISECONDS, IoEventType.WRITE))



Can you please approve that using the above chaining is best for my
needs?
If you remove the first executor, that should be fine.


Emmanuel, I read once your reservation about placing the executor first,
you said: "...as the executor is the fist one in the filters chain, you
may not be able to deal with fragmented messages"

Can you explain what did you mean fragmented messages?
You have no guaranty whatsoever tht the data coming from a client will be received in one block. You can even expect to get the messageReceived() event be called for every single byte in the message (not likely to happen, but it's just to depict the worst possible situation). Generally speaking, if you have big messages (ie, more than a few Kb), you may get it split in more than one PDU. You have to deal with this, using a cumulativeProtocolDecoder, or writing your own logic to gather the bytes.
And in other post you said " Executor can leads to some issue if you are
under heavy load " can you elaborate on that? Taking into consideration
these comments of yours what is the best approach in case of heavy load?
As soon as you spread the loads on many threads, at some point, you may creates thousands of threads if one of your clients send thousands of messages (let's say it's a DDOS). You probably have some ways to deal with such issues on a FW level, but it's important to keep in mind that such problems can arise.

However, it's more or less a warning, as every application open to the outside world can have the exact same issues.

--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com

Reply via email to