gpt4 book ai didi

nginx - lua-resty-redis set_keepalive 推荐设置

转载 作者:IT王子 更新时间:2023-10-29 06:06:05 27 4
gpt4 key购买 nike

我正在使用red:set_keepalive(max_idle_timeout, pool_size)

(来自这里:https://github.com/openresty/lua-resty-redis#set_keepalive)

使用 Nginx 并尝试确定用于 max_idle_timeout 和 pool_size 的最佳值。

如果我的 worker_connections 设置为 1024,那么将 pool_size 设置为 1024 是否有意义?

对于 max_idle_timeout,60000(1 分钟)是不是太“激进”了?使用较小的值是否更安全?

谢谢,

马特

最佳答案

我认为Check List for Issues官方文档的一部分有一个很好的连接池大小指南:

Basically if your NGINX handle n concurrent requests and your NGINX has m workers, then the connection pool size should be configured as n/m. For example, if your NGINX usually handles 1000 concurrent requests and you have 10 NGINX workers, then the connection pool size should be 100.

因此,如果您预计有 1024 个并发请求实际连接到 Redis,那么您的池的合适大小是 1024/worker_processes。可能还有一些是为了解决工作人员之间请求分配不均的问题。

您的 keepalive 应该足够长以说明流量到达的方式。如果您的流量稳定,那么您可以降低超时时间。或者保持 60 秒,在大多数情况下,更长的超时不会产生任何明显的差异。

关于nginx - lua-resty-redis set_keepalive 推荐设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52750688/

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