Lets Get Dugg!



Ill keep it short; SMF > rc.d

# ps -ef | grep -i thttpd    
    root  3919  6938   0 15:45:16 pts/6       0:00 grep -i thttpd
webservd 18619   592   0   Jun 11 ?           0:54 /opt/extra/sbin/thttpd -C thttpd.conf

Now...

# kill -9 18619
# ps -ef | grep -i thttpd
webservd  4017   592   0 15:47:33 ?           0:00 /opt/extra/sbin/thttpd -C thttpd.conf

Automatic service restarts. Solaris is like a nice Cadillac compared to Linux.


Our logs at fabulously40 grow quite large each day. I needed away to rotate our nginx logs so it does not grow uncontrollably.

Here is the recipe

 sh# logadm -w /opt/extra/nginx/logs/fab40.access.log -s 100m -a 'kill -USR1 `cat /opt/extra/nginx/logs/nginx.pid`'
 # check /etc/logadm.conf
 sh# cat /etc/logadm.conf
 # if you wish to test it out right away, run logadm
 sh# /usr/sbin/logadm

Simple no?


We at fabulously40.com use nginx with a java backend. When it came to system service updates, We had no efficient way of displaying a "service out of commission" page. Our typical scenario for this was modifying our nginx configuration and restarting the service to redirect users to a "service out of commission page."

Obviously this isn't really ideal, the whole comment, modify and restart httpd cycle. Here is an excellent solution for redirecting users to a service-out-of-commission page dynamically.

      
	location ~ /(javascripts|images|stylesheets|html)/ {
                root /opt/jetty/production/fab40;
       	}
	location / {
		# ... proxy configuration up here...
            	if (-f /opt/jetty/production/fab40/upgrade) {
               	 rewrite ^(.*)$ /html/upgrade.html last;
                	break;
           	}
		# redirect to proxy
	}

Whenever, Nginx sees the "upgrade" file in /opt/jetty/production/fab40 it redirects all users to /html/upgrade.html. As soon as I remove the "upgrade" file nginx redirects traffic back to the proxy for backend requests.

So our typical upgrade scenario goes like this...


	sh# cd /opt/jetty/production/fab40
	sh# cp /export/home/victori/fab40.war .
	sh# unzip fab40.war
	sh# touch upgrade
	sh# svcadm disable jetty; svcadm enable jetty
	# ... wait a few seconds for the backend to startup...
	sh# rm upgrade 

Nice and simple roll out of our service.


I am not exactly sure why this isn't documented but nginx as of 0.7.x supports event ports

This is a huge performance win for Solaris. Nginx can avoid the 0(n) file descriptor problem with event ports support.

To enable event ports add this to your nginx.conf

events {
    use eventport;
}

Here is our performance-proven configuration that we use on fabulously40

The follow configuration will help you survive massive traffic with nginx. We have served 4.4 million requests in a 4 hour time frame with no issues. That is 305req/sec.

worker_processes  6;
worker_rlimit_nofile 10240;
events {
    worker_connections  8024;
    use eventport;
}
http {
    keepalive_timeout  20;
    server_names_hash_bucket_size 64;
    sendfile        on;
    tcp_nopush     on;
    client_max_body_size 150m;

    gzip  on;
    gzip_comp_level  5;
    gzip_vary        off;
    gzip_proxied    any;
    gzip_types       text/plain text/css text/xml application/xml text/javascript text/html application/x-javascript;
}