Nginx 推送模块性能的测试数据

1、准备

tcp调优: 

  net.core.somaxconn = 2048

net.core.rmem_default = 262144

net.core.wmem_default = 262144

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

 

net.ipv4.tcp_rmem = 4096 4096 16777216

net.ipv4.tcp_wmem = 4096 4096 16777216

//这两个参数可以减少为1024,减少内存的开销,但速度会下降

 

net.ipv4.tcp_mem = 786432 2097152 3145728

//这个值很重要,可以在运行时通过 cat /proc/net/sockstat查看,最大值需要有内存的支持,

//如果内存支持不了3145728,一样会失败,产生oom错误。

//内核只使用物理内存,不使用swap,oom产生后,swap的内存仍然很大

 

net.core.netdev_max_backlog = 20000

net.ipv4.tcp_fin_timeout = 15

net.ipv4.tcp_max_syn_backlog = 16384

//这个值设置的太大没有用,因为nginx里面定义了#define NGX_LISTEN_BACKLOG        511

//需修改代码,重新编译。

 

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_max_orphans = 131072

Nginx 设置:

pid         logs/nginx.pid; error_log   logs/error.log info;

# Development Mode #master_process      off; #daemon              off; #worker_rlimit_core  500M; #working_directory /tmp/nginx;

worker_processes    8; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; worker_priority -1;

events {     worker_connections  1000000;     use                 epoll; }

tcp_nopush                      off;     tcp_nodelay                     on;     keepalive_timeout               1800000;     #send_timeout                    10;     client_body_timeout             18000000;     client_header_timeout           18000000;     sendfile                        on;     client_header_buffer_size       40k;     large_client_header_buffers     40 80k;     client_max_body_size            40k;     client_body_buffer_size         40k;     ignore_invalid_headers          on;

    push_stream_shared_memory_size              2000m;

......

 

 
消息大小:512bytes
推送模块使用的内存较多,使用命令:
ulimit -m unlimited
ulimit -v unlimited
去掉对用户的内存限制。
  
2、测试环境
   通过LVS转发,server的内存为16G,4个client内存为4G,CPU为8核
 
3、测试结果
     
  
  

连接数

连接创建时间(millisecond)

推送时间(millisecond)

推送速度

(条/毫秒)

CPU活跃数

消息到达率

1万

1902

585

17

1

100%

5万

9513

2884

17

1

100%

10万

10007/ 13343

3204

31

2

100%

15万

10317/14587

/9906

14194

10

4

100%

20万

11020/ 31242

/ 53399/ 68179

4909

40

4

100%

 
  
  
  

 channel数

连接数

CPU活跃数

推送时间(millisecond)

推送速度

(条/毫秒)

消息到达率

100

10000

1

705

14

100%

1000

10000

1

1142

8

100%

10000

10000

1

124845

0.08

100%

 
  
  
  

连接数

消息数/管道数

消息数

推送时间(millisecond)

推送速度

(条/毫秒)

CPU活跃数

消息到达率

1万

100/100

100万

44699

22

1

100%

5万

100/100

500万

222304

22

1

100%

10万

100/100

1000万

208355

48

4

100%

20万

100/100

2000万

675115

30

4

100%

 
  
  
  

连接数

消息数/管道数

消息数

推送时间(millisecond)

推送速度

(条/毫秒)

CPU活跃数

消息到达率

1万

100/100

100万

45479

21

1

100%

5万

100/100

500万

225211

22

1

100%

10万

100/100

1000万

287552

34

2

100%

20万

100/100

2000万

565293

41

5

100%

 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

淡定的茶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值