zoukankan      html  css  js  c++  java
  • nginx及基本原理

    1、nginx的注意事项

    epoll模型会有的惊群现象:当有新的请求来临时,所有的worker进程都会被唤醒,但只有一个请求可以执行accept方法,因此nginx采用了accept_mutex锁来解决这个问题,保证只有一个worker进程在监听。

    2、nginx的安装

      gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

      ./configure --prefix=/usr/local/nginx
      make && make install

    3、nginx的优点:

      1、nginx的epoll模型使用

      2、nginx的sendfile技术使用

      3、worker进程之间通过共享内存、原子操作等一些进程间通信机制来实现负载均衡

      4、accept_mutex是Nginx的负载均衡锁

      5、nginx的worker进程数最好设置与CPU核心数相等,最好每一个worker进程都绑定一个特定的CPU核心,这样子的话进程间切换的代价是最小的。

      6、nginx的进程通信:共享内存、套接字、信号。

    4、nginx的命令行操作

      (1)启动  /usr/local/nginx/sbin/nginx

      (2)测试配置文件  /usr/local/nginx/sbin/nginx -t

      (3)查看版本信息  /usr/local/nginx/sbin/nginx -v

      (4)显示编译阶段的参数  /usr/local/nginx/sbin/nginx -V

      (5)强制停止  /usr/local/nginx/sbin/nginx -s stop

      (6)优雅的停止服务  /usr/local/nginx/sbin/nginx -s quit

      (7)重新加载配置文件  /usr/local/nginx/sbin/nginx -s reload

      (8)日志文件回滚  /usr/local/nginx/sbin/nginx -s reopen

  • 相关阅读:
    centos7.3部署memcached服务
    tomcat一闪而过,无法开启
    Windows系统因“CredSSP加密Oracle修正”无法远程连接
    猴子和打字机
    特修斯之船
    爱因斯坦的光线
    10个著名的思想实验(2)
    10个著名的思想实验1
    快速排序
    快速排序的c++实现
  • 原文地址:https://www.cnblogs.com/erdanyang/p/10862014.html
Copyright © 2011-2022 走看看