java - Apache Tomcat JVM Heapsize on Redhat 5 64 位 32 RAM 2 四核 Xeon 性能问题

标签 java apache tomcat jvm heap-size

请帮我调整我的服务器 当一次连接数超过 500 时,我的 httpd 就会卡住并停止响应。

自 2008 年以来我一直使用相同的配置,现在添加了一些 RAM 现在我在两台服务器上各有 32 Gb

第一个安装了RHEL 5 64位2.6.18-53.1.4.el5xen 它向连接到第二个服务器后的客户端提供 jnlp

Apache 2.2.3 httpd.conf

<IfModule prefork.c>
StartServers       8
MinSpareServers   10
MaxSpareServers   75
ServerLimit      1100
MaxClients       1100
MaxRequestsPerChild  4000
</IfModule>

<IfModule worker.c>
StartServers         2
MaxClients         150
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

具有以下参数的 java 1.6.0_27 进程

java -server -Xmx1280M -XX:MaxPermSize=256M -Djava.awt.headless=true ...

tomcat server.xml 参数如下

 ...   connectionTimeout="12000" maxSpareThreads="250" protocol="AJP/1.3" 
 maxHttpHeaderSize="8192" disableUploadTimeout="true" minSpareThreads="25" 
 useBodyEncodingForURI="true" maxThreads="500" acceptCount="100" 
 enableLookups="false" ...

第二个服务器只有 JVM java 进程 HW 与上面相同 当连接的用户数超过 600 时卡住 我昨天将 Xmx 从 4000m 更改为 26g,希望这将允许在此过程中使用更多 RAM。但没有看到它在 top 中使用了超过 4g。

java -server -Xmx26g -Djava.awt.headless=true -Dfile.encoding=UTF-8 -jar

top - 01:34:10 up 252 days,  8:02,  1 user,  load average: 0.00, 0.02, 0.00
Tasks: 127 total,   1 running, 126 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.8%us,  0.2%sy,  0.0%ni, 97.7%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  37049860k total,  3225916k used, 33823944k free,   331836k buffers
Swap: 10223608k total,        0k used, 10223608k free,  2409808k cached

top - 03:57:04 up 252 days,  8:02,  1 user,  load average: 0.01, 0.02, 0.00
Tasks: 145 total,   1 running, 144 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.0%us,  0.0%sy,  0.0%ni, 99.8%id,  0.2%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  37108368k total, 36117600k used,   990768k free,   218364k buffers
Swap:  2031608k total,      120k used,  2031488k free, 33518948k cached

请帮我解决这个问题。我打算升级所有这些但不确定我的 java 程序是否可以与新版本的 rhel apache tomcat 和 jvm 一起使用。

最佳答案

这很可能是您在 Tomcat 方面的问题

maxThreads="500"

在 server.xml 中...提高它,这将允许更多并发连接。

maxThreads

The maximum number of request processing threads to be created by this Connector, which therefore determines the maximum number of simultaneous requests that can be handled. If not specified, this attribute is set to 200. If an executor is associated with this connector, this attribute is ignored as the connector will execute tasks using the executor rather than an internal thread pool.

From Apache Tomcat documentation

另外,这部分解释了为什么600个客户端可以连接:

acceptCount="100"

这使另外 100 个客户端可以在队列中等待服务

acceptCount

The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.

注意:为了能够验证内存情况,可以使用JMX(jconsole、jvisualvm等...)连接Tomcat,也可以查看很多实际设置,如 Monitoring Tomcat FAQ 中所述.

关于java - Apache Tomcat JVM Heapsize on Redhat 5 64 位 32 RAM 2 四核 Xeon 性能问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38904124/

相关文章:

java - Jenkins环境变量JOB_NAME为空

java - 使用 JSlider 创建日期选择器?

java - 如何解决 outbound-gateway 不允许使用 http-method

php - 每次调用 mysql_query 时执行一个函数。 (PHP)

PHP:可以在默认的 php.ini 文件中设置常量

apache - Windows 无法在本地计算机上启动 Apache CouchDB 服务

java - 如何在没有登录和 cli 的情况下在 Aws ec2 上运行 .Jar 文件?

java - 如何使用Java正确读取RRD文件?

Angular 应用程序部署在 tomcat 上作为 war

tomcat - Servlet 是否独立于另一个(进程方面)?