Report this

What is the reason for this report?

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

Posted on July 18, 2013

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.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there, <br> <br>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. :) <br> <br>Hope this helps!

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. <br> <br>Setting client_body_temp_path fixed the problem for me.

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.: <br> <br> gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.