我目前正在测试gwan Web服务器,我对gwan worker的默认设置和CPU Core检测有疑问。
在Xen服务器(包含4核Xeon CPU)上运行gwan,gwan.log
文件报告只检测到单个核心:
'./gwan -w 4' used to override 1 x 1-Core CPU(s)
[Wed May 22 06:54:29 2013 GMT] using 1 workers 0[01]0
[Wed May 22 06:54:29 2013 GMT] among 2 threads 0[11]1
[Wed May 22 06:54:29 2013 GMT] (can't use more threads than CPU Cores)
[Wed May 22 06:54:29 2013 GMT] CPU: 1x Intel(R) Xeon(R) CPU E5506 @ 2.13GHz
[Wed May 22 06:54:29 2013 GMT] 0 id: 0 0
[Wed May 22 06:54:29 2013 GMT] 1 id: 1 1
[Wed May 22 06:54:29 2013 GMT] 2 id: 2 2
[Wed May 22 06:54:29 2013 GMT] 3 id: 3 3
[Wed May 22 06:54:29 2013 GMT] CPU(s):1, Core(s)/CPU:1, Thread(s)/Core:2
有什么想法吗?
谢谢!
答案 0 :(得分:1)
与许多其他虚拟机管理程序一样,gwan.log文件报告我只有一个核心:
Xen
正在破坏CPUID
指令和/proc/cpuinfo
Linux内核结构(G-WAN都使用它们来检测CPU内核)。 / p>
正如您所看到的,对于旨在扩展多核的多线程应用程序来说,这是一个真正的问题。
'./ gwan -w 4'用于覆盖1 x 1-Core CPU
为避免愚蠢的手动覆盖浪费内存并影响性能,G-WAN会检查用户提供的线程数是否大于实际CPU核心数。
这就是为什么你有警告:“(不能使用比CPU内核更多的线程)”。
要绕过此保护和警告,您可以使用-g
(“上帝”)模式:
./gwan -g -w 4
此命令行开关记录在G-WAN可执行文件帮助中:
./gwan -h
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Usage: gwan [-b -d -g -k -r -t -v -w] [argument]
(grouped options '-bd' are ignored, use '-b -d')
-b: use the TCP_DEFER_ACCEPT TCP option
(this is disabling the DoS shield!)
-d: daemon mode (uses an 'angel' process)
-d:group:user dumps 'root' privileges
-g: do not limit worker threads to Cores
(using more threads than physical Cores
will lower speed and waste resources)
-k: (gracefully) kill local gwan processes
using the pid files of the gwan folder
-r: run the specified C script (and exit)
for general-purpose code, not servlets
-t: store client requests in 'trace' file
(may be useful to debug/trace attacks)
-v: return version number and build date
-w: define the number of worker threads.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Available network interfaces (2):
127.0.0.1 192.168.0.11