Use JVisualVM to profile a remote JVM running on Amazon EC2 linux node

I have java server running on an amazon EC2 linux (RHEL 6) node. I don’t have X Windows System on this node.
I’m running JVisualVM on a Windows node in order to profile the remote jvm.

These are some configurations i needed to setup for everything to work fine.

* add an iptable rule on the linux node to accept all incoming connections from my windows node (private ip of the windows node is

sudo iptables -I INPUT -p tcp -s -j ACCEPT

In order for the JVisualVM to communicate with the remote JVM we can use  jstatd or JMX.

* start jstatd server on the linux node

The jstatd server comes with the jdk.  Running it on the linux machine

allows the discovery, by the JVisualVM of the JVMs running in this machine and communication with  the remote JVMs.

Create a security policy for jstatd.  The file jstatd.all.policy contains:

grant {

Start jsatd:

jstatd -p 13999

Now, in the JVisualVM, right click on Remote -> Add Remote Host and type the private IP of the linux node.  Now click on the IP and “add jstatd Connection”.  Put in the jstatd port and you should now have a list of all remote JVMs. Double click on the entry corresponding to your JVM and the profiling windows opens.

* add JMX arguments to the JVM 

You’ll notice that some features are “Not supported for this JVM”. We’ll enable JMX communication to fix that.

For this, some java arguments need to be added to the JVM’s start script: -Djava.rmi.server.hostname=linux.node.private.ip

We now restart the JVM, reconnect the JVisualVM to it and all profiling features are available.


Here is a nice article on JMX and jstatd.

This entry was posted in java, linux. Bookmark the permalink.

One Response to Use JVisualVM to profile a remote JVM running on Amazon EC2 linux node

  1. Hi, I am trying to profile JVM running on an EC2 instance. But I want to profile it from my PC. I do not want to create a windows instance to do that. (Assuming windows node is another EC2 instance). You help is most appreciated.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s