Related Configuration
The nginx upstream persistent connection is controlled by the keepalive command in upstream mode and specifies the number of connections that can be used for persistent connections. The configuration example is as follows:
upstream http_backend {
server 127.0.0.1:8080;
keepalive 16;
}
server {
...
location /http/ {
proxy_pass http://http_backend;
proxy_http_version 1.1;
proxy_set_header Connection "";
...
}
}
Currently, nginx only supports reverse proxy to the server configured under upstream. It does not support servers directly configured by the proxy_pass command, and does not support variables contained in the proxy_pass parameter. In addition, to support persistent connections, you need to configure the use of http1.1 protocol (although HTTP 1.0 can achieve persistent connections by setting the connection request header to "keep-alive", this is not recommended ).
In addition, because the httpproxy module sets the connection header of the reverse proxy request to close by default, you also need to clear the connection header here (clear the header to avoid sending this header, in HTTP 1.0, persistent connections are used by default ).
Problem: nginx and the backend upstream servers are all short links. In this way, nginx will consume a lot of time and bandwidth when sending requests to the upstream backend. If nginx and the upstream backend establish a long link, from a request initiated by nginx, you can select a suitable persistent link to the upstream backend server, which can save bandwidth and increase the response speed.
1. Introduction to nginx upstream persistent links and implementation methods
Http://bollaxu.iteye.com/blog/900424
2. Comparison of website TPS Performance Improvement Using nginx keepalive
Http://sohulinux.blog.sohu.com/180744817.html
This article is from the "xficc" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1565171
Nginx upstream keepalive analysis to maintain persistent connections