You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Lóránt Pintér <lp...@infomatix.hu> on 2007/10/03 22:21:53 UTC
Lots of connections
Hi!
We have a little problem here with a stress test we'd like to do on our
MINA-based server. There's a test client applicaiton that tries to
connect to the server, execute some stuff, and then disconnect. This is
repeated many times on 10 different threads.
After a few thousand of such tries all the threads start failing to
connect to the server, one by one.
First, it seems that no exception is reported. The connection is done
like this:
> ConnectFuture connectFuture = connector.connect(address, this, connectorConfig);
> connectFuture.join();
> if (!connectFuture.isConnected())
> throw new ProtocolIOException("Cannot connect to server");
The exceptionCaught() method of the IoHandler is never caught, but
connectFuture.isConnected() returns false.
After expecting and diving deep into MINA, we have found that a
BindException is raised somewhere during connection, saying something
like 'address already in use: no further information'.
One more piece of information that seems to be important: we create a
new SocketIoConnector each time (I know this is bad practice), so by the
time the connection problems start to occur, we have already created a
few thousand SocketIoConnectors already. As the local ports allocated by
the SocketIoConnector never gets released (they show up nicely with
netstat -a), I simply run out of available ports.
I have three questions that I'd like you to answer:
1) Should I share one SocketIoConnector instance between all threads, or
should I open one for each serivce thread? (Please take into
consideration that I'm doing a stress-test, so I'd like to have the
'clients' working the most similar to as if they were running on
different machines.)
2) Why does the BindException never get reported by
IoHandler.exceptionCaught()? Should I submit a bug about this, or am I
doing something completely wrong? Is there some other place I can catch it?
3) Is there a way that I can force the SocketIoConnector to shut down
the associated socket?
Thanks,
Lóránt
Re: Lots of connections
Posted by Trustin Lee <tr...@gmail.com>.
Hi Lóránt,
On 10/4/07, Lóránt Pintér <lp...@infomatix.hu> wrote:
> UPDATE: I seem to have gotten a bit confused here. Of course, I use only
> one SocketIoConnector, but there are different IoSessions for each
> connection. IoHandler.sessionClosed() gets called for each session, but
> the client side socket seems to never get released.
You mean there's resource leak on the client side when BindException
is raised due to running out of ephemeral ports?
> Lóránt Pintér wrote:
> > Hi!
> >
> > We have a little problem here with a stress test we'd like to do on our
> > MINA-based server. There's a test client applicaiton that tries to
> > connect to the server, execute some stuff, and then disconnect. This is
> > repeated many times on 10 different threads.
> >
> > After a few thousand of such tries all the threads start failing to
> > connect to the server, one by one.
> >
> > First, it seems that no exception is reported. The connection is done
> > like this:
> >
> >> ConnectFuture connectFuture = connector.connect(address, this,
> >> connectorConfig);
> >> connectFuture.join();
> >> if (!connectFuture.isConnected())
> >> throw new ProtocolIOException("Cannot connect to server");
> >
> > The exceptionCaught() method of the IoHandler is never caught, but
> > connectFuture.isConnected() returns false.
If the connection is not made at all, exceptionCaught it not invoked.
You can get the exception by calling ConnectFuture.getSession() or
ConnectFuture.getException() instead.
> > 1) Should I share one SocketIoConnector instance between all threads, or
> > should I open one for each serivce thread? (Please take into
> > consideration that I'm doing a stress-test, so I'd like to have the
> > 'clients' working the most similar to as if they were running on
> > different machines.)
Yes.
> > 2) Why does the BindException never get reported by
> > IoHandler.exceptionCaught()? Should I submit a bug about this, or am I
> > doing something completely wrong? Is there some other place I can catch it?
It's because it means the connection is not actually made. A session
is a connection, and we can't report any exception if there's no
session created. You can get the raised exception from ConnectFuture
alternatively, as suggested above.
> > 3) Is there a way that I can force the SocketIoConnector to shut down
> > the associated socket?
Could you explain a little bit more in detail?
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6
Re: Lots of connections
Posted by Lóránt Pintér <lp...@infomatix.hu>.
UPDATE: I seem to have gotten a bit confused here. Of course, I use only
one SocketIoConnector, but there are different IoSessions for each
connection. IoHandler.sessionClosed() gets called for each session, but
the client side socket seems to never get released.
Regards,
Lóránt
Lóránt Pintér wrote:
> Hi!
>
> We have a little problem here with a stress test we'd like to do on our
> MINA-based server. There's a test client applicaiton that tries to
> connect to the server, execute some stuff, and then disconnect. This is
> repeated many times on 10 different threads.
>
> After a few thousand of such tries all the threads start failing to
> connect to the server, one by one.
>
> First, it seems that no exception is reported. The connection is done
> like this:
>
>> ConnectFuture connectFuture = connector.connect(address, this,
>> connectorConfig);
>> connectFuture.join();
>> if (!connectFuture.isConnected())
>> throw new ProtocolIOException("Cannot connect to server");
>
> The exceptionCaught() method of the IoHandler is never caught, but
> connectFuture.isConnected() returns false.
>
> After expecting and diving deep into MINA, we have found that a
> BindException is raised somewhere during connection, saying something
> like 'address already in use: no further information'.
>
> One more piece of information that seems to be important: we create a
> new SocketIoConnector each time (I know this is bad practice), so by the
> time the connection problems start to occur, we have already created a
> few thousand SocketIoConnectors already. As the local ports allocated by
> the SocketIoConnector never gets released (they show up nicely with
> netstat -a), I simply run out of available ports.
>
> I have three questions that I'd like you to answer:
>
> 1) Should I share one SocketIoConnector instance between all threads, or
> should I open one for each serivce thread? (Please take into
> consideration that I'm doing a stress-test, so I'd like to have the
> 'clients' working the most similar to as if they were running on
> different machines.)
>
> 2) Why does the BindException never get reported by
> IoHandler.exceptionCaught()? Should I submit a bug about this, or am I
> doing something completely wrong? Is there some other place I can catch it?
>
> 3) Is there a way that I can force the SocketIoConnector to shut down
> the associated socket?
>
> Thanks,
> Lóránt