NGINX: How do I calculate an optimal no. of worker processes and worker connections?

Posted by bodacious on Server Fault See other posts from Server Fault or by bodacious
Published on 2011-06-11T08:41:26Z Indexed on 2011/06/20 16:25 UTC
Read the original article Hit count: 224

Filed under:
|
|

Our web app is running on a Linode 2048 server at the moment (~ 2048 GB of RAM)

The MYSQL database is on another linode of it's own so this server is really only handling NGINX and and the Rails application.

The application itself uses about 185976 of memory per instance (RSS).

Our traffic is < 1000 per day and the pages are mostly cached so there are fewer hits to the rails app itself.

My question is - how can I calculate optimal NGINX config settings for my app?

Below is the current config:

worker_processes  1;

# pid of nginx master process
pid /var/run/nginx.pid;

events {
  worker_connections  1024;
}


http {

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  passenger_root /home/user/.rvm/gems/ree-1.8.7-2011.01@URTV/gems/passenger-3.0.3;
  passenger_ruby /home/user/.rvm/rubies/ree-1.8.7-2011.01/bin/ruby;

  include       mime.types;
  default_type  application/octet-stream;

  sendfile        on;

  tcp_nopush    on;
  tcp_nodelay   on;

  # gzip settings
  gzip  on;
  gzip_http_version 1.0;
  gzip_comp_level 2; 
  gzip_vary on;
  gzip_proxied any; 
  gzip_types text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  # load extra modules from the vhosts directory
  include /opt/nginx/vhosts/*.conf;
}

Any advice would be appreciated! :)

© Server Fault or respective owner

Related posts about ruby-on-rails

Related posts about nginx