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)

#java-performance, #performance-fine-tuning

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

#custom-plugins-for-apache-jmeter, #tps

Software Performance Cycle – Deming Wheel

Many people think that installing software in new system will improve performance. Many people suggest that adding memory or increasing CPU will improve. Without understanding fundamentals doing all this won’t help much. This type of thinking comes from watching present day advertisements. After watching Nike shoe advertisement, perception is that if you can wear good shoe you can run faster. Person go to shop, buys Nike Shoe. He can’t win in Olympics just because he had Nike Shoe. Performance comes from within. External shoes, track helps after that.

Many times we won’t plan / design properly. Team is not familiar with performance driven coding. Due to project pressure everybody concentrates on functionality to work. Once it is working management moves resources to other work. There is no time to stop and check the code / performance. While studying Deming Wheel it is reminding the same.


Plan: Keep Performance in mind while designing code, SQL Queries, Infrastructure, Architecture, ..etc

Do: Code for Performance + Functionality + Modularity + Testability..etc

Check: Take time to check what we did and identify the problems

Act: Fix the issues

Improve Standards / Increase Awareness:
1. Set up new standards so that team won’t do the same mistake again and again.
2. Share the knowledge across teams. Awareness prevents doing same mistake again

If we can follow this cycle religiously, over period of time performance of the code will increase. Otherwise at the same pace it will go downhill.



#deming-wheel, #software-deming-wheel, #software-performance, #software-performance-deming-wheel

Application performance management (APM)   – This is very cost effective and best tool. – Very Costly tool – Leader in the market


Note: Many times business is confused with monitoring at different levels like software/hardware/application. Architect can bring more clarity to the table.

Enterprise Application Fine Tuning.

Enterprise Application Performance Fine tuning is very important.

Measure the performance at different layers.


Step 1: Prevention (Design, Code Reviews, Alerts, Dashboards, Caching techniques)

Step 2: Detection (Performance testing, Set Alerts and Dashboards, Log and Monitor apps, Service Attacks)

Step 3: Recovery in Production (Restrict Traffic, Allocate more resources like space, memory, cpu…until we fix the issue., Restart)


Different levels of performance fine tuning.

1. JVM Fine tuning

2. OS (JVM Running) fine tuning

3. Database Fine Tuning

4. Application Fine Tuning

5. UI Fine Tuning:

6. Network Fine tuning. (

Each step is big subject and contact me for more help.


Spring Insight :

Visual VM: