gpt4 book ai didi

nginx - 如何解决 nginx - 连接上游客户端时没有实时上游?

转载 作者:行者123 更新时间:2023-12-04 05:45:48 28 4
gpt4 key购买 nike

目前,我正在运行在 tomcat 上运行的 grails 3 上的系统构建上使用 JMeter 运行负载测试。每秒发送 20k 请求后,我在 nginx 错误日志中看到“连接到上游客户端时没有实时上游”。我们的应用程序是 Multi-Tenancy 基础,所以我需要执行高负载。这是我的 nginx 配置。

worker_processes  16;
worker_rlimit_nofile 262144;
error_log /var/log/nginx/error.log;

events {
worker_connections 24576;
use epoll;
multi_accept on;
}


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

sendfile on;
keepalive_timeout 600;
keepalive_requests 100000;
access_log off;
server_names_hash_max_size 4096;
underscores_in_headers on;
client_max_body_size 8192m;
log_format vhost '$remote_addr - $remote_user [$time_local] $status "$request" $body_bytes_sent "$http_referer" "$http_user_agent" "http_x_forwarded_for"';

proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 120;


gzip on;
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss image application/javascript;
gzip_min_length 1000;
gzip_static on;
gzip_vary on;
gzip_buffers 16 8k;
gzip_comp_level 6;
gzip_proxied any;
gzip_disable "msie6";

proxy_intercept_errors on;
recursive_error_pages on;

ssl_prefer_server_ciphers On;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-RC4-SHA:ECDHE-RSA-AES256-SHA:RC4-SHA;
include /etc/nginx/conf.d/*.conf;
}

如何配置高并发负载?

最佳答案

对我来说,问题出在我的 proxy_pass 条目上。我有

location / {
...
proxy_pass http://localhost:5001;
}

这导致上游请求使用 IP4 本地主机 IP 或 IP6 本地主机 IP,但时不时地,它会使用没有端口号的本地主机 DNS,导致上游错误,如下面的日志所示。
[27/Sep/2018:16:23:37 +0100] <request IP> - - - <requested URI>  to: [::1]:5001: GET /api/hc response_status 200
[27/Sep/2018:16:24:37 +0100] <request IP> - - - <requested URI> to: 127.0.0.1:5001: GET /api/hc response_status 200
[27/Sep/2018:16:25:38 +0100] <request IP> - - - <requested URI> to: localhost: GET /api/hc response_status 502
[27/Sep/2018:16:26:37 +0100] <request IP> - - - <requested URI> to: 127.0.0.1:5001: GET /api/hc response_status 200
[27/Sep/2018:16:27:37 +0100] <request IP> - - - <requested URI> to: [::1]:5001: GET /api/hc response_status 200

如您所见,“localhost:”的状态为 502

将我的 proxy_pass 更改为 127.0.0.1:5001 意味着所有请求现在都使用带有端口的 IP4。

StackOverflow response 对查找问题有很大帮助,因为它详细说明了更改日志格式以查看问题。

关于nginx - 如何解决 nginx - 连接上游客户端时没有实时上游?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49767001/

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