PS:本章节我将采用在3M客户现场的实际项目经验与测试结果来展示对应可优化参数

    测试环境:

    测试设备 配置 IP地址
    Client 2 Core 2G Mem 10.1.10.51
    NGINX LB (R22) 4 Core 4G Mem 10.1.10.204
    NGINX Web Server (R22) 4 Core 4G Mem 10.1.10.205/10.1.20.205
    wrk -c 100 -t 2 -d 1m http://10.1.10.205/picturefill.js
    wrk -c 100 -t 2 -d 1m http://10.1.10.204/picturefill.js

    压测所用web资源:picturefill.js
    Nginx Performance Test - 图1

    结果汇总:

    优化场景 Request/Second Latency ms (Avg)
    直接压服务器 59846 2.43
    NGINX默认配置 23083 25.24
    优化Worker Connection 22948 18.67
    配置连接复用 41968 2.37
    配置CPU亲和及Worker优先级 41289 2.58
    配置日志缓存 46668 2.28
    配置Cache 42945 2.44
    优化CPU开销 44847 2.45

    Nginx Performance Test - 图2
    Nginx Performance Test - 图3

    优化一:直接进行压力测试
    Nginx Performance Test - 图4

    保持nginx默认配置不变:
    Nginx Performance Test - 图5

    Nginx Performance Test - 图6

    优化二:优化worker_connections
    Nginx Performance Test - 图7

    Nginx Performance Test - 图8

    优化三:配置链接复用
    Nginx Performance Test - 图9
    开启连接复用前server端连接数
    Nginx Performance Test - 图10
    开启连接复用后server端连接数
    Nginx Performance Test - 图11

    Nginx Performance Test - 图12

    优化四:配置CPU亲和及worker优先级
    Nginx Performance Test - 图13

    Nginx Performance Test - 图14

    优化五:配置日志缓存
    Nginx Performance Test - 图15

    Nginx Performance Test - 图16

    优化六:配置Cache
    Nginx Performance Test - 图17

    Nginx Performance Test - 图18

    优化七:优化cpu开销
    Nginx Performance Test - 图19

    Nginx Performance Test - 图20