nginx reverse proxy is slow, got 499 when load testing and have high upstream_connect_timeHelp needed setting...
El Dorado Word Puzzle II: Videogame Edition
Does the Crossbow Expert feat's extra crossbow attack work with the reaction attack from a Hunter ranger's Giant Killer feature?
Unable to disable Microsoft Store in domain environment
Is there a distance limit for minecart tracks?
Overlapping circles covering polygon
Why does the Persian emissary display a string of crowned skulls?
Can I run 125kHz RF circuit on a breadboard?
Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?
Deciphering cause of death?
How can I, as DM, avoid the Conga Line of Death occurring when implementing some form of flanking rule?
Echo with obfuscation
Grepping string, but include all non-blank lines following each grep match
What happens if I try to grapple mirror image?
Limit max CPU usage SQL SERVER with WSRM
If Captain Marvel (MCU) were to have a child with a human male, would the child be human or Kree?
Why is the principal energy of an electron lower for excited electrons in a higher energy state?
Ways of geometrical multiplication
How do I fix the group tension caused by my character stealing and possibly killing without provocation?
Anime with legendary swords made from talismans and a man who could change them with a shattered body
ContourPlot — How do I color by contour curvature?
Animation: customize bounce interpolation
How to I force windows to use a specific version of SQLCMD?
Personal or impersonal in a technical resume
SOQL query causes internal Salesforce error
nginx reverse proxy is slow, got 499 when load testing and have high upstream_connect_time
Help needed setting up nginx to serve static filesTrouble with nginx and serving from multiple directories under the same domainNginx load balancing redirects to upstream “name”NGINX don't parse .php5 as .phpnginx sending incomplete responseNginX + WordPress + SSL + non-www + W3TC vhost config file questionsChange Nginx document root from /usr/share/nginx to /etc/nginxHow do we configure nginx to prevent proxy abuse?Did someone succeeded in getting to my server?Redirect in nginx port not showing up
We are load testing one of our application server using Gatling sending ~150 req/s. When we load test by calling the application server directly, everything works fine but when we are calling through nginx which act as a reverse proxy, there are a lot of timeouts (60s) at Gatling.
Looking at nginx logs we saw cases where upstream_connect_time would be '-'
{"log":""20/Mar/2019:08:26:16 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=499 bytes_sent=0 body_byt
es_sent=0 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172
.30.106.47:80 upstream_status=- request_time=60.000 upstream_response_time=- upstream_connect_time=- upstream_header_time=-n","stream":"stdout","time":"2019-03-20T08:
26:16.593007324Z"}
or in some cases, upstream_connect_time goes to 31s
{"log":""20/Mar/2019:08:26:00 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=200 bytes_sent=280 body_bytes_sent=12 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172.30.106.47:80 upstream_status=200 request_time=31.154 upstream_response_time=31.154 upstream_connect_time=31.080 upstream_header_time=31.154n","stream":"stdout","time":"2019-03-20T08:26:00.355564536Z"}
So we imagine this could be something related to connections to an upstream server. We've tried enabled keepalive but it doesn't help. When we tried lower the workers_connection to 512, we would get an error saying 'workers_connection are not enough'. Below is our nginx.conf. What could be the problem here?
user nginx;
worker_processes auto;
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1000;
use epoll;
multi_accept on;
}
http {
log_format main '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';
access_log /var/log/nginx/access.log main;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 10240;
gzip_comp_level 1;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_requests 100000;
upstream backend {
server 172.30.106.47:80;
keepalive 128;
}
server {
listen 80;
server_name localhost;
location = /health {
return 200;
}
location /status {
stub_status on;
}
location / {
proxy_buffers 32 4m;
proxy_busy_buffers_size 25m;
proxy_buffer_size 512k;
proxy_max_temp_file_size 0;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 4m;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_intercept_errors off;
stub_status on;
proxy_pass http://backend;
}
location = /50x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
}
}
nginx reverse-proxy
New contributor
add a comment |
We are load testing one of our application server using Gatling sending ~150 req/s. When we load test by calling the application server directly, everything works fine but when we are calling through nginx which act as a reverse proxy, there are a lot of timeouts (60s) at Gatling.
Looking at nginx logs we saw cases where upstream_connect_time would be '-'
{"log":""20/Mar/2019:08:26:16 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=499 bytes_sent=0 body_byt
es_sent=0 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172
.30.106.47:80 upstream_status=- request_time=60.000 upstream_response_time=- upstream_connect_time=- upstream_header_time=-n","stream":"stdout","time":"2019-03-20T08:
26:16.593007324Z"}
or in some cases, upstream_connect_time goes to 31s
{"log":""20/Mar/2019:08:26:00 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=200 bytes_sent=280 body_bytes_sent=12 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172.30.106.47:80 upstream_status=200 request_time=31.154 upstream_response_time=31.154 upstream_connect_time=31.080 upstream_header_time=31.154n","stream":"stdout","time":"2019-03-20T08:26:00.355564536Z"}
So we imagine this could be something related to connections to an upstream server. We've tried enabled keepalive but it doesn't help. When we tried lower the workers_connection to 512, we would get an error saying 'workers_connection are not enough'. Below is our nginx.conf. What could be the problem here?
user nginx;
worker_processes auto;
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1000;
use epoll;
multi_accept on;
}
http {
log_format main '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';
access_log /var/log/nginx/access.log main;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 10240;
gzip_comp_level 1;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_requests 100000;
upstream backend {
server 172.30.106.47:80;
keepalive 128;
}
server {
listen 80;
server_name localhost;
location = /health {
return 200;
}
location /status {
stub_status on;
}
location / {
proxy_buffers 32 4m;
proxy_busy_buffers_size 25m;
proxy_buffer_size 512k;
proxy_max_temp_file_size 0;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 4m;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_intercept_errors off;
stub_status on;
proxy_pass http://backend;
}
location = /50x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
}
}
nginx reverse-proxy
New contributor
add a comment |
We are load testing one of our application server using Gatling sending ~150 req/s. When we load test by calling the application server directly, everything works fine but when we are calling through nginx which act as a reverse proxy, there are a lot of timeouts (60s) at Gatling.
Looking at nginx logs we saw cases where upstream_connect_time would be '-'
{"log":""20/Mar/2019:08:26:16 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=499 bytes_sent=0 body_byt
es_sent=0 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172
.30.106.47:80 upstream_status=- request_time=60.000 upstream_response_time=- upstream_connect_time=- upstream_header_time=-n","stream":"stdout","time":"2019-03-20T08:
26:16.593007324Z"}
or in some cases, upstream_connect_time goes to 31s
{"log":""20/Mar/2019:08:26:00 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=200 bytes_sent=280 body_bytes_sent=12 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172.30.106.47:80 upstream_status=200 request_time=31.154 upstream_response_time=31.154 upstream_connect_time=31.080 upstream_header_time=31.154n","stream":"stdout","time":"2019-03-20T08:26:00.355564536Z"}
So we imagine this could be something related to connections to an upstream server. We've tried enabled keepalive but it doesn't help. When we tried lower the workers_connection to 512, we would get an error saying 'workers_connection are not enough'. Below is our nginx.conf. What could be the problem here?
user nginx;
worker_processes auto;
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1000;
use epoll;
multi_accept on;
}
http {
log_format main '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';
access_log /var/log/nginx/access.log main;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 10240;
gzip_comp_level 1;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_requests 100000;
upstream backend {
server 172.30.106.47:80;
keepalive 128;
}
server {
listen 80;
server_name localhost;
location = /health {
return 200;
}
location /status {
stub_status on;
}
location / {
proxy_buffers 32 4m;
proxy_busy_buffers_size 25m;
proxy_buffer_size 512k;
proxy_max_temp_file_size 0;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 4m;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_intercept_errors off;
stub_status on;
proxy_pass http://backend;
}
location = /50x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
}
}
nginx reverse-proxy
New contributor
We are load testing one of our application server using Gatling sending ~150 req/s. When we load test by calling the application server directly, everything works fine but when we are calling through nginx which act as a reverse proxy, there are a lot of timeouts (60s) at Gatling.
Looking at nginx logs we saw cases where upstream_connect_time would be '-'
{"log":""20/Mar/2019:08:26:16 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=499 bytes_sent=0 body_byt
es_sent=0 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172
.30.106.47:80 upstream_status=- request_time=60.000 upstream_response_time=- upstream_connect_time=- upstream_header_time=-n","stream":"stdout","time":"2019-03-20T08:
26:16.593007324Z"}
or in some cases, upstream_connect_time goes to 31s
{"log":""20/Mar/2019:08:26:00 +0000" client=172.30.14.21 method=POST request="POST /api/shopping/log HTTP/1.1" request_length=5672 status=200 bytes_sent=280 body_bytes_sent=12 referer=- user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36" upstream_addr=172.30.106.47:80 upstream_status=200 request_time=31.154 upstream_response_time=31.154 upstream_connect_time=31.080 upstream_header_time=31.154n","stream":"stdout","time":"2019-03-20T08:26:00.355564536Z"}
So we imagine this could be something related to connections to an upstream server. We've tried enabled keepalive but it doesn't help. When we tried lower the workers_connection to 512, we would get an error saying 'workers_connection are not enough'. Below is our nginx.conf. What could be the problem here?
user nginx;
worker_processes auto;
worker_rlimit_nofile 100000;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1000;
use epoll;
multi_accept on;
}
http {
log_format main '"$time_local" client=$remote_addr '
'method=$request_method request="$request" '
'request_length=$request_length '
'status=$status bytes_sent=$bytes_sent '
'body_bytes_sent=$body_bytes_sent '
'referer=$http_referer '
'user_agent="$http_user_agent" '
'upstream_addr=$upstream_addr '
'upstream_status=$upstream_status '
'request_time=$request_time '
'upstream_response_time=$upstream_response_time '
'upstream_connect_time=$upstream_connect_time '
'upstream_header_time=$upstream_header_time';
access_log /var/log/nginx/access.log main;
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 10240;
gzip_comp_level 1;
gzip_vary on;
gzip_disable msie6;
gzip_proxied expired no-cache no-store private auth;
gzip_types
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
image/svg+xml;
reset_timedout_connection on;
client_body_timeout 10;
send_timeout 2;
keepalive_requests 100000;
upstream backend {
server 172.30.106.47:80;
keepalive 128;
}
server {
listen 80;
server_name localhost;
location = /health {
return 200;
}
location /status {
stub_status on;
}
location / {
proxy_buffers 32 4m;
proxy_busy_buffers_size 25m;
proxy_buffer_size 512k;
proxy_max_temp_file_size 0;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 1024m;
client_body_buffer_size 4m;
proxy_connect_timeout 300;
proxy_read_timeout 300;
proxy_send_timeout 300;
proxy_intercept_errors off;
stub_status on;
proxy_pass http://backend;
}
location = /50x.html {
root /usr/share/nginx/html;
}
error_page 500 502 503 504 /50x.html;
}
}
nginx reverse-proxy
nginx reverse-proxy
New contributor
New contributor
New contributor
asked 23 mins ago
hikky36hikky36
1
1
New contributor
New contributor
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
hikky36 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f959228%2fnginx-reverse-proxy-is-slow-got-499-when-load-testing-and-have-high-upstream-co%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
hikky36 is a new contributor. Be nice, and check out our Code of Conduct.
hikky36 is a new contributor. Be nice, and check out our Code of Conduct.
hikky36 is a new contributor. Be nice, and check out our Code of Conduct.
hikky36 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Server Fault!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f959228%2fnginx-reverse-proxy-is-slow-got-499-when-load-testing-and-have-high-upstream-co%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown