Redis 就像一个数据库。

huangapple go评论59阅读模式
英文:

Redis like a database

问题

我们有一个独立配置的 Redis,我正在使用 Lettuce 进行连接。当我们只有一个单一用户访问 Redis 数据库时,结果 API 的响应速度很快,大约为 700 毫秒,但是当有超过 5 个用户消耗这个访问 Redis 数据库的 API 时,响应时间增加超过 1 到 2 秒。
如何确保多个用户在使用我的 API 时不会失去性能?

附注:我们有一个 Java API(使用 Spring Boot)+ Lettuce + JPA,没有使用连接池或显式阻塞操作。我们只进行 findBy 操作,可能会有大约 30000 个用户访问这个 API。

英文:

We have a redis with standalone configuration and I am using lettuce to connect with it. When we have one single user to access redis database the result api is fast, about 700ms, but when we have more then 5 users to consume this api that access redis database the time is increased more than 1 or 2 seconds.
How can garantee many users to consume my api without lost performance time?

PS: we have a java API (Spring boot) + lettuce + JPA without pool or explicit blocking operation. We have only findBy operations and may this API will be access about 30000 users

答案1

得分: 0

尝试增加最小空闲连接池和活动连接池。类似以下配置:

lettuce:
  pool:
    max-active: 64
    max-idle: 64
    min-idle: 16

根据您的基础设施和需求,尝试微调这些值。您可能需要为lettuce添加连接池依赖,因为它可能不是默认提供的。类似于 commons-pool2

英文:

Try increasing the minimum idle connection pool and and active connection pool. Something like below:

lettuce:
  pool:
    max-active: 64
    max-idle: 64
    min-idle: 16

Try and fine tune these values as per your infrastructure and need. You might have to add connection pool dependency for lettuce cause it might not come by default. Something like commons-pool2

huangapple
  • 本文由 发表于 2020年8月25日 07:51:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/63570145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定