我有一个创建jedispool的功能,
final JedisPoolConfig poolConfig = new JedisPoolConfig();
poolConfig.setMaxTotal(25);
poolConfig.setMaxIdle(20);
poolConfig.setMinIdle(20);
poolConfig.setTestOnBorrow(false);
poolConfig.setTestOnCreate(true);
poolConfig.setTestOnReturn(true);
poolConfig.setTestWhileIdle(false);
poolConfig.setMinEvictableIdleTimeMillis(-1);
poolConfig.setTimeBetweenEvictionRunsMillis(-1); // don't evict
poolConfig.setNumTestsPerEvictionRun(-1);
poolConfig.setBlockWhenExhausted(false);
poolConfig.setLifo(false);
return poolConfig;
我正在使用以下方法从池中获取客户端。我看到有时甚至在100- 500毫秒内有时甚至在30毫秒内都有高延迟才能使客户端从池中获取。我正在测试52个rps,配置20个空闲连接和25个最大连接。能够处理〜600rps。在池级别是否有任何调整可以验证?
Instant instant = Instant.now();
Instant getFromPool = null;
try (final Jedis jedis = jedisPool.getResource()){
getFromPool = Instant.now();
}
最佳答案
您可以在池中使用以下方法检查等待线程和最大等待时间。
jedisPool.getNumWaiters();
jedisPool.getMaxBorrowWaitTimeMillis()
但是我认为网络层存在问题。
关于java - jedispool getResource消耗太多延迟,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/60158537/