Search code examples
c#aerospike

Are connections in connection pool closed in Aerospike after we close the parent connection?


The ClientPolicy of the Aerospike connection I am creating has minConnsPerNode = 10. When I create a connection using the below syntax in C#

using (AerospikeClient client = new AerospikeClient(moduleClientPolicy, address, port))
{

}

Will the 10 connections that were created (due to minConnsPerNode) be closed after '}' or they will be moved back to connection pool?

If they are moved back to connection pool, the next connection I make again using the above syntax will use the connection from the pool right?

Also, is there a way to figure out the number of connections made with Aerospike?


Solution

  • minConnsPerNode number of connections are kept open in the connection pool. If connections fall below that number, new ones are opened by the tend thread and put in the pool. This can happen if the the socket is closed, when used, in certain situations. When asking for a new connection, if there are connections in the pool, they are used. So, overall, your understandig about minConnsPerNode is correct. (Ensure, server uses proto-fd-idle-ms =0 [default] so connections are not closed by the server and then have to be re-opened by tend thread to maintain the minConnsPerNode. Server uses keep-alive messages to detect abandoned clients and close sockets.)