3 ms·
1. Look at the code. Especially src/core. 2. Nginx is a software pipeline, it has same ideas behind its design as modern CPUs. 3. Look at the code.
by dschiptsov 13y ago
1. Look at the code. Especially src/core.
2. Nginx is a software pipeline, it has same ideas behind its design as modern CPUs.
3. Look at the code.
- future_grad 13y agoGreat advice. http://tomoconnor.eu/blogish/gwan-snakeoil-beware/ http://tomoconnor.eu/blogish/gwan-snakeoil-beware/ was a good read.
- dschiptsov 13y agoOh, I see - yet another MongoDB.)
- FooBarWidget 13y agoI know it's cool to say good things about Nginx, and Nginx is good software, but your point (2) doesn't mean anything. I'd like to see some serious research and explanation into Nginx's code. Full disclosure: I'm one of the authors behind the Phusion Passenger application server (https://www.phusionpassenger.com https://www.phusionpassenger.com), built on Nginx. What I'm saying here is based on my experience with Nginx module development and research into Nginx code. As far as I see, the main reason why Nginx is fast is because the programmer is brilliant. No, seriously. Look at the code. There are almost no comments, there are no unit tests, and yet Nginx has no well-known stability bugs, or even performance regressions. There are also tons of micro-optimizations, some of which are of questionable nature on modern CPUs (e.g. the huge switch statements in the HTTP parser). The Nginx code goes into great pain to ensure that there are no unnecessary copies or memory allocation. Everything assumes that you use static string structs that point to already-allocated memory instead of dynamically allocated strings. In return, writing an Nginx module requires extreme programmer discipline. Almost everything is hard. Compared to Apache, Nginx's main reason for being faster is because (1) it's evented and (2) it has a lot less features than Apache. No .htaccess - implementing .htaccess is a huge performance penalty because suddenly on every request you have to perform additional filesystem operations. No dynamic spawning of processes (unless you use Phusion Passenger). No dynamic loadable modules, so if you want to add anything you have to recompile Nginx entirely.
- dschiptsov 13y agoNginx is fast is because the programmer is brilliant. isn't it enough?) What I'm saying is that it is a good software. I don't even care that it was written by Russian guys. The code speaks for itself. As for praising, well, I had no intention to read the code very carefully, but what I been able to gather from it, it was well-designed before being written, and it evented nature - processing multiple requests at different stages in a single process, looks very much like a instruction pipeline of a modern CPU, at least to me. That's, probably, the reason behind its name - an engine.
- FooBarWidget 13y agoI don't really get the comparison with CPUs though. Pipelines, even software pipelines, have existed long before CPUs used them.