Your SlideShare is downloading. ×
Performance Monitoring With AOP
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Performance Monitoring With AOP

815
views

Published on

Published in: Technology, Design

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
815
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
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 Monitoring With AOP @ivannoteshttp://www.ivannotes.com
  • 2. Agenda 为什么需要对性能进行监控 哪些点需要进行性能监控 简单即是美— 如何来做性能监控 Future 参考资料 Q&A
  • 3. 为什么需要对性能进行监控 问道 哪个接口调用最耗时 哪个页面访问速度最慢 哪个接口调用次数最多 出问题的时候是哪个接口错误率最高 一切为了稳定,一切为了快速
  • 4. 哪些点需要进行性能监控 外部依赖 谨慎的处理外部依赖 页面访问 了解网站的运行状况 SPI 一旦发布就要终身负责
  • 5. 简单即是美—如何来做性能监控 性能统计 Perf4J 无缝监控  Delegator + Spring AOP  Rose Intercepter  AspectJ
  • 6. Perf4J System.out.println(endTime – startTime); 编程模型 StopWatch sw = new **StopWatch(); sw.start(); // your code sw.stop(tag);
  • 7. Perf4J 结合 Commons Log Log logger = LogFactory.getLog(“performance”); StopWatch watch = new CommonsLogStopWatch(logger); Log4j 配置 <appender name="delegatorPerfAppender" class="org.perf4j.log4j.AsyncCoalescingStatisticsAppender"> <param name="TimeSlice" value="60000" /> <appender-ref ref="delegatorAppender" /> </appender> <appender name="delegatorAppender" class="org.apache.log4j.DailyRollingFileAppender"> <param name="File" value="/performance.log" /> <param name="DatePattern" value=".yyyyMMdd" /> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="[%-5p %d{yyyy-MM-dd HH:mm:ss.SSS}] %l [%m] %n" /> </layout> </appender>
  • 8. Per4J CoalescingStatistics
  • 9. 无缝监控 Delegator + Spring AOP 外部依赖约定使用 Delegator 封装,利用 Spring AOP 进行切片监控接口调用性能 实现文档: http://www.ivannotes.com/2012/spring-aop/
  • 10. 无缝监控 Rose Interceptor 利用 Rose 的 Interceptor 采用 round 机制对 Web 服务进行性能监控 public class WebPerfomanceInterceptor extends ControllerInterceptorAdapter { private static final Log logger = LogFactory.getLog(“performance"); @Override public int getPriority() { return 200; } @Override protected Object round(Invocation inv, InvocationChain chain) throws Exception { StringBuilder sb = new StringBuilder(); sb.append(inv.getRequest().getMethod()).append("|"); sb.append(inv.getResourceId()); StopWatch watch = new CommonsLogStopWatch(logger); try { watch.start(); return super.round(inv, chain); } finally { watch.stop(sb.toString()); } } }
  • 11. 无缝监控 AspectJ 对 SOA 服务进行监控 × Compile Time weaving √ Load Time weaving √ @AspectJ Style
  • 12. 无缝监控1) Java agent2) aop.xml3) @AspectJ
  • 13. Future Abstract & Open Data Visualization Dynamic Switch
  • 14. 参考资料 http://www.ivannotes.com/2012/spring-aop/ http://perf4j.codehaus.org/devguide.html http://www.eclipse.org/aspectj/doc/released/adk15notebook/in <Spring reference> <AspectJ in Action>
  • 15. Q&A
  • 16. { Thanks;}