Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29986
  • 博文数量: 15
  • 博客积分: 385
  • 博客等级: 一等列兵
  • 技术积分: 210
  • 用 户 组: 普通用户
  • 注册时间: 2011-03-27 13:27
文章分类

全部博文(15)

文章存档

2013年(3)

2012年(2)

2011年(10)

我的朋友

分类: LINUX

2011-06-28 12:36:10

 
thundering herd 惊群  涉及accept,epoll_wait
Leader/Follower L/F
Master/Slave M/S

 
nginx.conf:
daemon off;//default on
master_process on;//if off,那么worker_processes,worker_threads都是不会被使用的,也就是说是单进程的。
worker_processes   2;//if master_process on,多进程才有可能。
worker_threads     3;//不一定被所有的nginx version 所支持,
以2011-06-01 nginx-1.0.4和2011-05-25 nginx-1.0.3为例:
nginx-1.0.4编译时都找不到threads的痕迹了,nginx-1.0.3需作如下修改就能支持threads,
/auto/options USE_THREADS=pthreads ,/auto/summary 注释$USE_THREADS检测,这样在objs下编译时生成的ngx_auto_config.h中有 #define NGX_THREADS  1
在objs下编译时还会生成ngx_modules.cngx_modules里面定义了要加载的module.
 
nginx一般依赖的库:
pcre(rewrite) zlib crypt crypto
 
ngx_modules.c查找ngx_modules-->ngx_epoll_module, epoll一般为首选,只要系统支持。
 
谈一下nginx.conf中的server,listen[port]的程序解析流程:
server {
        listen       80;
        server_name  localhost;
......
ngx_cycle.c:ngx_init_cycle()--> initialize [cycle->listening.elts ,nelts] -->ngx_conf_parse()-->ngx_conf_handler()--[cmd->set(cf, cmd, conf);]-->ngx_http.c: ngx_http_commands.ngx_http_block()-->ngx_http_optimize_servers()-->ngx_http_init_listening()-->ngx_http_add_listening()-->ngx_connection.c: ngx_create_listening() ngx_array_push(&cf->cycle->listening);
 
 
 
 
 
阅读(704) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~