≡ Menu

How to monior Heap usage of a Java Application ?

Heap is the memory space where java application objects are stored. Unfortunately the size of Heap is limited (by the -Xmx java command line option). When all of heap is used up, you are in deep trouble. So, it helps to understand how to measure Java heap usage, and that’s exactly what I’m going to be discussing with you in this post.

Very surprisingly, measuring heap is not that straight forward in java world. I believe it is due to the fact there are numerous ways to measure java heap. Oracle seems to introduce new tools with every release (and retire the old ones). For this reason, I recommend everyone to invest in a commercial grade APM (Application Performance Management) tool. With APM tool, you will simply login to the APM interface (typically a web application) to view the JVM heap usage (along with tons of other useful metrics)

Using the command jcmd to measure heap usage

Java comes with a command line tool named jcmd. It should be available in most flavors of Java (Oracle, IBM etc). I’m going to recommend jcmd to measure your heap usage. One of the advantages of using jcmd is the class histogram which not only shows the heap usage but it breaks down the usage by class. This gives you an instant view of what is causing heap to fill up.

Important Note: jcmd does have some impact on the jvm. But I assure it is worth the price, as the details shown by jcmd are very valuable.

Important Note: the command jcmd must be run as the same user (or effective user) as the user running the java application

Let us see jcmd in action.

Read More

As an Application Support Engineer or a Lead Developer,  you are supposed to save the day when things hit the fan. But this is easier said than done.  I’ve dealt with these issues on a daily basis for couple of decades. In any enterprise application, there are 4 major subsystems that cause performance degradation or outage. Even though the Application platforms have drastically changed in the past few years, these 4 subsystems still make up majority (if not all) of the issues. Understanding this obvious, yet often overlooked fact, you will be able to ask intelligent questions during troubleshooting.

Without further due, here are those:

  1. Application Serving Platform (typically an Application Server or PAAS)
  2. Backend Database or other Remote service(s) that your application depends on
  3. The Operating System that hosts the Application
  4. Application Code

And no, Network is NOT one of the major subsystems to point finger at. That is not to say that Network issues do not occur at all. But in practice, I would look at Network when all other suspects have been eliminated.

Also note that the 4 subsystems listed are not in any order. That is, they all have equal chances of being the culprit.

Image: 4 Subsystems responsible for Application stability

4 Subsystems

(C) Karun Subramanian

Read More

By default, AppDynamics captures tons of useful metrics from your java application. Average response time of your Applications, JDBC response times, Throughput, Heap and Garbage Collection Metrics etc. In addition, AppDynamics automatically captures  Transaction Snapshots (that provide deep diagnostics) periodically and during slow response times. The snapshots will reveal the hotspots up to the method level.

But at times, you may want to monitor a particular method for performance metrics. For example, you may want to know how often a method named ‘cancelOrder’ is called and how long it takes to process. For requirements like this, AppDynamics provides a neat way of instrumenting your java method – Information Points.

Infopoints

To configure a new Information Point, navigate to Analyze -> Information Points. Click on the New button at the top.

Read More

One of the major uses of an APM such as AppDynamics is the ability to collect application data at method level. For example, let’s say you have a method named processOrder in your code that accepts OrderID and Username as parameters.  What if you want to capture the Username as part of the performance metrics ?  This can be extremely valuable, for instance,  to identify which user could be submitting orders that are very slow to process. In AppDynamics, you can achieve this by using Data Collectors. In this blog post, let me show you how it is done.

  1. Log on to AppDynamics Controller UI
  2. Navigate to Configuration -> Instrumentation and click Data Collector tab
  3. You have two types of Data Collectors to choose from
    • Method Data Collector – Captures method arguments and return values.
    • HTTP Data Collector – Captures URLs, Headers and Cookies
  4. Click on Add under the Method Data Collector
  5. Configure the Method Data Collector as follows
    • Name: Provide a meaningful name for this Data Collector
    • Select Apply to new Business Transactions. If you don’t select this, you have to manually select the Business Transactions.
    • Provide the method signature (identifying a method) by its fully qualified class name and method name.
    • If the method is overloaded, i.e the same method name with various arguments, you need to select Is this Method Overloaded check box and choose the method signature you want to monitor
    • Optionally specify match condition to choose the method
    • Under Specify the data to collect from this Method Invocation, enter a display name (this is the name that will show up in Transaction Snapshots under User Data) and the data to collect. You can collect method arguments and/or return valuesAppd
  6. Note that you can also configure HTTP Data Collector if you wish you capture HTTP metadata such as URLs, Cookies and Header values.

Read More

The surprising future of Java EE and what you can do about it

Remember how Adobe (Macromedia) Flash created such a  buzz and ruled the world for over a decade ? While websites created with HTML/CSS/CGI looked like beat-up Kia, websites created with Flash looked like brand new Mercedes Benz. A complete industry was born after Flash animation. Alas, Flash is destined to die due to the enormous amount of security vulnerabilities and Performance issues. While I’m sad that Flash is going away, that is the reality in this fast-paced Information Era. Only the fittest survive. And we are about to see if Java EE is fit enough.

JEE_Container

Image Source: oracle.com

Read More

In this free ebook, I introduce 9 free tools that can be life savers in managing Java Applications. These tools have been time tested, reliable and have helped countless Application Support Engineers and Developers. They DO WORK. These tools can be used to solve problems ranging from ‘Out Of Memory’ errors to ‘Slow’ Applications.

View/Download PDF

 

Do you know the single biggest reason why some APMs fail? Do you know what you have to do first before you even begin evaluating various APM solutions? Do you know the hidden cost in any APM system?

Selecting an APM solution can be tedious task. In this free 18 pages ebook, I present 9 criteria to choose a reliable APM with highest ROI. I’ve derived these criteria based on years of experience in supporting Application infrastructure of various sizes. These criteria will help you clearly understand what exactly you should be looking for in any potential APM solution. You will be ready to ask the right questions when you meet with the APM vendor and will not be caught off guard later.

Enjoy the ebook and Good Luck.

View/Download PDF

 

No nonsense guide to SSL

Dealing with SSL issues is one of the most annoying and frustrating problems. But it does not have to be. In this short guide, I will explain how ssl works, teach how to troubleshoot most common ssl issues and show you how to use the most commonly used SSL tools.

View/Download PDF

 

AppDynamics quick start

Get a high level overview of AppDynamics, one of the leading APM tools in the market. Learn the architecture, capabilities and practical instructions on how to get started. This document will help you to install an AppDynamics Controller and configure a Java agent to start monitoring in minutes.

View/Download PDF

 

Elastic Search Quick Start

ElasticSearch is creating lot of buzz, and for good reasons. It is lightning fast, rock solid and super easy to setup. Searching logs has just gotten glamorous with  ElasticSearch. Organizations like ebay,uber and netflix are using it, and reaping the benefits. In this brief guide, I explain ELK (Elastic Search, LogStash, Kibana) from a 10,000 foot level. You will gain instant understanding of how all this works, how to get started and where to get more information.

View/Download PDF