Andre Rosot
Andre Rosot

Reputation: 121

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!

Upvotes: 8

Views: 5068

Answers (2)

Will Sargent
Will Sargent

Reputation: 4396

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.

Upvotes: 6

Rodrigo
Rodrigo

Reputation: 1253

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

Upvotes: 4

Related Questions