如何配置Tomcat使用1个以上的CPU? [英] How to configure Tomcat to use more than 1 CPU?

查看:100
本文介绍了如何配置Tomcat使用1个以上的CPU?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个新客户端,目前我们正在使用 100 个并发 http 线程(使用 Jmeter)对生产类服务器进行压力测试.问题是即使我们有 2 个 Xeon 处理器(每个 CPU 有 4 个核心,总​​共 8 个核心),我也只能看到 tomcat 使用 4 个核心,而不是 8 个核心.4 核我相信它只属于 1 个处理器.其他 4 个线程实际上正在休眠.

We have a new client, and currently we are performing stress test on the production like server with 100 concurrent http threads (using Jmeter). The problem is even though we have 2 Xeon Processor (each CPU with 4 core, total to 8 core), i can only see tomcat utilizing 4 cores, not 8 cores. the 4 cores i believe it belongs to only 1 processor. the other 4 threads is virtually sleeping.

我从 Apache 文档中得到的印象是,如果我们有多 CPU 机器,我们应该配置 acceptorThreadCount="2" :http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

i got the impression from the Apache document that if we have multi CPU machine, we should configure acceptorThreadCount="2" : http://tomcat.apache.org/tomcat-6.0-doc/config/http.html

我们已将默认连接器更改为具有 maxThreads="150" minSpareThreads="4" 的 tomcatThreadPool,并将连接器执行程序更改为具有 acceptorThreadCount="2".但它仍然只使用 1 个 CPU.

We have change the default connector to tomcatThreadPool with maxThreads="150" minSpareThreads="4" and connector executer to have acceptorThreadCount="2". But it is only still utilizing 1 CPU.

知道如何配置以利用所有内核(或所有 CPU 的处理器)吗?

Any idea how to configure to utilize all cores (or all CPU's processors)?

推荐答案

一些随机的想法来帮助你.

A couple random thoughts to help you out.

JVM 将在内部进行自己的任务调度.有时,如果 JVM 不认为一个 CPU 负担过重,它可能会为关键操作保留几个内核.因此,您会看到一些内核正在使用,而另一些内核则闲置.

The JVM will do its own scheduling of tasks internally. There are times if the JVM does not think that one CPU is being over taxed it may reserve a few cores for critical operations. Therefore you see some cores being used and others sitting idle.

另一种可能是需要显式设置 CPU 亲和性.在 Unix 中,您可以使用 taskset 命令 检查 JVM 已选择使用的 CPU::

Another possibility is that the CPU affinity needs to be explicitly set. In Unix you can check which CPU's the JVM has been chosen to use with the taskset command::

taskset -p <pid>

在 Windows 中,调出您的任务管理器,转到进程选项卡,右键单击进程并选择设置 Affinity.您可以查看设置要使用的 CPU/内核.

In Windows, bring up your task manager, go to the process tab, right click a process and choose set Affinity. You can see which CPU/Cores are set to be used.

我不知道 Java/Tomcat 中有一个启动参数来控制 CPU 使用率.我相信这应该是在操作系统级别.我也不记得读过关于 JVM 被编码以限制使用的 CPU/内核数量的信息.

I am not aware of a start-up parameter in Java/Tomcat to control CPU usage. I believe this should be on the OS level. I also dont recall ever reading about the JVM being coded to limit the number of CPU/Cores being used.

这篇关于如何配置Tomcat使用1个以上的CPU?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆