Did you use Perf4J in your Java application to collect and analyze performance stats?
What was the typical pattern (using log files, utilities, UI, JMX, etc.)?
Did you use annotations and AOP-based features?
Did you use any JMX integration?
How did you handle production configuration?
Did you include performance stats views/reports as a feature in your application?
Please tell if and why you decided on alternative library/approach.
Source: Tips4all
I am using Perf4J in a client-server application for timing RPC calls. It was quite simple to implement: I only needed to include a few lines of code around the RPC dispatcher servlet to measure each RPC method call. Time measurements are written to a separate log file, aggregated data is kept in memory for usage with the graphing servlet. Configuration was a matter of minutes.
ReplyDeleteThis is an excerpt from the preHandle() method:
request.setAttribute("stopWatch", new CommonsLogStopWatch());
This code from the postHandle() method:
LoggingStopWatch stopWatch = (LoggingStopWatch)request.getAttribute("stopWatch");
stopWatch.stop(methodName);
Here are the relevant sections of my log4j.cfg:
<logger name="org.perf4j.TimingLogger" additivity="false">
<level value="info"/>
<appender-ref ref="CoalescingStatistics"/>
<appender-ref ref="statsAppender"/>
</logger>
<appender name="CoalescingStatistics"
class="org.perf4j.log4j.AsyncCoalescingStatisticsAppender">
<param name="TimeSlice" value="60000"/>
<appender-ref ref="graphPatientChart"/>
</appender>
<appender name="graphPatientChart"
class="org.perf4j.log4j.GraphingStatisticsAppender">
<param name="GraphType" value="Mean"/>
<param name="TagNamesToGraph" value="getPatientChart,idleNotification"/>
</appender>
<appender name="statsAppender" class="org.apache.log4j.DailyRollingFileAppender">
<param name="datePattern" value="'.'yyyy-MM-dd"/>
<param name="file" value="WEB-INF/log/meona-performance.log"/>
<param name="append" value="true"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%m%n"/>
</layout>
</appender>
I'd like the graphing servlet to be more interactive: It would be nice if I could choose the tags to be included in the graph. Have you come across an UI application that can be used to analyze the time measurement logs?
I am using Per4j to monitor webservice endpoint performance and also internal service and dao class performance.
ReplyDeleteI mainly just log the raw performance statistics to a daily rolling file. Then i use the jar on the command line to analyse the data with different timeslices as i please. I often use the -g commandline option to output a html file which i can then open up and view the data visually which is really useful.
I enjoy using Spring AOP with the @Profiled annotation. It makes timing very clean. I had a few doubters regarding perf4j degrading performance, and i could easily offer that i could turn the logging off by removing the TimingAspect from my Spring applicationContext.xml file.
<!-- just remove and all uses of @Profiled do nothing -->
<bean id="timingAspect" class="org.perf4j.log4j.aop.TimingAspect"/>
Becareful about the mean value and note the max value. While doing performance tuning, we had a method call having wild values with a large standard deviation. Most of the values were around the median, however there were a sprinkling of calls which were 100x more than the average. More of user error than anything, but watch out.
I use theAsyncCoalescingStatisticsAppender with a timeslice of 15000, but hardly read the log. Because i have the raw performance logs, I can chop and change that by running perf4j on the command line.
I tried out the JMX integration and it works as promised from the documentation. But I have no real use at the moment for it.
I have plans to expose the data using SNMP and if it's useful i'll contribute.
In all, i recommend Perf4j.
I've used Perf4J, and eventually ditched it because I was already using Spring AOP. I would love to simply integrate the two , but was having trouble with it (because of the Perf4J appenders).
ReplyDeleteI tried to use Perf4j through annotations and AOP without JMX.
You can handle production cfg through configuration files.
Overall, I liked the Perf4j approach but since I was already using Spring for performance monitoring I didn't need perf4j. One thing that Perf4j gives for free is the min/max/standard dev; with other libs you would have to do the math yourself.
I thing perf4j is nice if you don't have any other lib that can provides interception (aspectJ or AOP), but since I already had spring it was easier to implement performance measurement. You can easily expose bean properties through JMX with Spring.