Java Monitoring (Not recommended)

Reports Server:

Check Ganglia Demos:



Monitoring Tomcat

Easy to use
Excellent features
License: Apache Software License
Need tinkering to enable/disable in production.
Easy to take thread dumps
Active development going on


JMX Monitoring is best….but many won’t open ports in production.



The Scale Cube:


The Concurrent Mark Sweep (CMS) Collector Vs The Garbage First or G1 garbage collector

G1 Garbage Collector got introduced in Java 7. People already written on this subject. Just giving links. Please go through and take care of GC Configurations.


Java Garbage Collection Basics

Bench marking


To check quickly, check following in JVM Params




Multithreaded Custom Class Loaders in Java SE 7



Cache (Noun)

Cache: a part of a computer’s memory where information is kept so that the computer can find it very quickly

Nearest Place to CPU to find Objects are Primary Memory, File System, Database and Network.
We have software which supports cache. No need to implement from scratch. But we need to know concepts and fundamentals behind this. There are different Cache Algorithms to use.

2013-12-13 18_54_55-cache



Cache Algorithms:

Open Source Cache Software List:

Connection Pool

HTTP Connection Pool:

FTP Connection Pool

Image / JS / HTML Cache in transit, Network Route Optimization :


How to do Performance Fine Tuning?

This is very common question asked by many.
Enterprise systems are made up of 4 components.

2013-12-13 17_59_35-performance

Primary Memory: Make sure that we use memory efficiently. Reduce the foot print.

CPU: Use CPU friendly algorithms for calculations. Example: One team member is fetching records and counting them in while loop to know total number of records. Instead of this he should have use select count(*)

Use Visual VM to monitor CPU, Memory. Use JMeter or other tools to simulate load.
1. Take memory dump and analyze total number of objects and its size
2. Avoid object creation. Reuse Objects. Example: String query = a+b+c+d+ ….etc
3. Do proper code review and check SONAR violations
4. Use New Relic, Spring Insight, Visual VM, JMeter, …tools
5. JMon API is good one to check performance
6. Establish bench mark performance numbers.

Secondary Memory: File System/Database comes under this. Reduce total number of trips. Store wisely.
1. Reading same object again and again is not good. Better to cache them. Implement good caching algorithms.
2. Instead of statement, prepared statements are good
3. Avoid select *. If user needs two columns, it is better to choose only those two, instead of using select * and using data only from two columns.
4. Where clause order
5. Indexes, Re-indexes, Table Partitions, …etc
6. Instead of making two calls to database, combine them and fetch data in one call

Network: Network latency, Network Bandwidth, HTTP Connection reuse, Time Outs, Firewalls, ..etc

>ping -t

Pinging [] with 32 bytes of data:
Request timed out.
Request timed out.

Ping statistics for
Packets: Sent = 2, Received = 0, Lost = 2 (100% loss),

Operating System / JVM Performance Tuning: Check Memory Settings, JVM Parameters, …etc


Reference Books:
Java Performance and Scalability: A Quantitative Approach Paperback
by Henry H. Liu

Oracle Database 12c Performance Tuning Recipes: A Problem-Solution Approach [Paperback]
Sam Alapati (Author), Darl Kuhn (Author), Bill Padfield (Author)

Introduction to Algorithms [Hardcover]
Thomas H. Cormen (Author), Charles E. Leiserson (Author), Ronald L. Rivest (Author), Clifford Stein (Author)

The Definitive Guide to Terracotta: Cluster the JVM for Spring, Hibernate and POJO Scalability (Expert’s Voice in Open Source) [Paperback]
Terracotta Inc. (Author)

Instant Effective Caching with Ehcache Paperback
by Daniel Wind (Author)

Software Performance and Scalability: A Quantitative Approach [Hardcover]
Henry H. Liu (Author)

Patterns for Performance and Operability: Building and Testing Enterprise Software [Hardcover]
Chris Ford (Author), Ido Gileadi (Author), Sanjiv Purba (Author), Mike Moerman (Author)


Custom Plugins for Apache JMeter

These are very useful plugins to analyze the JMeter Results.

Please disable View Results Tree
Log only Errors
Add Assertions to count proper errors
Define Time Outs

Optimum Numbers:
C2B API (Customer is calling Business API)
50% CPU
70% Memory
1 Sec Max
The TPS within this is optimum TPS for given JVM

B2B API (Business is calling Business API)
80% CPU
80% Memory
.75 Sec Max
The TPS within this is optimum TPS for given JVM