• Nginx核心知识100讲学习笔记(陶辉)Nginx架构基础(四)


    一、红黑树

    1、红黑树


    2、红黑树复杂度

    3、使用红黑树的模块

    1、本地内存做的红黑树

    ngx_conf_module 
    ngx_event_timer_rbtree #管理定时器的红黑树

    2、管理定时器的红黑树

    Ngx_http_file_cache
    Ngx_http_geo_module
    Ngx_http_limit_conn_module
    Ngx_http_limit_req_module
    Ngx_http_lua_shdict:ngx.shared.DICT  #LRU链表性质
    resolver   #ngx_resolver_t
    Ngx_stream_geo_module
    Ngx_stream_limit_conn_module

    二、使用动态模块来提升运维效率

    1、动态库和静态库有什么区别?

    静态库直接把所有的源代码编译到最终的二进制中

    动态库在nginx可执行文件里保留了调用它的地址、在需要用到动态库的功能时由nginx的可执行文件去调用这个动态库

    2、动态库的应用场景

    这里的好处是:当我们仅仅需要修改某一个模块或者升级某个模块功能时、这时候我可以仅仅编译这个动态库就可以升级的时候用新的动态文件替换掉旧的动态文件即可

    1、那些模块是支持动态模块的

    [root@ceph-client openresty-1.13.6.2]# ./configure --help|grep "=dynamic"
      --with-http_xslt_module=dynamic    enable dynamic ngx_http_xslt_module
      --with-http_image_filter_module=dynamic
      --with-http_geoip_module=dynamic   enable dynamic ngx_http_geoip_module
      --with-http_perl_module=dynamic    enable dynamic ngx_http_perl_module
      --with-mail=dynamic                enable dynamic POP3/IMAP4/SMTP proxy module
      --with-stream=dynamic              enable dynamic TCP/UDP proxy module
      --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module  

    3、静态模块工作原理

     4、动态模块运行流程

    三、动态模块安装

     1、安装流程图

    2、安装过程

    1、Configure加入动态模块

    ./configure --prefix=/home/geek/nginx  --with-http_image_filter_module=dynamic

    2、编译进binary

    make && make install

    3、启动时初始化模块数组

    4、读取load_module配置

    load_module modules/ngx_http_image_filter_module.so;

    5、打开动态库并加入模块数组

    6、基于模块数组开始初始化

    四、动态模块使用前后对比

    1、未使用动态模块

    nginx配置

    location / {
         root /test;
    }
    nginx -s reload [root@nginx ~]# ll /test/ total 288 -rw-r--r-- 1 root root 294408 Aug 21 17:18 1.png

    验证

    2、使用动态模块

    nginx配置

    load_module modules/ngx_http_image_filter_module.so
    image_filter resize 150 100;
    nginx -s reload

    验证效果

  • 相关阅读:
    背景透明度IE兼容性代码
    酷站收藏
    洛谷P1142 轰炸 数学
    洛谷P1282 多米诺骨牌
    洛谷P1247 取火柴游戏 数学题 博弈论
    洛谷P1135 奇怪的电梯 广搜
    洛谷P1077 摆花 动态规划
    洛谷P1161 开灯 数学
    洛谷P1154 奶牛分厩 数学
    洛谷P2147 [SDOI2008]Cave 洞穴勘测 Link-Cut Tree LCT
  • 原文地址:https://www.cnblogs.com/luoahong/p/12409545.html
Copyright © 2020-2023  润新知