简体   繁体   English

Tomcat 8:100%cpu使用率

[英]Tomcat 8 : 100% cpu usage

I am having a problem with tomcat since switching to a different package provider (bitnami -> official debian). 因为切换到不同的包提供程序(bitnami - >官方debian),我遇到了tomcat的问题。 Someone seems to be hitting our servers with a request (with malicious intent): 有人似乎是在向我们的服务器发出请求(有恶意):

59.111.29.6 - - [04/Feb/2017:16:17:58 +0000] "-" 400 -

where "-" is the request path, which coincides with 其中“ - ”是请求路径,与之一致

Feb 04, 2017 4:17:58 PM org.apache.coyote.http11.AbstractHttp11Processor process
INFO: Error parsing HTTP request header
 Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.

which coincides with the increased CPU usage. 这与CPU使用率的增加相吻合。 The server status shows the following: 服务器状态显示以下内容:

 <h1>JVM</h1><p> Free memory: 355.58 MB Total memory: 833.13 MB Max memory: 2900.00 MB</p><table border="0"><thead><tr><th>Memory Pool</th><th>Type</th><th>Initial</th><th>Total</th><th>Maximum</th><th>Used</th></tr></thead><tbody><tr><td>Eden Space</td><td>Heap memory</td><td>34.12 MB</td><td>229.93 MB</td><td>800.00 MB</td><td>12.47 MB (1%)</td></tr><tr><td>Survivor Space</td><td>Heap memory</td><td>4.25 MB</td><td>28.68 MB</td><td>100.00 MB</td><td>2.22 MB (2%)</td></tr><tr><td>Tenured Gen</td><td>Heap memory</td><td>85.37 MB</td><td>574.51 MB</td><td>2000.00 MB</td><td>462.84 MB (23%)</td></tr><tr><td>Code Cache</td><td>Non-heap memory</td><td>2.43 MB</td><td>7.00 MB</td><td>48.00 MB</td><td>6.89 MB (14%)</td></tr><tr><td>Perm Gen</td><td>Non-heap memory</td><td>128.00 MB</td><td>128.00 MB</td><td>512.00 MB</td><td>52.57 MB (10%)</td></tr></tbody></table><h1>"http-nio-8080"</h1><p> Max threads: 200 Current thread count: 10 Current thread busy: 3 Keeped alive sockets count: 1<br> Max processing time: 301 ms Processing time: 71.068 s Request count: 10021 Error count: 2996 Bytes received: 0.00 MB Bytes sent: 3.18 MB</p><table border="0"><tr><th>Stage</th><th>Time</th><th>B Sent</th><th>B Recv</th><th>Client (Forwarded)</th><th>Client (Actual)</th><th>VHost</th><th>Request</th></tr><tr><td><strong>F</strong></td><td>1486364749526 ms</td><td>0 KB</td><td>0 KB</td><td>185.40.4.169</td><td>185.40.4.169</td><td nowrap>?</td><td nowrap class="row-left">? ? ?</td></tr><tr><td><strong>F</strong></td><td>1486364749526 ms</td><td>0 KB</td><td>0 KB</td><td>185.40.4.169</td><td>185.40.4.169</td><td nowrap>?</td><td nowrap class="row-left">? ? ?</td></tr><tr><td><strong>R</strong></td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td></tr><tr><td><strong>S</strong></td><td>36 ms</td><td>0 KB</td><td>0 KB</td><td>106.51.39.130</td><td>106.51.39.130</td><td nowrap>104.197.119.177</td><td nowrap class="row-left">GET /manager/status?org.apache.catalina.filters.CSRF_NONCE=072F9F6884D94C5D7B30D1D34CE61BD9 HTTP/1.1</td></tr><tr><td><strong>R</strong></td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td><td>?</td></tr></table><p>P: Parse and prepare request S: Service F: Finishing R: Ready K: Keepalive</p><hr size="1" noshade="noshade"> <center><font size="-1" color="#525D76"> 

So it doesn't seem like an out of memory issue (but I could be wrong). 所以它似乎不是一个内存不足的问题(但我可能是错的)。

How can I stop someone from making the request in the first place to avoid the issues I'm facing? 我怎样才能阻止某人首先提出请求以避免我面临的问题? My webapp running on tomcat restricts HTTP methods to GET/POST, but how can I configure tomcat as a whole to restrict them? 我在tomcat上运行的webapp将HTTP方法限制为GET / POST,但是如何将tomcat配置为一个整体来限制它们呢?

I would advise you to obtain a thread dump of your server : 我建议你获取服务器的线程转储:

  • Isolates the PID of the tomcat server using : 使用以下命令隔离tomcat服务器的PID:

jps -l

  • Obtains a thread dump using : 使用以下命令获取线程转储:

kill -3 PID or jstack PID kill -3 PIDjstack PID

  • Then checks the Thread dump, you should find the reason of the hogging thread 然后检查线程转储,你应该找到占用线程的原因

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM