0

I have a java rest api and it uses 10% to 5% cpu when I run it with the following command:

java -jar myrestapi.jar

when I use nohup command as shown below the cpu usage increases to 90% even though no requests are being sent.

nohup java -jar myrestapi.jar &

I'm looking for suggestions on where to look to identify the problem. This is done on a Linux machine with java 8 on it.

kennyT07
  • 65
  • 1
  • 1
  • 6
  • Attach a profiler like _YourKit_ and examine which lines are consuming all your time. – Matt Clark Oct 22 '18 at 22:08
  • or `jps` to find the pid and then run `jstack ` a few times if you don't have such tools at hand. Or https://stackoverflow.com/questions/4764167/inspecting-java-threads-in-linux-using-top – zapl Oct 22 '18 at 22:20
  • I've used YourKit and I've found that the line Scanner.nextLine() is consuming all the CPU time. That's actually waiting for user's input so that the app keeps running. Is there another way to have the rest api running without having to read the user's input? – kennyT07 Oct 23 '18 at 15:03

0 Answers0