Most part of long-running hybris projects has issues with hybris start up time. Below could be found tips on how to speed up platform start up.
-
Disable unused tenants in properties
Disabling everything except master tenant allows to save time on spring context creation for each tenant during start up.
1installed.tenants= -
Use more than 1 tomcat start up threads
By adjusting tomcat
startStopThreadsengine configuration property (/hybris/config/tomcat/conf/server.xml) could be increased amount of threads. You can read about it in tomcat documentation. Starting from Hybris 6.7 this option can be safely used on production system(startStopThreads=0is OOTB configuration value). For lower version of Hybris it is not recommended to be used, due to it can lead to broken spring context due to non deterministic extension load order. -
Exclude jars from tag library scanning
Check Hybris start up logs for messages like
At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.In case they are present, you should define which jars are scanned and add exclude them from scanning:- Increase log level to output scanned jars by adding at the bottom of
hybris/bin/platform/resources/tanukiwrapper/bin/jdk_logging.properties:
1 2org.apache.catalina.startup.TldConfig.level=FINE org.apache.jasper.compiler.TldLocationsCache.level=FINE- Run Hybris and get list of scanned jars from logs. Small .sh script can be used to automate things:
1cat console.log | grep "Consider adding" | awk -F '!\/\]' '{print $1}' | awk -F '\/' '{print $NF",\\"}' | sort | uniq- Result of the sh script should be inserted into
/hybris/config/tomcat/conf/catalina.propertiesas value of propertyorg.apache.catalina.startup.TldConfig.jarsToSkip.
- Increase log level to output scanned jars by adding at the bottom of
-
Get rid of groovy classes in Hybris extensions (including testsrc)
During startup Hybris class loader load all classes in extensions (even test files). In case of groovy files class loader must firstly compile groovy into class file and load it after that. Compilation process is pretty slow. For example, removal of 200 groovy test classes speed up Hybris start up and
ant unittestsexecution on 90 seconds. -
Exclude test classes from
ant productionDuring start up Hybris load all class files including the ones placed in testsrc. Removing test classes during
ant productionpackaging will allow to save some time on production server. For example, it can be done by overridingextension_build_jarant macrodef:1 2 3 4 5<jar destfile="@{destdir}/bin/@{extname}server.jar"> <fileset dir="${ext.@{extname}.path}/classes" > <exclude name="**/*Test.class" /> </fileset> </jar> -
Disable task engine
On dev local environment (and on prod env in case of different node types deployments are supported by CI/CD pipiline) could be disabled task engine, which is responsible for tasks and cronjons execution.
|
|
-
Disable backoffice warmup
Warming up the cache from backoffice can be switched off during startup time and loaded during first access.
1backoffice.fill.typefacade.cache.on.startup=false -
Remove unused extension from localextensions.xml
-
Ensure proper relation between extensions
Wrong relation between Hybris extensions can lead to slow start up in various ways.
-
For example,
acceleratorstorefrontcommonscopiescommonwebfolder in all dependent extensions with webmodule. This folder contains taglib definitions, various classes etc., which are loaded during startup. In one of the projects, core extension was related toacceleratorstorefrontcommonsand 4 none storefront web extensions was related to core. Changing dependencies in the way, when core extensions doesn’t requireacceleratorstorefrontcommonsand only storefront extension requires it, allowed to save around 20 sec of build time and 20 sec of start up time. -
In another case wrong dependency on
addonsupportextension leads to slower startup (only storefront extensions must be depndend on addon/addonsupport extensions).
-
-
Disable/remove unused web modules for extensions
- Some of OOTB extensions are shipped with web module extensions, which, most probably, are not used in project. There is possibility to disable them via properties (or whitelist via aspects in case of dockerized deployments)
1 2 3processing.webroot=<disabled> virtualjdbc.webroot=<disabled> mcc.webroot=<disabled> - Custom extensions can have unused web modules (
ant extgendefault template generate extension with web module). In such cases just remove web folder and remove web extension definition fromextensionsinfo.xml
- Some of OOTB extensions are shipped with web module extensions, which, most probably, are not used in project. There is possibility to disable them via properties (or whitelist via aspects in case of dockerized deployments)
-
Decrease time of spring bean creation
-
First of all enable spring debug log for spring bean creation factories:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16log4j2.appender.jsonFile.name = BEANLOG log4j2.appender.jsonFile.type = RollingFile log4j2.appender.jsonFile.Append=false log4j2.appender.jsonFile.filePattern = /tmp/bean_init-%d{yyyyMMdd}.log log4j2.appender.jsonFile.policies.type = Policies log4j2.appender.jsonFile.policies.time.type = TimeBasedTriggeringPolicy log4j2.appender.jsonFile.policies.time.interval = 1 log4j2.appender.jsonFile.layout.type = PatternLayout log4j2.appender.jsonFile.layout.pattern = %r %m%n log4j2.logger.beans.name = org.springframework.beans.factory.support log4j2.logger.beans.level = all log4j2.logger.beans.appenderRef.stdout.ref = BEANLOG -
Determine which beans take a lot of time for creation and check if it possible to get rid of them
For example, in project only in 1 place was used
@Retryannotation fromspring-retrylibrary. Analysis of bean creation logs, shows that creation of retryConfiguration bean takes 16 seconds(it takes so long due to aspect implementation). Rewriting@Retryannotation in one place on simple for loop allows to save 16 seconds during start up. -
Determine which beans have circular dependencies and get rid of it
-
P.S.: Python script which converts spring bean creation log into json, which is much easier to understand and analyze.
|
|