zoukankan      html  css  js  c++  java
  • 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

    验证效果

  • 相关阅读:
    树分治
    实现自己的shell--MIT xv6 shell
    逆元打表
    Linux fork()函数
    三分:求解凸函数极值
    anti-nim 游戏
    nginx配置文件详解
    nginx之别名、location使用
    shell脚本编程基础知识点
    linux任务计划
  • 原文地址:https://www.cnblogs.com/luoahong/p/12409545.html
Copyright © 2011-2022 走看看