Hi Gaston, On 3/8/07, Gaston Dombiak <[EMAIL PROTECTED]> wrote:
We would like to be able to stop reading traffic for ALL sessions when the server is under heavy load. Instead of counting traffic of each single session and stop reads for that session we need to do it in a global way. That means that we are not interested in throttling a single session but all of them. I was checking the ReadThrottleFilterBuilder class to see how throttling works and figure out ways to implement the "global throttling". I found that the ReadThrottleFilterBuilder class sets a specific TrafficMask to the session to stop or allow reading based on the amount of traffic for that session. I was planning to create something like a GlobalReadThrottleFilterBuilder that would 1) consider traffic of all active IoSessions and 2) change the TrafficMask to all sessions based on #1. I then realized that accomplishing #2 in a highly concurrent environment with a good performance is not possible by doing an iteration on the IoSessions. Instead it would be nice if we could set the *same TrafficMask instance* to all IoSessions and *change the TrafficMask* to allow or disallow traffic. However, TrafficMask is not meant to be modified but to be used as singletons. Therefore, the ideal solution (IMHO) is not feasible unless we modify MINA to 1) use a TrafficMask interface where you can have your own implementation or 2) change the current TrafficMask class from using singletons to be modifiable. What do you think? Is there any other alternative that I missed? Would you be fine if I make any of the above changes to MINA?
It sounds very good. As you pointed out, iterating the list of manages sessions will cost too much. We could provide traffic control methods in IoService as we do in IoSession, and therefore the global traffic mask can override the per-session traffic mask. Additionally, Integrating this feature into existing class (i.e. ReadThrottleFilterBuilde) will be more comprehensive for users, rather than providing another builder. Thanks, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
