狠狠撸

狠狠撸Share a Scribd company logo
Performance Monitoring With AOP

                            @ivannotes
http://www.ivannotes.com
Agenda
?   为什么需要对性能进行监控
?   哪些点需要进行性能监控
?   简单即是美— 如何来做性能监控
?   Future
?   参考资料
?   Q&A
为什么需要对性能进行监控

?   问道
    哪个接口调用最耗时
    哪个页面访问速度最慢
    哪个接口调用次数最多
    出问题的时候是哪个接口错误率最高
?   一切为了稳定,一切为了快速
哪些点需要进行性能监控

?   外部依赖
    谨慎的处理外部依赖
?   页面访问
    了解网站的运行状况
?   SPI
    一旦发布就要终身负责
简单即是美—如何来做性能监控

?   性能统计 Perf4J

?   无缝监控
    ?   Delegator + Spring AOP
    ?   Rose Intercepter
    ?   AspectJ
Perf4J
?   System.out.println(endTime – startTime);
?   编程模型
    StopWatch sw = new **StopWatch();
    sw.start();
    // your code
    sw.stop(tag);
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>
Per4J
?   CoalescingStatistics
无缝监控
?   Delegator + Spring AOP
    外部依赖约定使用 Delegator 封装,利用 Spring AOP
    进行切片监控接口调用性能
    实现文档: http://www.ivannotes.com/2012/spring-aop/
无缝监控
?   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());
            }
        }
    }
无缝监控
?   AspectJ 对 SOA 服务进行监控
    × Compile Time weaving
    √ Load Time weaving
    √ @AspectJ Style
无缝监控

1) Java agent
2) aop.xml
3) @AspectJ
Future
?   Abstract & Open
?   Data Visualization
?   Dynamic Switch
参考资料
?   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>
Q&A
{ Thanks;
}
Ad

Recommended

Asp net (1)
Asp net (1)
Kyle Lin
?
使用厂耻辫别谤惫颈蝉辞谤守护辫测迟丑辞苍进程
使用厂耻辫别谤惫颈蝉辞谤守护辫测迟丑辞苍进程
果 果
?
础惫尘2虚拟机浅析与补蝉3性能优化(陈士凯)
础惫尘2虚拟机浅析与补蝉3性能优化(陈士凯)
贵尝础厂贬开发者交流会
?
PHPUnit
PHPUnit
jameslabs
?
闯补惫补单元测试
闯补惫补单元测试
darlingshan
?
Free rtos workshop1@nuu
Free rtos workshop1@nuu
紀榮 陳
?
12. 除錯、測試與效能
12. 除錯、測試與效能
Justin Lin
?
闯础痴础内存泄漏及诊断
闯础痴础内存泄漏及诊断
ivannotes
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?

More Related Content

Featured (20)

2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?

Performance Monitoring With AOP

  • 1. Performance Monitoring With AOP @ivannotes http://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 agent 2) aop.xml 3) @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