2012/01/05

Nginx - overview - 2



The source folder constructs as:

core -- the core data structures and functions.

event -- event-related data structure etc.

http -- http protocol specific data structures etc.

mail -- since ng also acts as mail server.

misc -- some miscellaneous files.

os -- ng supports multiple os(s), os specific files.

I suppose that Igor is an organized guy in code, since when you compile ng project, no compile warning is outputed. You may be aware that Igor turned on gcc flags: -Wall -Wno-unused-parameter -Wunused-function, -Wunused-variable, -Wunused-value.

I mainly focus on core, event, and http, others might be omitted.

In core folder, many basic data structures are implemented without importing third party library. I wonder why Igor bother to do this. After one month reading, I figured it out: the efficiency concern. Importing extra third party means giving your efficiency control to other unknown guys. Put yourself in third party developers' shoes, at some design trade-off, you could achieve better generic goal by scarifying some time efficiency and memory space. Ooooh, no, wait a minute, that's exactly not what we want. To support high concurrency, we must try very hard to be fast and occupy less memory. Then, you get the point.

To address the structure or design clear, I will posts some picture or flow chart if necessary. Draw tool is avaiable here(http://www.graphviz.org/).

Nginx - preface - 1



Lately, the design of nginx attracted my attention. So, I started to hack the nginx source and try to deep understand inside. FYI, you can download the source code from nginx.org(Or direct download from http://sharesend.com/20amd). FYI, the term "ng" is short for nginx.

The recommended version choice is 1.1.4. The reasons lie as follows:
1) The total lines is about 100,000. With my limited time, this could be the better choice.
2) I've been using this version for a while, kind of familiar.
3) The main feature of HTTP server are ready to go.

After days of search, I found these following related resources available. Hope it would save you bunch of time :)
1)LXR http://lxr.evanmiller.org/http/source/ (Only support version 1.0.11 and 1.1.12)
2)Geek blog http://blog.sina.com.cn/s/blog_677be95b0100iivb.html (Brief introduce the structure, design pattern, and config specifictions etc. unfortunately, the post is written in Chinese.)
3)Nginx wiki http://wiki.nginx.org (Read the doc and search over the community as you need.)
4)Linux man http://linux.die.net/man/ (Geek like you , may not need this.)
5)Dev guide http://www.evanmiller.org/nginx-modules-guide.html (Advanced tutorial for guys that want to get their hands dirty. )

Maybe some day, another guy would add this blog to the tail of his recommend list.

Just as Linus said, “RTFSC", Let's do this.