gpt4 book ai didi

performance - JedisPool 持有的默认连接

转载 作者:可可西里 更新时间:2023-11-01 11:18:00 24 4
gpt4 key购买 nike

我正在使用jedis 客户端redisofbiz 集成。 不同的应用程序正在使用一个 redis 服务器。我的问题是

  1. 默认情况下,JedisPool 将保持多少个连接。

  2. 如果我创建多个 JedisPool 会影响 redis 性能

注意:我在另一个应用程序中使用默认配置创建 JedisPool

client = new JedisPool(ip, port);

有没有更好的方法?,建议我。谢谢

更新:使用默认配置用户 spring data 启动 redis 服务器

<bean id="connectionFactory"
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
p:host-name="${app.cache.redis.host}" p:port="${app.cache.redis.port}" p:password="${app.cache.redis.password}" />

最佳答案

1) JedisPool默认会持有多少个连接

通过在这个实例化中使用 JedisPool,

client = new JedisPool(ip, port);

您正在使用来自 apache-commons-pool 的 GenericObjectPoolConfig

这个通用池的默认配置是:

DEFAULT_MAX_TOTAL = 8
DEFAULT_MAX_IDLE = 8
DEFAULT_MIN_IDLE = 0

2) 如果我创建多个 JedisPool 会影响 redis 性能吗

是也不是。如果您创建多个 JedisPool,您将有更多的客户端连接到 Redis。但是 Redis 可以支持很多连接的客户端,性能非常好。

您可以在 redis.conf 中设置 Redis 最大客户端授权数(例如 10000 clients max)。

maxclients 10000

或在启动时:

./redis-server --maxclients 10000

或者使用 redis-cli :

127.0.0.1:6379> config set maxclients 10000

在默认配置中,授权客户端的数量是无限的。

根据您的用例,您可以拥有多个 JedisPool,或者只是增加 JedisPool 的大小(拥有超过 8 个连接)。

关于performance - JedisPool 持有的默认连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42220505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com