A ZK Performance Monitor"
m (→Download) |
|||
Line 44: | Line 44: | ||
==1. Download Files== | ==1. Download Files== | ||
*copy *.jar file to ./WEB-INF/lib | *copy *.jar file to ./WEB-INF/lib | ||
− | [https://sourceforge.net/projects/zkforge/files/Small%20Talks/Performance%20Meter%20Tool/monitor.jar/download ZK | + | [https://sourceforge.net/projects/zkforge/files/Small%20Talks/Performance%20Meter%20Tool/monitor.jar/download ZK 5 monitor.jar] |
or | or | ||
[https://github.com/downloads/samchuang/monitor/monitor.jar ZK 6 monitor.jar] | [https://github.com/downloads/samchuang/monitor/monitor.jar ZK 6 monitor.jar] |
Revision as of 10:00, 3 October 2012
Sam Chuang, Engineer, Potix Corporation
January 5, 2010
Applicable to ZK 3.6 and later
Introduction
ZK was among the first Ajax frameworks to introduce a performance meter utility for monitoring Ajax applications. A performance test provides us with the knowledge of whether the application meets the performance criteria, such as server response time, or the rendering time on browsers, which helps us in determining a web application's reliability and scalability. In this Small talk, an implementation of ZK's Performance Meter interface is illustrated.
ZK's Performance Meter Interface
The [Javadoc Error! type should either be a class or an interface] interface provides timestamped information in different stages of a request. The figure below shows the stages in a request.
The interface defines five functions. Using these functions, we could get a timestamp in each stage of request cycle.
- Figure: This is a graphical representation of a complete ZK request cycle.
- T1: requestStartAtClient (java.lang.String requestId, Execution exec, long time)
- T2: requestStartAtServer(java.lang.String requestId, Execution exec, long time)
- T3: requestCompleteAtServer(java.lang.String requestId, Execution exec, long time)
- T4: requestReceiveAtClient(java.lang.String requestId, Execution exec, long time)
- T5: requestCompleteAtClient(java.lang.String requestId, Execution exec, long time)
Note: Each request has a unique id called requestId, which distinguishes one request from another.
Define time period by request stages
- Server Execution time: T3 - T2
- Client Execution time: T5 - T4
- Network Latency time: (T4 - T3) + (T2 - T1)
Note
- About request time period: when we make a connection to a page for the first time, only Server Execution time is available. The Client Execution time period is saved on the client side, which will not be made available on the server side until the data is sent to the server along with the next request.
For more information, please also refer to a previous contribution by Jiri Bubnik: Performance Monitoring of ZK Application
A Demo of Performance Meter Implementation
Here is an implementation of the Performance Meter interface.
Running the Demo
1. Download Files
- copy *.jar file to ./WEB-INF/lib
ZK 5 monitor.jar or ZK 6 monitor.jar
- copy *.zul to ./
monitor.zul stats.zul barchart.zul piechart.zul stats.zul
2. Register Listeners
In zk.xml, register two listeners to ZK
<?xml version="1.0" encoding="UTF-8"?>
<zk>
<listener>
<description>Monitor the statistic</description>
<listener-class>org.zkoss.zk.ui.util.Statistic</listener-class>
</listener>
<listener>
<description>ZK performance monitor</description>
<listener-class>org.zkoss.zkdemo.monitor.PerformanceMeter</listener-class>
</listener>
</zk>
3.Monitor Performance
Open monitor.zul in your browser to view data
Show Each Request's Average Time
- 1. Click Refresh to list the data
- Note: Each request made to the server is recorded, and the average time and time percentage in each stages are calculated.
Show Monitored Data
- 1. Click Start to start monitoring request data in session
- 2. Click Refresh to update and display data
- 3. Click Stop to stop monitoring request data in session
- Note: This table shows each request made to the server in a session; each request interval is kept and may be selected for comparisons.
Stage Comparison Chart
- 1. Select rows in the grid.
- 2. Click Stage Comparison Chart to draw
- Note: This chart compares each selected row (request) in different stages.
Time Percentage Chart
- 1. Select rows in the grid.
- 2. Click Time Percentage Chart to draw
- Note: This chart compare time percentage
Server Statistics
- Click Reload to list data
- Note:This grid shows the number of "Sessions", "Desktops" and "Updates".
Download
- download ZK 5 monitor or
ZK 6 monitor war file
Summary
Performance is a critical factor to a web application. The Performance Meter utility allows us to determine the request execution time, compare the results, and identify the bottleneck with ease.
If you have any problems, please feel free to post on the ZK forum.
Comments
Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License. |