【问题标题】:nginx error : worker_connections are not enoughnginx 错误:worker_connections 不够
【发布时间】:2018-03-20 04:16:12
【问题描述】:

我是 Nginx 的新手。

我想用 Nginx 做的是流量负载平衡。 为此,我配置了 nginx.conf,如下所示

系统结构

      udp        udp
    A <--> Nginx <--> Backend 1
                 <--> Backend 2

nginx.conf

user  nginx;
worker_processes  4;
worker_rlimit_nofile 30000;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

stream {
upstream udp_upstreams {
   server 1:1:1:1:9997 fail_timeout=60s;
   server 1:1:1:2:9997 fail_timeout=60s;
}

server {
    listen 9000 udp;
    proxy_pass udp_upstreams;
    proxy_timeout 3s;
    proxy_responses 1;
    error_log /var/log/nginx/udp.log;
}
}

events {
    worker_connections  10240;
}

当我运行 nginx 时,nginx 会打印很多下面的消息。

2016/04/27 04:50:36 [alert] 3137#3137: *446352 10240 worker_connections are not enough while connecting to upstream, udp client: 3.3.3.3, server: 0.0.0.0:9000, upstream: "1.1.1.2:9997", bytes from/to client:0/0, bytes from/to upstream:0/0
2016/04/27 04:50:36 [alert] 3136#3136: *446353 10240 worker_connections are not enough while connecting to upstream, udp client: 3.3.3.3, server: 0.0.0.0:9000, upstream: "1.1.1.1:9997", bytes from/to client:0/0, bytes from/to upstream:0/0

如何配置 nginx.conf 来解决它? 我已经将 work_connections 的值设置为 40000。但是没有用。

提前致谢。

【问题讨论】:

  • 我遇到了同样的问题。你有没有解决过这个问题?

标签: nginx


【解决方案1】:

在我停止疯狂谷歌搜索并开始阅读 nginx 文档后,我遇到了同样的问题并找到了解决方案。 ^_^;

参数 'proxy_responses' 告诉 nginx 等待对请求的 x 个响应。我的情况,日志转发,没有。所以 nginx 等待服务器并使其失败。

解决办法:

proxy_responses 0

文档: http://nginx.org/en/docs/stream/ngx_stream_proxy_module.html#proxy_responses

【讨论】:

  • 很好的答案!您还可以为后代提供指向文档的链接吗?
  • 感谢您对此的解释。我讨厌那些只向你扔代码而没有解释的答案。
猜你喜欢
  • 2019-11-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-07-13
  • 2021-06-27
  • 2023-03-04
  • 2021-05-26
相关资源
最近更新 更多