Logo

Armand.nz

Home / About / Linkedin / Github

Nginx keepalive connections

#nginx |

Nginx’s keepalive directive allows you to keep the connection open for a certain number of requests to the server or until the request timeout period expires.

10,000 idle connections use only 2.5 MB of memory- proof that Nginx efficiently manages idle connections due to keepalive connections.

Keepalive profoundly impacts System resources on the Nginx host, which ultimately affects the user experience of the end user (i.e., how quickly a website appears to load ).

Read more about it here: HTTP Keepalive Connections and Web Performance, and also “Mistake 3: Not Enabling Keepalive Connections to Upstream Servers” in Avoiding the Top 10 NGINX Configuration Mistakes

Nginx keepalive connections config example to upstream servers. Nginx upstream HTTP keepalive config example As per Nginx documentation, the key directives of proxy_http_version and proxy_set_header need to be set as per below:

upstream backend {
	server 127.0.0.1:8080;
	keepalive 8;
}

server {
	listen 80;
	location / {
		proxy_pass http://backend;
		proxy_http_version 1.1;
		proxy_set_header Connection "";
}
comments powered byDisqus

Copyright © Armand