Help optimizing the server for Wordpress (Ubuntu + Nginx + Varnish)

July 18, 2013 7k views
Hi, I'm trying to optimize my server and would be great if someone could help me with the best configuration. The server will be used only to host Wordpress sites (multiple domains), currently I'm using a 2 core/ 2Gb droplet with Ubuntu 12.04 x64 + Nginx + Varnish. Here are my configs so far: -------------Nginx------------- user www-data; worker_processes 4; pid /var/run/nginx.pid; events { worker_connections 768; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; port_in_redirect off; server_names_hash_bucket_size 64; include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; gzip on; gzip_disable "msie6"; } ---------------------------------- -------------Varnish------------- START=yes NFILES=131072 MEMLOCK=82000 DAEMON_OPTS="-a :80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -S /etc/varnish/secret \ -s malloc,1500m" ---- .connect_timeout = 600s; .first_byte_timeout = 600s; .between_bytes_timeout = 600s; .max_connections = 800; set req.grace = 2m; set beresp.grace = 2m; ---------------------------------- Is this ok? Am I missing something? Can I improve it? I read some people saying that I could use 'file' instead of 'malloc' on varnish to take advantage of the SSD disks, would it be better? Thank you, any thoughts would be really appreciate.
7 Answers
Hi there,

I'm no expert, but the number of Nginx worker_processes is too high. Nginx only needs one worker process per available core. So you only need 2. Although it doesn't really matter since Nginx's memory usage is so ridiculously insanely low that you can afford to waste processes. :)

Hope this helps!
You might want to set gzip_types in the main nginx.conf to compress types other than the default of just text/html type files, e.g.:

gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
Thanks for the answers people! I've already changed the config as suggested.

Any other suggest are welcome!
Just in case you run across this, I've seen nginx throw 500 errors when updating WordPress posts/pages that contain a lot of data.

Setting client_body_temp_path fixed the problem for me.
@Pablo: Thank you! The links were really helpful. :)
Have another answer? Share your knowledge.