March 16, 2020
Estimated Post Reading Time ~

Performance Tuning

Overview
While running the CQ5 application you might come across performance issues.
CQ OOTB application comes with some OOTB setting enable that might affect performance.

The performance issue can be because of the following reason.
Custom Application Issue: This could be anything, ranging from the poorly written application, Third-party application, etc.
Product Issue: Some module of the product itself is performing slow.
Hardware Issue: Performance issue could be because of hardware issues as well like disk I/O issue.
Network Issue: Network issues could also result in a performance issue.
There are some basic rules that you should follow for optimizing performance:
Think about optimization during the early stage of the project.

Be realistic about optimization.
Know your hardware requirement before the project is started based on capacity and volume.
Optimize the most important thing first and test before applying it to production.
Response Time Analysis
In order to find issue with response time, the good starting point is CQ request log, that can be found under /crx-quickstart/logs/request.log.
request.log looks like as follows:
22/May/2013:09:51:26 -0700 [2881] -> GET /crx/packmgr/endorsed/extjs-theme/images/crx/tree/elbow-minus-nl.gif HTTP/1.1
22/May/2013:09:51:26 -0700 [2881] <- 200 image/gif 1ms
22/May/2013:09:51:26 -0700 [2882] -> GET /crx/packmgr/endorsed/extjs-theme/images/crx/qtip/tip-sprite.gif HTTP/1.1
22/May/2013:09:51:26 -0700 [2882] <- 200 image/gif 1ms
22/May/2013:09:51:26 -0700 [2883] -> GET /crx/packmgr/endorsed/extjs
22/May/2013:09:51:26 -0700 [2883] <- 200 image/gif 2ms

It contains the following information:
Date and time when request and response is made
The ID of request (2881 in above example)
Arrow indicating request or response (-> mean request and <- mean response)
Then request line which contains
METHOD (GET, POST or HEAD)
REQUESTED_RESOURCE
PROTOCOL
Response Line contains
Status Code (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html)
MIME Type
Response Time
In order to analyze response time, you can either use any script to parse the request log or use a rlog analyzer that comes with CQ. You can find it under /crx-quickstart/opt/helpers/rlog.jar
Rlog syntax
java -jar rlog.jar
Request Log Analyzer Version 21584 Copyright 2005 Day Management AG
Usage:
java -jar rlog.jar [options] <filename>

Options:
-h Prints this usage.
-n <maxResults> Limits output to <maxResults> lines.
-m <maxRequests> Limits input to <maxRequest> requests.
-xdev Exclude POST request to CQDE.
Using request log you can find top 10 slow request
Top Slow Request using rlog
java -jar rlog.jar logs/request.log
*Info * Parsed 986 requests.
*Info * Time for parsing: 48ms
*Info * Time for sorting: 2ms
*Info * Total Memory: 81mb
*Info * Free Memory: 79mb
*Info * Used Memory: 1mb
------------------------------------------------------
60320ms 23/May/2013:11:01:26 -0700 302 POST /crx/packageshare/login.html text/html; charset=utf-8
17027ms 23/May/2013:19:52:13 -0700 200 POST /etc/citrixreports/damreport/_jcr_content.html text/html
6505ms 23/May/2013:23:14:36 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
5943ms 23/May/2013:14:14:38 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
4777ms 23/May/2013:11:02:26 -0700 200 GET /crx/packageshare/index.html text/html; charset=utf-8
4507ms 23/May/2013:14:44:15 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
4016ms 23/May/2013:14:45:27 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
3689ms 23/May/2013:15:13:27 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
3574ms 23/May/2013:23:20:18 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
3534ms 23/May/2013:15:55:28 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
3512ms 23/May/2013:15:19:53 -0700 200 POST /crx/packmgr/service.jsp text/plain; charset=utf8
3114ms 23/May/2013:14:45:45 -0700 200 POST /etc/citrixreports/damreport/_jcr_content.html text/html
With this you can find slow requests and then work on that to find why response time is slow.

Search Performance Tuning
CQ uses different API to perform a search against repository including JCR Search, Query Builder API
Search Indexes in CQ is stored under
/crx-quickstart/repository/workspace/crx.default/index -> Lucene Index for Data
/crx-quickstart/repository/repository/index -> Lucene Index for Version

In order to debug JCR Search you can do the following:
JCR Query Debug

Log in to Felix Console: http://localhost:4502/system/console/configMgr
From "Factory Configurations", create "Apache Sling Logging Writer Configuration"
Set value of "Log File" to "../logs/search.log"
Click on "Save"
From "Factory Configurations", create "Apache Sling Logging Logger Configuration"
Set value of "Log Level" to "Debug"
Set value of "Log File" to "../logs/search.log"
Add "Logger" => org.apache.jackrabbit.core.query.QueryImpl If you are using SQL2 then use org.apache.jackrabbit.core.query.lucene.join.QueryEngine
Click on "Save"
Starting with CRX 2.3, there is an MBean that exposes query statistics. These statistics include the top long-running queries.

The MBean can be accessed via any JMX client or the built-in client in the OSGi web console:
http://localhost:4502/system/console/jmx/com.adobe.granite%3Atype%3DQueryStat
In order to debug search through Query Builder, you can use following URL
http://localhost:4502/libs/cq/search/content/querydebug.html



You can do following to improve search performance (Only if search performance is slow)

Set CRX Search Index's resultFetchSize param
Result Fetch Size Config
If the result set of a jcr query is large, then the loading the complete setand checking ACLs on them is quite expensive.
To remedy this, limit the fetch size to 50 as via the SearchIndex element in the workspace.xml:
<param name="resultFetchSize" value="50"/>
e.g.
<SearchIndex class="com.day.crx.query.lucene.LuceneHandler">
<param name="path" value="${wsp.home}/index"/>
<param name="resultFetchSize" value="50"/>
</SearchIndex>
Set the CRX Search cacheSize param

Search Cache Size Setting
The search cacheSize can also be set in the SearchIndex element in workspace.xml. Set this parameter to 100000:
<param name="cacheSize" value="100000" />
e.g.
<SearchIndex class="com.day.crx.query.lucene.LuceneHandler">
<param name="path" value="${wsp.home}/index"/>
<param name="resultFetchSize" value="50"/>
<param name="cacheSize" value="100000" />
</SearchIndex>

This parameter is documented here.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.