How to force tomcat server to use shared libraries & resources for different virtual hosts?

StackOverflow https://stackoverflow.com/questions/19319164

  •  30-06-2022
  •  | 
  •  

문제

I've a GWT application which is running on debian with tomcat server 7. This application uses connection pooling technique for communicating with back-end database.
I've some sites (with different domains) that all of them use same application & only difference between them is the database connection pool!
I have to create a virtual host for every domain, all virtual host configurations are exactly similar, except in hostname & database connection pool resource configuration that specifies database name, username and password.
Now here are the questions:

  1. is it the correct way that use different separate virtual host for every domain in this situation?
  2. does tomcat loads classes & libraries separately for every virtual host? or it just loads one instance for all? What techniques can be use for optimizing tomcat memory usage in this case?
  3. using this solution, tomcat restart time becomes too long because it need to reload all application contexts again. Is there any way to increase restart speed of tomcat?
도움이 되었습니까?

해결책

  1. Yes

  2. Web applications have their own class loaders, virtual hosts do not. So each app in each host will have its own class loader. If all apps share the same library you can place it in $CATALINA_BASE/lib. The downside is all apps then have to use that version and upgrading it means rebooting the entire Tomcat instance.

  3. If you use a recent version of Tomcat 7, you can take advantage of parallel deployment. Set startStopThreads to something greater than 1 on the Engine element in server.xml

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top