Hello Friends,
Lets today discuss about
hybris performance related things which can very usefull when you are going for
Hybris interview for senior position like Architect / hybris solution architect
So below point you must be
know
1. Enable JMX Remote
monitoring:
Remote JMX monitoring will help
us to monitor the server resources (e.g. memory usage and CPU usage) through
JMX client such as VisualVM.
Open <<HYBRIS_HOME>>/conf/local.properties
and
make sure the following properties are
added as part of tomcat.generaloptions .
-Dcom.sun.management.jmxremote.port=50055
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false -
Memory usage also can be
monitored from admin console
Monitoring à Memory
2. JVM Tuning:
The default JVM parameters are
not optimal for running large applications. So the parameters (e.g. memory and
GC) should be tuned for optimal performance of the application.
Create a folder crash under
<<HYBRIS_HOME>>
Open <<HYBRIS_HOME>>/conf/local.properties
and replace the variable java.mem with
the java.mem=6G
Open
<<HYBRIS_HOME>>/conf/local.properties
replace tomcat.generaloptions
with the following data
tomcat.generaloptions=-Xmx6G
-Xms6G -XX:MaxPermSize=1G -XX:NewRatio=1 -XX:SurvivorRatio=12
-XX:+UseParallelGC -XX:+UseParallelOldGC -XX:ParallelGCThreads=8
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=/app/hybris/crash/hybris_java.hprof
-Xloggc:/app/hybris/crash/hybris_gc.log -XX:+PrintGCDetails
-XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps -XX:+PrintHeapAtGC -ea
-Dcom.sun.management.jmxremote.port=50055
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true
-Djava.endorsed.dirs="%CATALINA_HOME%/lib/endorsed"
-Dcatalina.base=%CATALINA_BASE% -Dcatalina.home=%CATALINA_HOME%
-Dfile.encoding=UTF-8 -Dlog4j.configuration=log4j_init_tomcat.properties
-Djava.util.logging.config.file=jdk_logging.properties -Djava.io.tmpdir="${HYBRIS_TEMP_DIR}"
${jvm.crashHack}
Change
the XX:HeapDumpPath and –Xloggc path accordingly
a. Apply
the required load to the system – Apache JMeter can be used to load the request
to the system.
b. Monitor the system resources like CPU, Memory
and threads using VisualVM while load is applied to the system
c.Change the memory parameters
and GC parameters based on the above test result.
If you provide too little
memory to an application it will run out of memory. The JVM will not be able to free up memory space at the rate that your
application needs it. In this scenario JVM
will throw an OutOfMemoryError and
shut down completely
The above three steps should be
repeated to achieve the optimum system performance by applying different values
for the parameters.
3. Thread Tuning:
Modify the thread parameters
based on the system performance.
Open <<HYBRIS_HOME>>/bin/platform/
project.properties and replace the
following property values.
tomcat.acceptcount=150
tomcat.maxthreads=300
Change the counts accordingly.
Open
<<HYBRIS_HOME>>/ config/tomcat/conf/server.xml
And replace the below content
Old
<Connector
port="${tomcat.http.port}"
maxHttpHeaderSize="8192"
maxThreads="${tomcat.maxthreads}"
protocol="org.apache.coyote.http11.Http11Protocol"
executor="hybrisExecutor"
enableLookups="false"
acceptCount="100"
connectionTimeout="20000"
URIEncoding="UTF-8"
disableUploadTimeout="true"
/>
New
<Connector
port="${tomcat.http.port}"
maxHttpHeaderSize="8192"
maxThreads="${tomcat.maxthreads}"
protocol="org.apache.coyote.http11.Http11Protocol"
executor="hybrisExecutor"
enableLookups="false"
acceptCount="150"
connectionTimeout="20000"
URIEncoding="UTF-8"
disableUploadTimeout="true"
/>
Change
the acceptCount="150" accordingly
4. Improve Caching:
Open <<HYBRIS_HOME>>/
bin/platform/project.properties
Replace cache.main property value with cache.main=50000
5. Thread Dumps:
Thread Dump is a snapshot taken
at a given time which provides with a complete listing of all created Java
Threads. The thread dump can be analyzed to determine the bottleneck or
blocking threads.
Different tools can be used to
analyze the thread dumps e.g. Samurai and IBM Thread and Monitor Dump Analyzer
for Java.
Thread Dump can be generated
from admin console
Monitoring à Thread Dump
Click on Download button to
download the current thread dump.
6. JDBC Logging:
Sometimes the application will
be very slow due to slow running queries. Analyzing the slower running queries
using JDBC logging and create the indexes wherever required can drastically
improve performance.
Monitoring à
Database à JDBC logging
Click on Start logging and
click on Stop logging after particular time.
Click on Download log
Click on
JDBC log analysis à Analyze to find out the details on
the queries executed