How do I make Tomcat startup faster?

Jars

  1. Remove any jar files you don't need. When searching for classes every JAR file needs to be examined to find the needed class. Also during webapp startup, jar files are searched for TLD files. If the jar file is not there - there is nothing to search.
  2. Tomcat 7.+: You can add jars that do not need to be scanned for TLD files, Annotations and Web fragments to the value oftomcat.util.scan.DefaultJarScanner.jarsToSkip property in conf/catalina.properties file. Maybe later there would be a more convenient way to configure this feature.

Memory

  1. Tweak memory parameters - Google is your friend.

Config

  1. Trim the config files as much as possible. XML parsing is not cheap. The less there is to parse - the faster things will go.

Webapp

  1. Make sure your code is not doing slow things. (Use a profiler)
  2. Remove any webapps you don't need. (So remove the all the webapps installed with tomcat)
  3. Add metadata-complete="true" attribute to the <web-app> element of your WEB-INF/web.xml file, if you do not need the features that are enabled by the default value of "false" of that attribute. This way Tomcat would not waste time scanning the libraries to autodiscover annotated classes and web fragments.

Starting several web applications in parallel

  1. With Tomcat 7.0.23+ you can configure it to start several web applications in parallel. This is disabled by default but can be enabled by setting the startStopThreads attribute of a Host to a value greater than one.

Entropy Source

  1. Tomcat 7+ heavily relies on SecureRandom class to provide random values for its session ids and in other places. Depending on your JRE it can cause delays during startup if entropy source that is used to initialize SecureRandom is short of entropy. You will see warning in the logs when this happens, e.g.:

<DATE> org.apache.catalina.util.SessionIdGenerator createSecureRandom

INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] milliseconds.

  • There is a way to configure JRE to use a non-blocking entropy source by setting the following system property: -Djava.security.egd=file:/dev/./urandom

Note the "/./" characters in the value. They are needed to work around known JRE bug #6202721.

转载于:https://www.cnblogs.com/kasuo/archive/2013/06/06/3122284.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值