Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.0-M4
    • Fix Version/s: 2.0.8
    • Component/s: None
    • Labels:
      None

      Description

      In the current code base, when accepting new connections, we pick a processor and register the news connection within the internal selector. In other words, we have as many selectors as we have IoProcessors.

      This is a potential problem if some request cost a lot to be executed, as every requests waiting on this IoProcessor will be blocked.

      It would be way better to use a single selector which dispatches requests to an Executor, as we will always have available threads ready to process the requests (unless the pool is saturated, but then we have a bigger issue ...)

        Activity

        Hide
        elecharny Emmanuel Lecharny added a comment -

        There are ways to handle such a situation either by using an executor filter, or by dealing with costly operations on the IoHandler

        Show
        elecharny Emmanuel Lecharny added a comment - There are ways to handle such a situation either by using an executor filter, or by dealing with costly operations on the IoHandler
        Hide
        elecharny Emmanuel Lecharny added a comment -

        Won't be refactored in 2.0

        Show
        elecharny Emmanuel Lecharny added a comment - Won't be refactored in 2.0
        Hide
        cfsego chuanwen chen added a comment -

        Sorry, my mistake, it is 1.x in my hand

        Show
        cfsego chuanwen chen added a comment - Sorry, my mistake, it is 1.x in my hand
        Hide
        elecharny Emmanuel Lecharny added a comment -

        The IoProcessor class inherits from the AbstractPollingIoProcessor class, which contains an inner class named Processor, which is responsible for handling incoming messages. This class implements Runnable, and call the process() method, which iterates on all the selected sessions, one by one, do a read() for each one of them, and call the filterChain.fireMessageReceived(buf) method if some data has been received. If yiu don't put an executor in your chain, and if this chain processing is costly, then the whole mchansim will wait until your costly handling is finished.

        Show
        elecharny Emmanuel Lecharny added a comment - The IoProcessor class inherits from the AbstractPollingIoProcessor class, which contains an inner class named Processor, which is responsible for handling incoming messages. This class implements Runnable, and call the process() method, which iterates on all the selected sessions, one by one, do a read() for each one of them, and call the filterChain.fireMessageReceived(buf) method if some data has been received. If yiu don't put an executor in your chain, and if this chain processing is costly, then the whole mchansim will wait until your costly handling is finished.
        Hide
        cfsego chuanwen chen added a comment -

        I followed the execution flows of SocketAccept and SocketConnect, IoProcessors do not process any handler in their own threads, but throw them to org.apache.mina.filter.executor.ExecutorFilter, moreover, the filter process the user handlers within a threadpool(about 16 threads). So I don't think every requests waiting on this IoProcessor will be blocked, but fail.

        Show
        cfsego chuanwen chen added a comment - I followed the execution flows of SocketAccept and SocketConnect, IoProcessors do not process any handler in their own threads, but throw them to org.apache.mina.filter.executor.ExecutorFilter, moreover, the filter process the user handlers within a threadpool(about 16 threads). So I don't think every requests waiting on this IoProcessor will be blocked, but fail.
        Hide
        elecharny Emmanuel Lecharny added a comment -

        AFAIR, when a new message arrives, as it is associated with a session, it's beng processed by a IoProcessor. As an IoProcessor also holds the selector, we can't process more than one message at a time in a single IoProcessor (hopefully, we have more than one IoProcessor). So if the message is costly to process (ie, yu access a database in the middle), in a loaded system, messages can be blocked a long time before being processed, waiing for the crrent message to be completed.

        This is what I meant. Hope it's clearer.

        Show
        elecharny Emmanuel Lecharny added a comment - AFAIR, when a new message arrives, as it is associated with a session, it's beng processed by a IoProcessor. As an IoProcessor also holds the selector, we can't process more than one message at a time in a single IoProcessor (hopefully, we have more than one IoProcessor). So if the message is costly to process (ie, yu access a database in the middle), in a loaded system, messages can be blocked a long time before being processed, waiing for the crrent message to be completed. This is what I meant. Hope it's clearer.
        Hide
        cfsego chuanwen chen added a comment - - edited

        Not sure where requests will be blocked, or will you explain "cost a lot"?

        Show
        cfsego chuanwen chen added a comment - - edited Not sure where requests will be blocked, or will you explain "cost a lot"?

          People

          • Assignee:
            Unassigned
            Reporter:
            elecharny Emmanuel Lecharny
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development