我有一个场景,应用程序需要每个请求从 redis 获取大约 80 次操作。当我在该应用程序上遇到 1 个请求时,它会在不到 1 秒的时间内给出响应,但是当请求大小增加到 100 时,redissonClient 开始表现缓慢,大约需要 13 秒才能获取 250 条记录。
我是 redis 新手,不确定这是否是默认设置。虽然我在一些文章中发现,redis 可以在 1 秒内在 1 个节点上处理数百万次操作。我们的 redis 服务器目前在 1 个节点上运行。
下面是redis的配置:
{
"singleServerConfig": {
"idleConnectionTimeout": 10000,
"pingTimeout": 1000,
"connectTimeout": 10000,
"timeout": 2000,
"retryAttempts": 3,
"retryInterval": 1500,
"reconnectionTimeout": 2000,
"failedAttempts": 3,
"password": null,
"subscriptionsPerConnection": 5,
"clientName": null,
"address": "redis://172.18.17.207:6379",
"subscriptionConnectionMinimumIdleSize": 1,
"subscriptionConnectionPoolSize": 50,
"connectionMinimumIdleSize": 32,
"connectionPoolSize": 100,
"database": 0,
"dnsMonitoringInterval": 5000
},
"threads": 128,
"nettyThreads": 128,
"codec": null,
"useLinuxNativeEpoll": false
}
以下是我在启动时实例化 redisson 客户端的方式:
try {
Config config = Config.fromJSON(CommonConstants.REDIS_SINGLE_CONFIG_JSON_FILE);
redisClient = Redisson.create(config);
} catch (IOException e) {
log.error(null, "Error establishing connection to Redis Cluster!", e);
}
以下是我获取记录的方式:
public List<Map<String, String>> fetch(List<String> ids) {
return ids.stream().map(id -> {
Map<String, String> m = redisClient.getMapCache(id);
return m;
}).collect(Collectors.toList());
}
我怀疑我错误地配置了 redis 客户端,但无法弄清楚那是什么。
非常感谢任何帮助/灯光。
谢谢