Nginx Tuning

Alright here is the situtation. I have nginx and with passenger
running. I
can send load to the server and after a certain point I just start
getting
500’s back. I have not been able to see what is causing it. I have
made
tweaks to the config based on some blog posts but I can’t get past a
certain
point. I get to about 1400 requests per minute and than start seeing
500s.
The configs are below. It almost seems like I might be hitting an OS or
server limit that I can’t seem to find. The server is a 8CPU, 8GB
cloud
server.

nginx.conf

user www-data;
worker_processes 8;
worker_rlimit_nofile 30000;

error_log /var/log/nginx/error.log debug;
pid /var/run/nginx.pid;

events {
worker_connections 3500;
use epoll;
}

http {

log_format main
‘$status:$request_time:$upstream_response_time:$pipe:$body_bytes_sent
$connection $
remote_addr $host $remote_user [$time_local] “$request” “$http_referer”
“$http_user_agent” “$http_x_f
orwarded_for” $upstream_addr $upstream_cache_status “in: $http_cookie”’
include /etc/nginx/mime.types;
default_type application/octet-stream;

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

sendfile on;
tcp_nopush on;
tcp_nodelay on;

keepalive_requests 100;
keepalive_timeout 65;

gzip on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_vary off;
gzip_types text/plain text/css application/x-javascript text/xml
application/xml application/rss+xm
l application/atom+xml text/javascript application/javascript
application/json text/mathml;
gzip_min_length 1000;
gzip_disable “MSIE [1-6].”;

variables_hash_max_size 1024;
variables_hash_bucket_size 64;
server_names_hash_bucket_size 64;
types_hash_max_size 2048;
types_hash_bucket_size 64;

include /etc/nginx/conf.d/.conf;
include /etc/nginx/sites-enabled/
;
}

site.conf

server {
listen 0.0.0.0:80;
location ~ ^/api/.* {
include /etc/nginx/conf.d/include/restrict.include;
}

redirect http to https

location ~ .* {
return 301 https://$host$request_uri;
}
}

server {
listen 0.0.0.0:443;
server_name somesite.net;

set client body size to 15M, to address file upload limitations

client_max_body_size 15M;

include /etc/nginx/conf.d/actual_config/*.include;

ssl on;
ssl_certificate /etc/nginx/self_signed;
ssl_certificate_key /etc/nginx/cert.key;

Display the maintenance page if it exists

if (-f $document_root/system/maintenance.html){
rewrite ^(.*)$ /system/maintenance.html last;
break;
}

If the file exists as a static file serve it directly without

running all the other rewite tests on it

if (-f $request_filename) {
break;
}

this is the meat of the rails page caching config

it adds .html to the end of the url and then checks

the filesystem for that file. If it exists, then we

rewite the url to have explicit .html on the end

and then send it on its way to the next config rule.

if there is no file on the fs then it sets all the

necessary headers and proxies to our upstream mongrels

if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}

Use any statically compressed javascript or stylesheet files

location ~* ^/(javascripts|stylesheets)/.*.(js|css) {
#gzip_static on;
}
}

passenger.conf

passenger_root
/opt/ruby/lib/ruby/gems/2.2.0/gems/passenger-enterprise-server-5.0.24;
passenger_ruby /opt/ruby/bin/ruby;
passenger_max_pool_size 31;
passenger_min_instances 31;
passenger_pre_start https://llocalhost;
passenger_log_level 2;

site.conf

location / {
passenger_enabled on;
rails_env lt;

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

passenger_base_uri /;
alias /home/sites/site/current/public/$1;
passenger_app_root /home/sites/site/current;
index index.html index.htm;
}

#Asset displaying.
location ~ ^/(assets)/ {
gzip_static on;
expires max;
add_header Cache-Control public;
root /home/sites/site/current/public;
}

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,264775,264775#msg-264775

You should check the nginx error log as it may have vital clues to
resolve
this.

I just keep seeing things like this.

2016/02/24 17:04:56 [info] 5989#0: *108120 client 127.0.0.1 closed
keepalive
connection

When I get the 500 that is all I get. The location of the call that was
getting made and a 500.

Posted at Nginx Forum:
https://forum.nginx.org/read.php?2,264775,264782#msg-264782

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs