nginx's so_keepalive timeout and related Subtotal

KeepAlive

Here is a TCP keepalive probe alive mechanism:

[root@ ~]# sysctl -a  |grep tcp_keepalive
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 75

Parameters explanation:

  • tcp_keepalive_time 1200, 1200 tcp seconds if no data transmission link is established, the packet will be sent live EXPLORATION
  • tcp_keepalive_probes 9, sent a total of 9 times
  • tcp_keepalive_intvl 75, at intervals of 75 seconds

KeepAlive is not enabled by default, with no option to open a global KeepAlive TCP on Linux systems. Applications need to open a separate KeepAlive must be turned in at the TCP socket.

TCP socket there are three options for the kernel and correspondence, set for a single socket by setsockopt system call:

  • TCPKEEPCNT: covering tcpkeepaliveprobes
  • TCPKEEPIDLE: covering tcpkeepalivetime
  • TCPKEEPINTVL: covering tcpkeepalive_intvl

Nginx

server {
    listen 127.0.0.1:3306 so_keepalive=on;
    proxy_pass 172.17.0.3:3306;
    
    #建立连接时间
    proxy_connect_timeout 5s;
    #保持连接时间
    proxy_timeout 3600s;
    error_log /data/logs/my.log info;

so_keepalive=on|off|[keepidle]:[keepintvl]:[keepcnt]

  • on: Enables detection system default parameters more
  • off: Close
  • keepidle: waiting time
  • keepintvl: sending a probe packet interval
  • keepcent: the number of probe packets sent

proxy_timeout: After setting up a connection with the backend server connection when no data retention time, default 75s.

proxy_connect_timeout: Timeout in connection with the backend server, not more than 75s.

proxy_send_timeout: After issuing the write request to the backend server group, wait for a response over time of 60 seconds by default.

proxy_read_timeout: read request is issued to the back-end server group, wait for a response over time of 60 seconds by default.

Guess you like

Origin www.cnblogs.com/wshenjin/p/11354123.html