Java simon--Performance Bottleneck analysis tool

Source: Internet
Author: User

With AOP and Java instrument, Java has a lot of good performance monitoring tools that can help us analyze system bottlenecks effectively. For example, using JVISUALVM GUI to connect the JVM application can monitor the various states of the application, you can see the execution time of each function, but many times we do not have JVISUALVM GUI to help debug, this time I prefer to use Javasimon, The service layer method call time can be monitored through an AOP configuration, the JDBC call time is monitored, and the time required for the Web HTTP request can be monitored, with the web dashboard intact. Let's talk about how to use Java Simon in spring related projects.

1. Add Java Simon's package to the Web application, if it is a MAVEN project, by adding the following dependenncy:

<span style= "FONT-SIZE:14PX;" >            <dependency>                <groupId>org.javasimon</groupId>                <artifactId> javasimon-spring</artifactid>                <version>${<span style= "font-family:arial, Helvetica, Sans-serif ;" >simon-version</span>}</version>            </dependency>            <dependency>                <groupid >org.javasimon</groupId>                <artifactId>javasimon-console-embed</artifactId>                < Version><span style= "font-family:arial, Helvetica, Sans-serif;" >${simon-version}</span></version>            </dependency></span>

2. Add the following configuration to Web. xml:

2.1 Open Web Dashboard, note that dashboard can not use the monitor Web Dashboard before simon-filter.

2.2 Join Simon-filter Monitor all Web requests time consuming

<span style= "FONT-SIZE:14PX;" ><web-app version= "2.5" xmlns= "Http://java.sun.com/xml/ns/javaee" xmlns:xsi= "Http://www.w3.org/2001/XMLSche Ma-instance "xsi:schemalocation=" Http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_ 5.xsd > <filter> <filter-name>simon-filter</filter-name> <fil                ter-class>org.javasimon.javaee.simonservletfilter</filter-class> <!--Optional-- <init-param> <param-name>prefix</param-name> <par Am-value>com.my.app.web</param-value> </init-param> <!--Optional Basic PL Ain-text Console--<init-param> <param-name>console-path</param- Name> <param-value>/simon-filter</param-value> </init-param>                        <!--optional, necessary when long requests should be reported-<init-param> <param-name>report-threshold-ms</param-name> <param-value>1000</param- Value> </init-param> <!--optional, used by reporting Mechanism-default Implem Entation uses manager.message to log stuff, this goes to stdout, you can override it to report to F Ile-<init-param> <param-name>request-reporter-class</param-nam E> &LT;PARAM-VALUE&GT;ORG.JAVASIMON.JAVAEE.REQREPORTER.STANDARDREQUESTREPORTER&LT;/PARAM-VALUE&G                T                </init-param> <!--optional, used to specify parameters for Stopwatchsource instance-- <init-param> <param-name>stopwatch-source-props</param-name>                       <param-value>includeHttpMethodName=ALWAYS</param-value> </init-param&                Gt <!--see Javadoc for Org.javasimon.javaee.SimonServletFilter for more about available parameters--</fil Ter> <!--This was related to optional Web Console (not the basic ones included in the filter above)-not NEC Essary for monitoring itself if your use different the "How to get" the results (JMX, own mechanism, ...)--&G        T <filter> <filter-name>simon-console-filter</filter-name> <filter-class&                        Gt;org.javasimon.console.simonconsolefilter</filter-class> <init-param> <param-name>url-prefix</param-name> &LT;PARAM-VALUE&GT;/SIMON-CONSOLE&LT;/PARAM-VALUE&G                T </init-param> </filter> <!--in case Console are used it is recommended To put it in front of the monitoring filter, so it's not monitored-<filter-mapping> <filter-name>simon-console-filter</filter-name> <url-pattern>/*</url-pat tern> </filter-mapping> <filter-mapping> <filter-name>simon-filter</f Ilter-name> <url-pattern>/*</url-pattern> </filter-mapping></web-app>< /SPAN>
3. In the Spring application context XM file, monitor all spring-initialized beans in an AOP way

<span style= "FONT-SIZE:14PX;" ><bean id= "Monitoringinterceptor" class= "Org.javasimon.spring.MonitoringInterceptor"/></span>

<span style= "FONT-SIZE:14PX;" >  <aop:config>        <aop:advisor advice-ref= "monitoringinterceptor" pointcut= "Execution (public * Com... Service.*.* (..)) " />    </aop:config></span>

4. Launch the app, view Http://ip/app/simon-console to see the execution time of all monitored service methods, as well as Web requests, and add the ability to monitor JDBC (by wrapping the JDBC driver or JDBC Datasource/connection.

Java simon--Performance bottleneck analysis tool

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.