简体   繁体   中英

Web application deployed on tomcat is slow on first access?

We have a Spring MVC web application deployed on Tomcat 7. Every time I deploy a new build, it runs very slowly for first time. Even the login page takes time to come up.

What would be the reason for this and what can be done to make it faster?

This is a valid scenario. Your server load the servlets and action on first heat. So it will be slow on first access.

You can set the <loadonstartup>1</loadonstartup> in web.xml.

The above option will load required files on server startup.

If you are using Spring annotations make sure you have the correct packages configured in the <component:scan /> tag. That is do not include the same package(s) to scan in applicationContext.xml and xxx-servlet.xml file. Spring will scan them twice otherwise, I have seen this.

Also remember any JSPs will be compiled the first you use them, so this will be slower on first hit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM