Java Monitoring

http://jamonapi.sourceforge.net/

https://code.google.com/p/javasimon/ (Not recommended)

Metrics: http://metrics.dropwizard.io/
Reports Server: http://ganglia.info/

Check Ganglia Demos:
http://ganglia.info/?page_id=69

-o-

Advertisements

Monitoring Tomcat

https://www.hugeinc.com/ideas/perspective/happy-monitoring-with-javamelody

https://github.com/javamelody/javamelody/wiki/UserGuide

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

-o-

JMX Monitoring is best….but many won’t open ports in production.
http://wiki.apache.org/tomcat/FAQ/Monitoring

-o-

http://www.moskito.org/index.html

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

http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/gc01/index.html

http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html

Bench marking

http://java-is-the-new-c.blogspot.com/2013/07/tuning-and-benchmarking-java-7s-garbage.html

 

To check quickly, check following in JVM Params

-XX:+UseG1GC

-XX:+UseConcMarkSweepGC

 

Multithreaded Custom Class Loaders in Java SE 7

http://docs.oracle.com/javase/7/docs/technotes/guides/lang/cl-mt.html

-o-

Cache (Noun)

Cache: a part of a computer’s memory where information is kept so that the computer can find it very quickly
http://www.merriam-webster.com/dictionary/cache

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

Software:

http://ehcache.org/modules
http://terracotta.org/

Spring/EhCache: http://www.codingpedia.org/ama/spring-caching-with-ehcache/

Cache Algorithms: http://en.wikipedia.org/wiki/Cache_algorithms

Open Source Cache Software List: http://java-source.net/open-source/cache-solutions

Connection Pool

HTTP Connection Pool: http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

FTP Connection Pool

Image / JS / HTML Cache in transit, Network Route Optimization : http://www.akamai.com/

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 http://www.google.com

Pinging http://www.google.com [173.194.115.84] with 32 bytes of data:
Request timed out.
Request timed out.

Ping statistics for 173.194.115.84:
Packets: Sent = 2, Received = 0, Lost = 2 (100% loss),
Control-C
^C

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

-o-

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)
-o-

Custom Plugins for Apache JMeter

http://jmeter-plugins.org/

http://jmeter-plugins.org/wiki/StandardSet/

These are very useful plugins to analyze the JMeter Results.

Tips:
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
-o-