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

标签 nginx redis lua openresty

我正在使用 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/

相关文章:

java - 如何最好地组织我的项目以获得最佳的 nginx 使用

redis - not in redis查询怎么写

lua - 在 Lua 中从表中删除元表

multithreading - Lua 脚本协程

string - Lua:删除字符串中的特定字符

nginx - Kubernetes NGINX 入口 : Disable external auth for specific path

php - CodeIgniter 不会在 '/' 上加载默认 Controller

ssl - 一个网站的多个IP+域+SSL证书

java - Redisson如何序列化很长时间

ruby - 如何为两种环境配置god/redis?