设为首页 收藏本站
查看: 1315|回复: 0

[经验分享] 解决tomcat占用CPU过高

[复制链接]

尚未签到

发表于 2018-12-7 13:54:25 | 显示全部楼层 |阅读模式
  因生产环境tomcat占用CPU持续过高,负载过高,重启tomcat过于缓慢,参与网上资料,解决tomcat占用CPU过高,重启缓慢问题
  

  1、通过top命令找出占用CPU高的PID
top - 15:52:18 up 93 days,  2:23,  1 user,  load average: 9.05, 9.00, 9.17
Tasks:  98 total,   1 running,  97 sleeping,   0 stopped,   0 zombie
Cpu(s): 41.0%us, 59.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   3926224k total,  1070236k used,  2855988k free,    51508k buffers
Swap:  6143992k total,   286684k used,  5857308k free,    95404k cached
PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                              
4834 root      20   0 1953m  62m 1848 S 99.2  1.6  28369:16 java                                                                 
20399 root      20   0 1980m 650m 5724 S  0.3 17.0   6:31.53 java                                                                 
1 root      20   0 19348  904  632 S  0.0  0.0   0:12.21 init                                                                 
2 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kthreadd                                                            
3 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                         
4 root      20   0     0    0    0 S  0.0  0.0   2:50.30 ksoftirqd/0                                                         
5 root      RT   0     0    0    0 S  0.0  0.0   0:00.00 migration/0                                                         
6 root      RT   0     0    0    0 S  0.0  0.0   0:11.41 watchdog/0                                                           
7 root      20   0     0    0    0 S  0.0  0.0  47:36.80 events/0                                                            
8 root      20   0     0    0    0 S  0.0  0.0   0:00.00 cgroup                                                               
9 root      20   0     0    0    0 S  0.0  0.0   0:00.00 khelper                                                              
10 root      20   0     0    0    0 S  0.0  0.0   0:00.00 netns                                                               
11 root      20   0     0    0    0 S  0.0  0.0   0:00.00 async/mgr                                                            
12 root      20   0     0    0    0 S  0.0  0.0   0:00.00 pm                                                                  
13 root      20   0     0    0    0 S  0.0  0.0   0:22.66 sync_supers                                                         
14 root      20   0     0    0    0 S  0.0  0.0   0:21.60 bdi-default                                                         
15 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kintegrityd/0                                                        
16 root      20   0     0    0    0 S  0.0  0.0   1:41.28 kblockd/0                                                            
17 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpid                                                               
18 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_notify                                                         
19 root      20   0     0    0    0 S  0.0  0.0   0:00.00 kacpi_hotplug  

  2、通过ps aux | grep pid 可以进一步确定是tomcat进程出了问题
  

  3、显示线程列表
[root@tomcat-12 ~]# ps -mp 4834 -o THREAD,tid,time
USER     %CPU PRI SCNT WCHAN  USER SYSTEM   TID     TIME
root     85.4   -    - -         -      -     - 19-16:49:52
root      0.0  19    - futex_    -      -  4834 00:00:00
root      0.0  19    - futex_    -      -  4835 00:00:00
root      0.0  19    - futex_    -      -  4836 00:00:47
root      0.0  19    - futex_    -      -  4837 00:00:00
root      0.0  19    - futex_    -      -  4838 00:00:01
root      0.0  19    - futex_    -      -  4839 00:00:00
root      0.0  19    - futex_    -      -  4840 00:00:20
root      0.0  19    - futex_    -      -  4841 00:00:21
root      0.0  19    - futex_    -      -  4842 00:00:00
root      0.0  19    - futex_    -      -  4843 00:12:07
root      0.0  19    - futex_    -      -  4844 00:00:00
root      9.4  19    - -         -      -  4863 2-04:30:24
root      9.4  19    - -         -      -  4871 2-04:30:20
root      9.4  19    - -         -      -  4875 2-04:30:20
root      9.4  19    - -         -      -  4890 2-04:30:20
root      9.4  19    - -         -      -  4893 2-04:30:20
root      9.4  19    - -         -      -  4896 2-04:30:20
root      9.4  19    - -         -      -  4898 2-04:30:20
root      9.4  19    - -         -      -  4904 2-04:30:20
root      0.0  19    - futex_    -      -  4916 00:00:00
root      0.0  19    - futex_    -      -  4917 00:00:10
root      0.0  19    - futex_    -      -  4918 00:00:00
root      0.0  19    - futex_    -      -  4919 00:00:00
root      0.0  19    - futex_    -      -  4920 00:00:00
root      0.0  19    - futex_    -      -  4921 00:00:00
root      0.0  19    - futex_    -      -  4922 00:00:00
root      0.0  19    - futex_    -      -  4923 00:00:00
root      0.0  19    - futex_    -      -  4924 00:00:00
root      0.0  19    - futex_    -      -  4925 00:00:00
root      0.0  19    - futex_    -      -  4926 00:00:00
root      0.0  19    - futex_    -      -  4927 00:00:00
root      0.0  19    - futex_    -      -  4928 00:00:00
root      0.0  19    - futex_    -      -  4929 00:00:00
root      0.0  19    - futex_    -      -  4930 00:00:00
root      0.0  19    - futex_    -      -  4931 00:00:00
root      0.0  19    - futex_    -      -  4932 00:00:00
root      0.0  19    - futex_    -      -  4933 00:00:00
root      0.0  19    - futex_    -      -  4934 00:00:00
root      0.0  19    - futex_    -      -  4935 00:00:00
root      0.0  19    - futex_    -      -  4936 00:00:00
root      0.0  19    - futex_    -      -  4937 00:00:00
root      0.0  19    - futex_    -      -  4938 00:00:00
root      0.0  19    - futex_    -      -  4939 00:00:00
root      0.0  19    - futex_    -      -  4940 00:00:00
root      0.0  19    - futex_    -      -  4941 00:00:00
root      0.0  19    - futex_    -      -  4942 00:00:00
root      0.0  19    - futex_    -      -  4943 00:00:00
root      0.0  19    - futex_    -      -  4944 00:00:00
root      0.0  19    - futex_    -      -  4945 00:00:00
root      0.0  19    - futex_    -      -  4946 00:00:00
root      0.0  19    - futex_    -      -  4947 00:00:00
root      0.0  19    - futex_    -      -  4948 00:00:00
root      0.0  19    - futex_    -      -  4949 00:00:00
root      0.0  19    - futex_    -      -  4950 00:00:00
root      0.0  19    - futex_    -      -  4951 00:00:00
root      0.0  19    - futex_    -      -  4952 00:00:00
root      0.0  19    - futex_    -      -  4953 00:00:00
root      0.0  19    - futex_    -      -  4954 00:00:00
root      0.0  19    - futex_    -      -  4955 00:00:00
root      0.0  19    - futex_    -      -  4956 00:00:00
root      0.0  19    - futex_    -      -  4957 00:00:00
root      0.0  19    - futex_    -      -  4958 00:00:00
root      0.0  19    - futex_    -      -  4959 00:00:00
root      0.0  19    - futex_    -      -  4960 00:00:00
root      0.0  19    - futex_    -      -  4961 00:00:00
root      0.0  19    - futex_    -      -  4962 00:00:00
root      0.0  19    - futex_    -      -  4963 00:00:00
root      0.0  19    - futex_    -      -  4964 00:00:00
root      0.0  19    - futex_    -      -  4965 00:00:00
root      0.0  19    - futex_    -      -  4966 00:00:00
root      0.0  19    - futex_    -      -  4967 00:00:00
root      0.0  19    - futex_    -      -  4968 00:00:00
root      0.0  19    - futex_    -      -  4969 00:00:00
root      0.0  19    - futex_    -      -  4970 00:00:00
root      0.0  19    - futex_    -      -  4971 00:00:00
root      0.0  19    - futex_    -      -  4972 00:00:00
root      0.0  19    - futex_    -      -  4973 00:00:00
root      0.0  19    - futex_    -      -  4974 00:00:00
root      0.0  19    - futex_    -      -  4975 00:00:00
root      0.0  19    - futex_    -      -  4976 00:00:00
root      0.0  19    - futex_    -      -  4977 00:00:00
root      0.0  19    - futex_    -      -  4978 00:00:00
root      0.0  19    - futex_    -      -  4979 00:00:00
root      0.0  19    - futex_    -      -  4980 00:00:00
root      0.0  19    - futex_    -      -  4981 00:00:00
root      0.0  19    - futex_    -      -  4982 00:00:00
root      0.0  19    - futex_    -      -  4983 00:00:00
root      0.0  19    - futex_    -      -  4984 00:00:00
root      0.0  19    - futex_    -      -  4985 00:00:00
root      0.0  19    - futex_    -      -  4986 00:00:00
root      0.0  19    - futex_    -      -  4987 00:00:00
root      0.0  19    - futex_    -      -  4988 00:00:00
root      0.0  19    - futex_    -      -  4989 00:00:00
root      0.0  19    - futex_    -      -  4990 00:00:00
root      0.0  19    - futex_    -      -  4991 00:00:00
root      0.0  19    - futex_    -      -  4992 00:00:00
root      0.0  19    - futex_    -      -  4993 00:00:00
root      0.0  19    - futex_    -      -  4994 00:00:00
root      0.0  19    - futex_    -      -  4995 00:00:00
root      0.0  19    - futex_    -      -  4996 00:00:00
root      0.0  19    - futex_    -      -  4997 00:00:00
root      0.0  19    - futex_    -      -  4998 00:00:00
root      0.0  19    - futex_    -      -  4999 00:00:00
root      0.0  19    - futex_    -      -  5000 00:00:00
root      0.0  19    - futex_    -      -  5001 00:00:00
root      0.0  19    - futex_    -      -  5002 00:00:00
root      0.0  19    - futex_    -      -  5003 00:00:00
root      0.0  19    - futex_    -      -  5004 00:00:00
root      0.0  19    - futex_    -      -  5005 00:00:00
root      0.0  19    - futex_    -      -  5006 00:00:00
root      0.0  19    - futex_    -      -  5007 00:00:00
root      0.0  19    - futex_    -      -  5008 00:00:00
root      0.0  19    - futex_    -      -  5009 00:00:00
root      0.0  19    - futex_    -      -  5010 00:00:00
root      0.0  19    - futex_    -      -  5011 00:00:00
root      0.0  19    - futex_    -      -  5012 00:00:00
root      0.0  19    - futex_    -      -  5013 00:00:00
root      0.0  19    - futex_    -      -  5014 00:00:00
root      0.0  19    - futex_    -      -  5015 00:00:00
root      0.0  19    - futex_    -      -  5016 00:00:00
root      0.0  19    - futex_    -      -  5017 00:00:00
root      0.0  19    - futex_    -      -  5018 00:00:00
root      0.0  19    - futex_    -      -  5019 00:00:00
root      0.0  19    - futex_    -      -  5020 00:00:00
root      0.0  19    - futex_    -      -  5021 00:00:00
root      0.0  19    - futex_    -      -  5022 00:00:00
root      0.0  19    - futex_    -      -  5023 00:00:00
root      0.0  19    - futex_    -      -  5024 00:00:00
root      0.0  19    - futex_    -      -  5025 00:00:00
root      0.0  19    - futex_    -      -  5026 00:00:00
root      0.0  19    - futex_    -      -  5027 00:00:00
root      0.0  19    - futex_    -      -  5028 00:00:00
root      0.0  19    - futex_    -      -  5029 00:00:00
root      0.0  19    - futex_    -      -  5030 00:00:00
root      0.0  19    - futex_    -      -  5031 00:00:00
root      0.0  19    - futex_    -      -  5032 00:00:00
root      0.0  19    - futex_    -      -  5033 00:00:00
root      0.0  19    - futex_    -      -  5034 00:00:00
root      0.0  19    - futex_    -      -  5035 00:00:00
root      0.0  19    - futex_    -      -  5036 00:00:00
root      0.0  19    - futex_    -      -  5037 00:00:00
root      0.0  19    - futex_    -      -  5038 00:00:00
root      0.0  19    - futex_    -      -  5039 00:00:00
root      0.0  19    - futex_    -      -  5040 00:00:00
root      0.0  19    - futex_    -      -  5041 00:00:00
root      0.0  19    - futex_    -      -  5042 00:00:00
root      0.0  19    - futex_    -      -  5043 00:00:00
root      0.0  19    - futex_    -      -  5044 00:00:00
root      0.0  19    - futex_    -      -  5047 00:00:00
root      0.0  19    - futex_    -      -  5053 00:00:00
root      0.0  19    - futex_    -      -  5264 00:00:00
root      9.5  19    - -         -      -  7041 2-04:30:17
root      0.0  19    - futex_    -      -  7366 00:00:00
root      0.0  19    - futex_    -      -  7383 00:00:00
root      0.0  19    - futex_    -      -  7385 00:00:00
root      0.0  19    - futex_    -      -  7387 00:00:00
root      0.0  19    - futex_    -      -  7388 00:00:00
root      0.0  19    - futex_    -      -  7390 00:00:00
root      0.0  19    - futex_    -      -  7397 00:00:35
root      0.0  19    - skb_re    -      - 24683 00:00:00  通过观察共计7041、4904、4898、4896、4893、4890、4875、4871、4863九个tid占用了CPU
  

  4、打印线程的堆栈信息
[root@tomcat-12 ~]jstack pid | grep tid -A 30  此处不一一列表各tid的堆栈信息了,在其中一个的tid堆栈信息中找到了问题的原因




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-644381-1-1.html 上篇帖子: Linux下Apache与Tomcat的完全分布式集群配置(负载均衡) 下篇帖子: 在eclipse中安装tomcat服务器,报错" Cannot create a server using the selected type ".
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表