Nginx upstream keepalive analysis to maintain persistent connections

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.