您是否使用过 Perf4J 来收集和分析 Java 应用程序中的性能指标?

发布于 2024-08-19 08:45:02 字数 294 浏览 13 评论 0原文

您是否在 Java 应用程序中使用 Perf4J 来收集和分析性能统计数据?

典型的模式是什么(使用日志文件、实用程序、UI、JMX 等)?

您使用过注释和基于 AOP 的功能吗?

您使用过 JMX 集成吗?

您是如何处理生产配置的?

您是否将性能统计视图/报告作为应用程序的一项功能包含在内?

请说明您是否以及为什么决定使用替代库/方法。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

缱倦旧时光 2024-08-26 08:45:03

我正在使用 Per4j 来监视 Web 服务端点性能以及内部服务和 dao 类性能。

我主要只是将原始性能统计数据记录到每日滚动文件中。然后我在命令行上使用 jar 来分析不同时间片的数据。我经常使用 -g 命令行选项输出一个 html 文件,然后我可以打开该文件并直观地查看数据,这非常有用。

我喜欢使用带有 @Profiled 注释的 Spring AOP。它使计时变得非常干净。我对 perf4j 降低性能有一些怀疑,我可以轻松地提出,我可以通过从 Spring applicationContext.xml 文件中删除 TimingAspect 来关闭日志记录。

<!-- just remove and all uses of @Profiled do nothing -->
<bean id="timingAspect" class="org.perf4j.log4j.aop.TimingAspect"/>

注意平均值并记下最大值。在进行性能调整时,我们有一个方法调用,其野值具有很大的标准差。大多数值都在中位数附近,但也有少数呼叫数量比平均值高 100 倍。用户错误比任何事情都多,但要小心。

我使用时间片为 15000 的 AsyncCoalescingStatisticsAppender,但几乎不读取日志。因为我有原始性能日志,所以我可以通过在命令行上运行 perf4j 来修改和更改它。

我尝试了 JMX 集成,它按照文档中的承诺工作。但目前我对它没有真正的用处。

我计划使用 SNMP 公开数据,如果有用的话我会做出贡献。

总而言之,我推荐 Perf4j。

I am using Per4j to monitor webservice endpoint performance and also internal service and dao class performance.

I 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.

走野 2024-08-26 08:45:03

我在客户端-服务器应用程序中使用 Perf4J 来计时 RPC 调用。实现起来非常简单:我只需要在 RPC 调度程序 servlet 周围包含几行代码来测量每个 RPC 方法调用。时间测量结果写入单独的日志文件,聚合数据保存在内存中以供绘图 servlet 使用。配置只需几分钟。

这是 preHandle() 方法的摘录:

request.setAttribute("stopWatch", new CommonsLogStopWatch());

来自 postHandle() 方法的代码:

LoggingStopWatch stopWatch = (LoggingStopWatch)request.getAttribute("stopWatch");
stopWatch.stop(methodName);

以下是我的 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>

我希望图形 servlet 更具交互性: 如果可以的话那就太好了选择要包含在图表中的标签。您是否遇到过可用于分析时间测量日志的 UI 应用程序?

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.

This 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?

傲性难收 2024-08-26 08:45:03

我曾经使用过 Perf4J,但最终放弃了它,因为我已经在使用 Spring AOP。我很想简单地将两者集成起来,但遇到了麻烦(因为 Perf4J 附加程序)。

我尝试通过注释和 AOP 来使用 Perf4j,而不使用 JMX。
您可以通过配置文件处理生产cfg。

总的来说,我喜欢 Perf4j 方法,但由于我已经使用 Spring 进行性能监控,所以我不需要 perf4j。 Perf4j 免费提供的一件事是最小/最大/标准开发;对于其他库,您必须自己进行数学计算。

如果你没有任何其他可以提供拦截(aspectJ 或 AOP)的库,我认为 perf4j 很好,但由于我已经有了 spring,所以更容易实现性能测量。您可以使用 Spring 通过 JMX 轻松公开 bean 属性。

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

I 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文