• Like
Performance Analysis and Monitoring with Perf4j
Upcoming SlideShare
Loading in...5
×

Performance Analysis and Monitoring with Perf4j

  • 5,093 views
Uploaded on

This is a lightning presentation given by Sudhan Kanade to our team for the purpose of knowledge sharing in support of our efforts to create a culture of learning.

This is a lightning presentation given by Sudhan Kanade to our team for the purpose of knowledge sharing in support of our efforts to create a culture of learning.

More in: Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
5,093
On Slideshare
0
From Embeds
0
Number of Embeds
6

Actions

Shares
Downloads
53
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Performance Analysis and Monitoring with Perf4j Code timing, logging, analyzing and monitoring tool Sudhan Kanade
  • 2. Why do we need Perf4J
    • Code works on dev / stage env
    • Scalability
    • Distributed application
    1
  • 3. Analogy: Perf4J to Log4J
    • Log4j : System.out.println()
    • Perf4J : System.currentTimeMillis()
    • Can log similarly to any appenders defined in log4j.
    • Can use AspectJ / Spring AOP
    2
  • 4. What difference Perf4J makes:
    • Without Perf4J
      • long start = System.currentTimeMillis();
      • // execute the block of code to be timed
      • log.info("ms for block n was: " + (System.currentTimeMillis() - start));
    • With Per4J
      • StopWatch stopWatch = new LoggingStopWatch();
      • //... execute code here to be timed
      • stopWatch.stop("example1", "custom message text");
    • Allows parsing, analyzing and monitoring the logs.
    3
  • 5. Features / Highlights of Perf4J
    • A simple stop watch mechanism for concise timing statements.
    • A command line tool for generating aggregated statistics and performance graphs from raw log files.
    • Custom log4j appenders to generate statistics and graphs in a running application, with java.util.logging and logback support scheduled for subsequent releases.
    • The ability to expose performance statistics as JMX attributes, and to send notifications when statistics exceed specified thresholds.
    • A @Profiled annotation and a set of custom aspects that allow unobtrusive timing statements when coupled with an AOP framework such as AspectJ or Spring AOP.
    4
  • 6. Timing using StopWatch
    • Base class : LoggingStopWatch
    • SubClass : Log4JStopWatch, CommonsLogStopWatch and Slf4JStopWatch
    5
  • 7. Log Parsers: Statistics and Graphs
    • Groups stop watch output by tag and by time slice
    • Generating detailed statistics information
    • Time series graphs using the Google Chart API
    • LogParser reads from standard input thus allowing it to get output generated in real time.
      • tail -f performance.log | java -jar perf4j-0.9.8.1.jar
    6
  • 8. Sample for LogParser 7
  • 9. Integrating Directly With Log4J
    • Set of custom log4j appenders
    • Allows Perf4J to expose performance data as attributes on JMX MBeans, and to send JMX notifications.
    • Provides graphing appenders that generate performance graphs which can be exposed through a web front-end using a Perf4J graphing servlet.
    8
  • 10. sample log4j.xml – perf4j 9
  • 11. sample log4j.xml – log4j and perf4j 10
  • 12. Perf4J appender for JMX: 11
  • 13. @Profiled Annotation
    • Reduces the "signal-to-noise" ratio of the code.
    • Allowing the method body to remain free of StopWatch code.
    • Perf4J custom timing aspect can be enabled with an aspect-oriented programming framework such as AspectJ or Spring AOP
    • Minimal overhead.
    12
  • 14. @Profiled Annotation - sample
      • @Profiled(tag = "dynamicTag_{$0}")
      • public void profiledExample(String tagSuffix) {
      • ... business logic only here
      • //method body to remain free of StopWatch code
      • }
    13
  • 15. Pitfalls and Best Practices
    • Application monitoring - Fail to optimally deliver their intended benefits
    • Either too much or not enough where it is required.
    • Overhead
    14
  • 16. Pitfalls and Best … cont
    • When deciding which methods and code blocks to profile, focus on the big fish first.
    15
  • 17. Pitfalls and Best … cont
    • Perf4J is designed to offload performance analysis to a separate thread or process.
    16
  • 18. Pitfalls and Best … cont
    • Don’t forget the benefits of performance regression testing
    17
  • 19. Pitfalls and Best … cont
    • Take advantage of the @Profiled annotation and AspectJ’s load-time weaving to decide which methods should be timed at deployment time.
    18
  • 20. Pitfalls and Best … cont
    • Don’t forget about parts of your application that execute outside of the JVM
    19
  • 21. Future Directions for Perf4J
    • Methods to be profiled using a separate configuration file
    • To time method executions without access to source code
    20
  • 22. The End 5 minutes of question time starts now!
  • 23. Questions 4 minutes left!
  • 24. Questions 3 minutes left!
  • 25. Questions 2 minutes left!
  • 26. Questions 1 minute left!
  • 27. Questions 30 seconds left!
  • 28. Questions TIME IS UP!