代码非常简单,因为我使用EPOLLONESHOT来创建一个领导者跟随者多线程服务器程序。
我为它运行测试,服务器只是直接回显。当qps达到150000时,12工作线程进入D状态,但服务器没有内存分配,磁盘根本不忙。
如果我继续为它添加更多测试客户端,服务器的qps将不会升高,它只会保持在150000 qps。
这是我所有的服务器,测试客户端和服务器在同一台机器上通过lo(不是phyics网卡)通话,每个CPU的cpu空闲是60,但性能不再增加,什么是瓶颈?
epoll_wait(4, {{EPOLLIN, {u32=28, u64=28}}}, 1, 1000) = 1 <0.000051>
read(28, "hello world\n", 4096) = 12 <0.000005>
write(28, "hello world\n", 12) = 12 <0.000015>
epoll_ctl(4, EPOLL_CTL_MOD, 28, {EPOLLIN|EPOLLONESHOT, {u32=28, u64=4656724694760685596}}) = 0 <0.000033>
epoll_wait(4, {{EPOLLIN, {u32=14, u64=14}}}, 1, 1000) = 1 <0.000038>
read(14, "hello world\n", 4096) = 12 <0.000005>
write(14, "hello world\n", 12) = 12 <0.000013>
epoll_ctl(4, EPOLL_CTL_MOD, 14, {EPOLLIN|EPOLLONESHOT, {u32=14, u64=4656724694760685582}}) = 0 <0.000040>
epoll_wait(4, {{EPOLLIN, {u32=15, u64=15}}}, 1, 1000) = 1 <0.000056>
read(15, "hello world\n", 4096) = 12 <0.000005>
write(15, "hello world\n", 12) = 12 <0.000008>
epoll_ctl(4, EPOLL_CTL_MOD, 15, {EPOLLIN|EPOLLONESHOT, {u32=15, u64=4656724694760685583}}) = 0 <0.000047>
epoll_wait(4, {{EPOLLIN, {u32=33, u64=33}}}, 1, 1000) = 1 <0.000039>
read(33, "hello world\n", 4096) = 12 <0.000004>
write(33, "hello world\n", 12) = 12 <0.000019>
epoll_ctl(4, EPOLL_CTL_MOD, 33, {EPOLLIN|EPOLLONESHOT, {u32=33, u64=4656724694760685601}}) = 0 <0.000039>
epoll_wait(4, {{EPOLLIN, {u32=35, u64=35}}}, 1, 1000) = 1 <0.000042>
read(35, "hello world\n", 4096) = 12 <0.000005>
write(35, "hello world\n", 12) = 12 <0.000010>
epoll_ctl(4, EPOLL_CTL_MOD, 35, {EPOLLIN|EPOLLONESHOT, {u32=35, u64=4656724694760685603}}) = 0 <0.000042>
epoll_wait(4, {{EPOLLIN, {u32=8, u64=8}}}, 1, 1000) = 1 <0.000039>
read(8, "hello world\n", 4096) = 12 <0.000006>
write(8, "hello world\n", 12) = 12 <0.000007>
epoll_ctl(4, EPOLL_CTL_MOD, 8, {EPOLLIN|EPOLLONESHOT, {u32=8, u64=4656724694760685576}}) = 0 <0.000054>
epoll_wait(4, {{EPOLLIN, {u32=21, u64=21}}}, 1, 1000) = 1 <0.000034>
13283 work 15 0 636m 256m 308 R 19 0.4 4:33.09 server
13288 work 15 0 636m 256m 308 D 19 0.4 4:33.27 server
13286 work 15 0 636m 256m 308 D 17 0.4 4:32.60 server
13287 work 15 0 636m 256m 308 D 17 0.4 4:34.72 server
13280 work 15 0 636m 256m 308 D 15 0.4 4:33.20 server
13281 work 15 0 636m 256m 308 D 15 0.4 7:50.35 server
13282 work 15 0 636m 256m 308 R 15 0.4 4:33.14 server
13290 work 15 0 636m 256m 308 R 15 0.4 4:31.80 server
13279 work 15 0 636m 256m 308 D 13 0.4 4:24.11 server
13285 work 15 0 636m 256m 308 D 13 0.4 4:32.91 server
13289 work 15 0 636m 256m 308 D 13 0.4 4:32.34 server
13284 work 15 0 636m 256m 308 D 12 0.4 4:31.70 server
14042 work 16 0 2380 344 280 S 10 0.0 1:46.98 test_long_conn
6403 work 16 0 3692 580 416 S 10 0.0 0:00.12 grep
13915 work 16 0 2380 344 280 S 8 0.0 1:47.42 test_long_conn
13930 work 16 0 2380 344 280 R 8 0.0 1:49.59 test_long_conn
13945 work 16 0 2380 344 280 S 8 0.0 1:48.38 test_long_conn
13841 work 16 0 2380 344 280 S 6 0.0 1:36.61 test_long_conn
13847 work 16 0 2380 344 280 S 6 0.0 1:49.55 test_long_conn
13848 work 16 0 2380 344 280 S 6 0.0 1:48.75 test_long_conn
13849 work 16 0 2380 344 280 S 6 0.0 1:48.45 test_long_conn
13850 work 16 0 2380 344 280 S 6 0.0 1:48.74 test_long_conn
13913 work 16 0 2380 344 280 R 6 0.0 1:47.50 test_long_conn