Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling a Play framework application (2.0.2) through VisualVM

I'm having some serious problems regarding my Play! Applications performance. I already tried to change the server and the data base, but the slowness persists.

Using Firebug to measure my http requests I found out that they are taking around 20 seconds just to start replying.

So my last hope is to use VisualVM to profile my application and find its bottle necks. But I don't know the proper way of passing some arguments like "-Dcom.sun.management.jmxremote" without messing with the global JAVA_OPTS variable.

Thanks again!

like image 217
Andre Rosot Avatar asked Jul 25 '12 03:07

Andre Rosot


2 Answers

It looks like Metrics handles this automatically.

Add the following to your Build.scala app dependencies:

"com.yammer.metrics" % "metrics-core" % "2.1.2"

And start instrumenting your code. Then start up the application with "play run" -- VisualVM should show your JVM process and you can just connect to it directly (assuming you have the VisualVM-MBeans plugin). Check to see if you have at least 1.3.4. This is what I see when I start up:

VisualVM

the xsbt.boot.Boot process is Play.

More generally, this article really helps when debugging Akka based frameworks like Play.

like image 124
Will Sargent Avatar answered Sep 28 '22 08:09

Will Sargent


In case someone needs to profile a Play 2.3.x app:

  1. Put your JAVA_OPTS settings in ~/.activator/activatorconfig.txt (c.f. https://typesafe.com/activator/docs):

    -Dcom.sun.management.jmxremote.port=1234 
    -Dcom.sun.management.jmxremote.rmi.port=1234 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false 
    -Djava.rmi.server.hostname=127.0.0.1
    
  2. In VisualVM, add a Local JMX connection to localhost:1234

like image 35
Rodrigo Avatar answered Sep 28 '22 09:09

Rodrigo