Hi Trustin,
thanks a lot for your response.
Trustin Lee wrote:
Hi Swen,
On 1/4/07, Swen Moczarski <[EMAIL PROTECTED]> wrote:
Hi, I have done some performance tests. A client is sending a lot of
small
messages over a connection to a server. In
spite of the read-throttle-filter (
org.apache.mina.filter.ReadThrottleFilterBuilder) the server will be
overloaded and I
get out-of-memory exceptions.
Before the message will be forwarded to the ExecutionFilter, the
ReadThrottleFilter makes use of ByteBuffer.remaining()
for increasing the calculated size of the connection buffer. But after
passing the ExecutionFilter the method
ByteBuffer.capacity() is used to decrease the size. Is that behaviour
intended?
When I'm patching the ReadThrottleFilterBuilder to use
ByteBuffer.capacity()
for both cases the performance test works
absolutely fine, there are no longer out-of-memory exceptions. BTW, in
the
SVN-history I have seen that the first
version uses ByteBuffer.capacity() for both cases.
It seems like there was a mistake. Could you try to change both capacity()
calls to remaining()? I think it's a correct fix than using capacity().
When I'm using the remaining() calls, I still get an out-of-memory error. But
when I'm using capacity() it looks ok.
Maybe, this becomes only a problem when a lot of small messages are stored in
bigger ByteBuffers. But I think it would
be safer to prevent overloading when the ReadThrottleFilter tracks the memory
allocated by the ByteBuffers (capacity())
instead of the received bytes. WDYT?
Here is my simple stess-test:
public class Test {
private final static int PORT = 8056;
public static void main(String[] args) throws Exception {
IoHandler handler = new IoHandlerAdapter() {
public void exceptionCaught(IoSession session, Throwable cause) throws
Exception {
cause.printStackTrace();
}
public void sessionCreated(IoSession session) throws Exception {
ReadThrottleFilterBuilder throttleFilter = new
ReadThrottleFilterBuilder();
throttleFilter.attach(session.getFilterChain());
}
};
SocketAcceptor acceptor = new SocketAcceptor();
acceptor.bind(new InetSocketAddress(PORT), handler);
Socket socket = new Socket("localhost", PORT);
Writer writer = new OutputStreamWriter(socket.getOutputStream());
while (true) {
writer.write("test");
writer.flush();
}
}
}
I have tried the test with version 1.0.1 and the current trunk (with the current trunk it takes longer until the memory
error occures).
Should I attach the test to https://issues.apache.org/jira/browse/DIRMINA-338
and reopen the issue?
Regards,
Swen