aerospike / aerospike-client-java

Aerospike Java Client Library
Other
236 stars 212 forks source link

Connection Pool Question: How to make sure 'x' connections are always created #133

Closed s-aravind-flipkart closed 3 years ago

s-aravind-flipkart commented 5 years ago

Like in Jedis using GenericObjectPool there is a way to specify idle and max connections the client needs to create. Is there a similar way in java client to specify both aspects

BrianNichols commented 5 years ago

ClientPolicy.maxConnsPerNode sets max connections for each server node. ClientPolicy.maxSocketIdle sets max seconds connections may remain idle in a connection pool.

There is no direct way to require a minimum number of connections. You can keep connections in the pool longer by increasing maxSocketIdle (default 55 seconds). If maxSocketIdle is increased, the default connection reap on the server (proto-fd-idle-ms, default 60000 ms) should also increase because maxSocketIdle should always be less than proto-fd-idle-ms. Otherwise, the client may attempt to use connections that have been closed by the server.

s-aravind-flipkart commented 5 years ago

@BrianNichols Thanks for the info. This pool also includes for batch reads right. I see right now a lot of connections in TIMED_WAIT with default configs. Batch read size is large in my case around 80 ids per call.

BrianNichols commented 5 years ago

Yes, batch reads use a connection for each target node from the node's connection pool.

BrianNichols commented 3 years ago

ClientPolicy.minConnsPerNode has been supported for a while now.