Tomcat having extremely high cpu usage [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have tomcat 8 and running a web application on tomcat. Recently I noticed my Vsphere client showing alarms for high cpu usage and found that the process responsible for is tomcat. When I restart the tomcat server it is running good, but after some time, the same problem arise. How to solve this issue?
/data/IMS/java/bin/java -Djava.util.logging.config.file=/data/IMS/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048

This is a broad topic, so I can only really provide you with some pointers on how to debug remote applications.
If you want to get some visibility into what your App is doing you can use a tool like Visual VM. Visual VM can profile cpu and memory usage, see details here. In order to do profiling you need to:
Enable JMX on Tomcat. Docs on how to do this for Tomcat 8 are here.
Run Visual VM and point it at your Tomcat server's JMX connection. Tutorial here.
Do some cpu usage profiling and look at memory usage to get a better idea about what is happening. Formulate some hypotheses and test them out. Repeat the process until you stumble upon a solution.
If I had to guess what was going wrong, I would say memory usage is gradually increasing over time, and garbage collection starts taking a long time.

Related

100% CPU Utlization by Java Application [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am trying to analyze the java application using VisualVM tool and am getting the following statistics.
.
What I don't understand is why my app is utilizing approx 100% of CPU, and what are the ways I can detect and resolve memory-related issues in java application.
The project is developed on Spring Boot and is deployed on Apache Tomcat Server.
Thanks.
Edit:
My project used to utilize a max of 30% of CPU but now it's utilizing 100% and because of it most of the APIs are taking a lot of time to respond.
You could use a Profiling tool like JProfiler or VisualVM to analyze what your application is doing at that time. You could also connect a debugger and just "pause" the threads, that's a hack that may give you some hint on where to look for what is actually happening.
From your screenshot I'm not really seeing any memory specific issues, but using a profiling tool will also allow you to analyze which classes have instances with allocated memory.

Predicting memory consumption of java components [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am currently working on an event driven System with multiple components running. Recently , I have received an urgent requirement to identify the memory consumption of java components running , so that we can give a brief idea of memory requirements before it is getting deployed on UAT/customer production environments.
Do we have any API using which Deep retained size can be calculated or a formula can be provided using which memory requirements can be computed.
Any ideas on this will surely help.
I have seen some API's ( java instrumentation Api) using which Shallow size can be calculated , but this will not suffice my need.
I also found java Assist using which java byte code can be modified at runtime.
To identify the memory consumption of a java aplication, you can use a profiler.
In jdk 6 or greater you can find jvisualvm (https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jvisualvm.html).
With jvisualvm, you can attach to a java process and, in sampler tab, you can see the memory consumed grouped by class type.
There are even other powerful profilers (JProfiler is one of them)
Enable garbage collection logging and analyze the log. As a bonus you will also be able to identify (and fix) aberrant behaviour.
To turn on gc logging, use the following flags:
-verbose:gc
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+PrintTenuringDistribution
-XX:+PrintGCCause
-Xloggc:/gc-%t.log
This log file can then be handled in a number of tools like Censum from JClarity or uploaded to https://gceasy.io/ for easy analysis. Note that you will see the memory consumption as a whole for the app, not a breakdown. For that you will have to use something like VisualVM mentioned above.

how to get CPU usage of tomcat running in docker container [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
My application setup: 4 docker containers setup by docker-compose: myapplication (tomcat, jersey application), kafka, postgres, zookeeper.
I need to know the CPU usage of tomcat container.
1, I used JavaMeloday to get % System CPU 93.36, more details.
2, I used docker stats <docker id> to get that CPU % is 356% at the same time with % System CPU 93.36 by JavaMelody.
In my machine, there are 8 cores. why the numbers in 1 and 2 are different? How to explain them?
Thanks
As mentioned in moby/moby issue 26711:
800% is correct here, which is a standard notation for telling that 8 cores are 100% in use.
So 356% means the docker container processes (not just the java Tomcat) uses almost 4 of the 8 cores.
As opposed to Javamelody, used in "A Step-by-Step Guide to Tomcat Performance Monitoring", which monitors the Java application through JMX, and reports more: from "Java – monitoring cpu and system load of multi-threaded application via OperatingSystemMXBean", that value is an aggregate for all cores).
The issue is: docker stats and javamelody don't monitor the activity at exactly the same time, and could report (and aggregate) different activity peaks.

Capture and Analyze Core Dump on Running App Server [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
How can I capture a Core Dump and analyze the Java heap on an application running in Apache Tomcat?
A javacore can be provoked manually (assuming the JVM is configured to dump at user signal - generally it is).
On Windows: Press ControlBreak on the command window to generate the dumps.
On Linux: Press Control\ on the shell window.
On *nix or using Cygwin: kill -quit <pid>
All in all, launch Tomcat from a console, then depending on your platform perform one of the options above. This will generate a javacore which can be analyze with various tools e.g. Visual VM, etc.
VisualVM provide wide range of memory test on any application running with Java. I don't have much idea about tomcat memory analyzer but I'd prefer VisualVM
Download: https://visualvm.java.net/
VisualVM is a visual tool integrating several commandline JDK tools and lightweight profiling capabilities. Designed for both production and development time use, it further enhances the capability of monitoring and performance analysis for the Java SE platform
Screenshot of heap dump.

Tomcat7 parallel deployment feature: experiences using it on production servers? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I've recently learned about Tomcat 7's feature to allow multiple versions of the same webapp deployed at the same time:
http://www.tomcatexpert.com/blog/2011/05/31/parallel-deployment-tomcat-7
http://www.javacodegeeks.com/2011/06/zero-downtime-deployment-and-rollback.html
Our sites regularly get 10-20,000 user sessions per day, and quite a lot of them are transactional/stateful type of webapps. Parallel deployment seems perfect for what we want, but I haven't really heard much about people's experiences using it on their servers.
If you use this feature of tomcat 7 in production, have you had any issues with it so far? Have you had to make any changes to your webapps to "play nice" with this Tomcat feature?
I didn't use this feature in production. My first thougths are:
What if you apply database schema changes? You'll have two applications running on same schema with different database handling (for example different JPA entities).
What if you have some scheduled tasks? They'll run paralell. Your application must be ready for this.
What if you apply some very important bugfixes? You'll have good and buggy application running together. They'll together make changes to database until all old sesions expires.
Why do you want your users to see old version of an application if you apply some new features or bugfixes.
Your application must be prepared the same way you prepare it to run on cluster with sticky sessions. It's just the same, but on same Tomcat.
Are you sure your application can be redeployed on Tomcat without well-known perm gen issues? I heard they say it can be done now. I still restart Tomcat with each redeploy.
We didn't have much luck getting this to work consistently in our test environment, so no way we'd consider it for production.
The question is, do you need the ability to do hot upgrades in your environment? Often this is theoretically nice but not needed.

Categories

Resources