Erlang中启用Kernel Poll

Posted by Elton's Blog on December 3, 2012

默认情况下

$ erl
Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false]

my erlang
Eshell V5.9.3  (abort with ^G)
1>

如果要启用Kernel Poll,需要加上+K true参数

$ erl +K true
Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:true]

my erlang
Eshell V5.9.3  (abort with ^G)
1>

启用Kernel Poll的好处在于当有很多连接时,可以极大的降低CPU的占用率。对内存和响应延迟没有作用。

Num users 1500 3000
Kernel Poll no yes no yes
Latency (ms) 16 16 28 28
CPU (%) 15 2 30 4
Memory RES (MB) 84 84 150 150
Memory VIRT (MB) 94 94 160 160