与单个节点相比,使用NGINX的负载平衡低于RP

发布于 2025-01-31 05:33:51 字数 2710 浏览 4 评论 0原文

我为4个区块链客户设置了一个Nginx负载平衡器,并通过使用 k6 来获得每秒较低的请求。通过负载平衡器,如果我针对单个节点,我会做的。所有节点都在响应相等的流量,并且似乎没有一个比下一个响应慢。

负载平衡器用 bitnami nginx helm图表客户正在使用自己的VM运行。

** nginx.conf **

    # Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
    # user              www www;  ## Default: nobody;

    load_module modules/ngx_http_geoip2_module.so;
    load_module modules/ngx_stream_geoip2_module.so;

    worker_processes  auto;
    error_log         "/opt/bitnami/nginx/logs/error.log";
    pid               "/opt/bitnami/nginx/tmp/nginx.pid";

    events {
        worker_connections  1024;
    }

    http {
        include       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    "/opt/bitnami/nginx/logs/access.log";
        add_header    X-Frame-Options SAMEORIGIN;

        client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
        proxy_temp_path        "/opt/bitnami/nginx/tmp/proxy" 1 2;
        fastcgi_temp_path      "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
        scgi_temp_path         "/opt/bitnami/nginx/tmp/scgi" 1 2;
        uwsgi_temp_path        "/opt/bitnami/nginx/tmp/uwsgi" 1 2;

        sendfile           on;
        tcp_nopush         on;
        tcp_nodelay        off;
        gzip               on;
        gzip_http_version  1.0;
        gzip_comp_level    2;
        gzip_proxied       any;
        gzip_types         text/plain text/css application/javascript text/xml application/xml+rss;
        keepalive_timeout  65;
        ssl_protocols      TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_ciphers        HIGH:!aNULL:!MD5;
        client_max_body_size 80M;
        server_tokens off;

        include  "/opt/bitnami/nginx/conf/server_blocks/*.conf";
    }

** serverblock **

upstream backend {
  server 1.2.3.4:8000;
  server 2.2.3.4:8000;
  server 3.2.3.4:8000;
  server 4.2.3.4:8000;
}
server {
  listen 0.0.0.0:8080;
  location / {
      proxy_pass http://backend;
  }

  location /status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
  }
}

从NGINX指标或检查容器的资源用途中没有任何脱颖而出。

有没有人建议您在调试之后要调查的内容或罪魁祸首可能是什么?

感谢您的帮助。

I setup a nginx load balancer for 4 blockchain clients and am getting lower requests per second by load testing with k6 through the load balancer than I do if I target an individual node. All of the nodes are responding to equal amount of traffic and none of them seem to be responding slower than the next.

The load balancer is setup with the bitnami nginx helm chart and the blockchain clients are running on their own VMs.

**nginx.conf**

    # Based on https://www.nginx.com/resources/wiki/start/topics/examples/full/#nginx-conf
    # user              www www;  ## Default: nobody;

    load_module modules/ngx_http_geoip2_module.so;
    load_module modules/ngx_stream_geoip2_module.so;

    worker_processes  auto;
    error_log         "/opt/bitnami/nginx/logs/error.log";
    pid               "/opt/bitnami/nginx/tmp/nginx.pid";

    events {
        worker_connections  1024;
    }

    http {
        include       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    "/opt/bitnami/nginx/logs/access.log";
        add_header    X-Frame-Options SAMEORIGIN;

        client_body_temp_path  "/opt/bitnami/nginx/tmp/client_body" 1 2;
        proxy_temp_path        "/opt/bitnami/nginx/tmp/proxy" 1 2;
        fastcgi_temp_path      "/opt/bitnami/nginx/tmp/fastcgi" 1 2;
        scgi_temp_path         "/opt/bitnami/nginx/tmp/scgi" 1 2;
        uwsgi_temp_path        "/opt/bitnami/nginx/tmp/uwsgi" 1 2;

        sendfile           on;
        tcp_nopush         on;
        tcp_nodelay        off;
        gzip               on;
        gzip_http_version  1.0;
        gzip_comp_level    2;
        gzip_proxied       any;
        gzip_types         text/plain text/css application/javascript text/xml application/xml+rss;
        keepalive_timeout  65;
        ssl_protocols      TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_ciphers        HIGH:!aNULL:!MD5;
        client_max_body_size 80M;
        server_tokens off;

        include  "/opt/bitnami/nginx/conf/server_blocks/*.conf";
    }

**serverBlock**

upstream backend {
  server 1.2.3.4:8000;
  server 2.2.3.4:8000;
  server 3.2.3.4:8000;
  server 4.2.3.4:8000;
}
server {
  listen 0.0.0.0:8080;
  location / {
      proxy_pass http://backend;
  }

  location /status {
    stub_status on;
    access_log   off;
    allow 127.0.0.1;
    deny all;
  }
}

Nothing is standing out from the nginx metrics or from inspecting the resource uses of the containers.

Does anyone have any suggestions for what to look into next to debug this or what the culprit could be?

Thank you for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一瞬间的火花 2025-02-07 05:33:51

最终根本不是Nginx,因为我错误地认为那是瓶颈。设置一个小小的Hello World示例,在负载测试后,我将API网关中的真正瓶颈指向了我。

Ended up not being nginx at all as I wrongly assumed that it was the bottleneck. Setup a little hello world example which after load tests pointed me to the real bottleneck in my API gateway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文