Wednesday, February 17, 2010

My fling with engine X.

Projects that have X in the name are cool. Engines are cool (especially steam powered ones). Spelling engine 'ngin' gains 17.5 l33t points too. All combined, this makes the name nginx super schwet!

I've been using nginx for a while now, and have found it quite good so far. Been moving a couple of websites to it, fooling around with it a lot.

So far I've been able to use it for everything I've tried. Some of my apache configs are fairly long... so that is saying quite a bit. On my low memory (512MB) server it has saved quite a bit of memory - even though I've only moved over a couple of websites. Along with the cherrypy memory reduction work I did recently, my server has a bit more room to breathe... (and for me to waste memory on hosting other websites! ya!).

Nginx has a good reputation as being rock solid - so I hope it holds true for me. Then perhaps I can get rid of apache completely (on this one server). I've tried to replace apache with other web servers before... but always come up with a reason to move back to apache. Either some application uses a feature that the other server does not support, or the other server is just not as robust as apache. I don't like fixing, or looking at servers... I just want them to work without hassle. I'm not afraid of working, and learning about a new webserver to work... It's just that some webservers are too high maintenance.

Fastcgi is one way nginx allows you to host php and python websites. Nginx can also be used as a reverse proxy server. Personally I like to host python websites with cherrypy and a reverse proxy, and use fastcgi with php. The nginx proxy_pass configuration seems to work quite well... as does its simple-to-setup load balancing.

Like all good software, I love to check out how it was made. Reading the nginx source code is breath of fresh air. Despite Igor[the main author] being Russian, the code is written in english C(with tiny smatterings of asm/perl)... with very few comments. It is a modular, and very clean code base. It doesn't seem to have any unittests... but it's still quality software.

Our relationship is still a fling really. Before I invite nginx to meet my parents, I'll give it few more months. Ok, my love letter to nginx is done now.


ludovicofischer said...

Have you tried using Nginx in front of Apache as a proxy? You configure nginx to serve the css, images etc., but you still hand over to Apache to run the dynamic parts and take care of the associated rewrites. That way you benefit of nginx's speed without bothering with fastcgi and translating every mod_rewrite rule.

illume said...


that sounds good. So far doing that with just a couple of sites that has given my server more resources.

Using proxies seems fairly easy... like so:

location ~ \.php$ {
proxy_pass http://apache_url/;

For this one server it's about reducing memory usage... so to get better savings I'll have to stop using apache entirely. Probably not worth the effort for that reason alone... but maybe worth it to learn more about nginx.