首页 > 解决方案 > Nginx 工作进程

问题描述

我正在使用 docker nginx 作为我在 docker 容器中扩展的后端 rails api 应用程序的反向代理。

在性能测试期间,我收到这样的错误:

4048 worker_connections are not enough

我发现我有一个默认值 worker_processes = 1。之后我将此值更改为 8(在 8 个 vCPU ubuntu 服务器上),但仍然出现此错误。

看着 htop 似乎其他工人在高负荷下无法工作......

在此处输入图像描述

这是我的 nginx.conf

user  nginx;
worker_processes  8;

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


events {
    worker_connections  4048;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

标签: dockernginxhigh-loadartillery

解决方案


推荐阅读