Skip to content

Instantly share code, notes, and snippets.

@macghriogair
Last active January 16, 2020 10:24
Show Gist options
  • Save macghriogair/1bd25ca52c247b1d8b7126bfe5dd57ed to your computer and use it in GitHub Desktop.
Save macghriogair/1bd25ca52c247b1d8b7126bfe5dd57ed to your computer and use it in GitHub Desktop.
[Nginx php-fpm optimization]

PHP-FPM

pm = dynamic
pm.max_children = 100
pm.start_servers = 25
pm.min_spare_servers = 5
pm.max_spare_servers = 50
pm.max_requests = 500

Nginx

worker_processes auto;
worker_rlimit_nofile 100000;

events {
	#worker_connections 768;
	worker_connections 4000;
	multi_accept on;
}

http {
	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	gzip on;
	#gzip_static 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/html is always compressed by HttpGzipModule
	  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;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;


	reset_timedout_connection on;

	# request timed out -- default 60
	client_body_timeout 10;
	# if client stop responding, free up memory -- default 60
	send_timeout 2;
	# server will close connection after this time -- default 75
	keepalive_timeout 30;
	# number of requests client can make over keep-alive -- for testing environment
	keepalive_requests 100000;

	fastcgi_read_timeout 1800;
	proxy_read_timeout 1800;
} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment