随笔 - 502  文章 - 1 评论 - 6 阅读 - 37万
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

Nginx.conf   work_process配置

CPU 亲和绑定 减少进程的切换,减少性能损耗.

worker_processes  16; 
worker_cpu_affinity 0000000000000001 0000000000000010 0000000000000100 0000000000001000 0000000000010000 0000000000100000 
0000000001000000 0000000010000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;

worker_processes 配置的核心数,可以通过top查看, 或者物理CPu个数 * 每个CPU的核数

   worker_cpu_affinity 字符串16表示平均分配

 

查看work process

ps -eo pid,args,psr | grep [n]ginx

 

慕课老师配置

复制代码


user nginx;
worker_processes 16;
#worker_cpu_affinity 0000000000000010 0000000000000010 0000000000000100 0000000000001000 0000000000010000 0000000000100000 0000000001000000 0000000010000000 0000000100000000 0000001000000000 0000010000000000 0000100000000000 0001000000000000 0010000000000000 0100000000000000 1000000000000000;
#worker_cpu_affinity 1010101010101010 0101010101010101;
worker_cpu_affinity auto;


error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

worker_rlimit_nofile 35535;

events {
use epoll;
worker_connections 10240;
}

 

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
#######
#Charset
charset utf-8;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$request_uri"';

access_log /var/log/nginx/access.log main;

#######
#Core modlue
sendfile on;
#tcp_nopush on;
#tcp_nodeny on;
keepalive_timeout 65;

########
#Gzip module
gzip on;
gzip_disable "MSIE [1-6]\.";
gzip_http_version 1.1;

########
#Virtal Server
include /etc/nginx/conf.d/*.conf;
}

复制代码
posted on   1161588342  阅读(517)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
历史上的今天:
2018-07-24 Hive安装 和管理
点击右上角即可分享
微信分享提示