ajm
ajm

Reputation: 13203

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?

Upvotes: 5

Views: 6128

Answers (2)

Ayub Malik
Ayub Malik

Reputation: 2568

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.

Upvotes: 1

Gunjan Shah
Gunjan Shah

Reputation: 5168

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.

Upvotes: 4

Related Questions