How it works now
The dieing process lunches the restart.shIn this time two instances of tomcat run on the same resources
After the old process died the new one should be upThis is highly OS dependent and can cause race conditions and configurations dependent process behaviour.
Concepts
WAR redeployment
Just redeploying the WAR application on Tomcat. This would be an ideal solution but was previously tested i shown the following faults:
- Tomcat generally crushes after 3-6 hot redeploys
- this may be due to some configuration options
- exploded WAR's have many problems, maybe configuring Tomcat to not explode the WAR is an solution
- qcadoo MES may have memory leaks on startup and shutdown
- by default garbage collection does not sweep old unused class bitcode
Issue: http://issues.qcadoo.org/browse/QCADOOMES-117
We should retest with Tomcat 7. It is tolled that it solves many memory leak problems. Plus it has a very nice feature called Parallel Deployments which could use as a fall-back mechanism when some one creates a wrong plugin. We should test how multiple deployments of qcadoo MES affect memory usage.
Useful links:
- http://www.javacodegeeks.com/2011/06/zero-downtime-deployment-and-rollback.html
- http://java.dzone.com/articles/memory-leak-protection-tomcat
- http://www.mkyong.com/tomcat/tomcat-javalangoutofmemoryerror-permgen-space/
- https://blog.coremedia.com/cm/post/1856228/Fight_Tomcats_OutOfMemoryError_PermGen.html
The best way to test this would be to install a clean Tomcat 7 and deploy mes-application*.war (you can find it in qcadoo-src/mes/mes-application/target in a the build sources).
You will however need to:
- copy the qcadoo directory with properties files from the binary distribution to Tomcats 7 distribution
- copy some QCADOO* environmental variables from qcadoo's bin/setenv.sh (or bat) to Tomcats 7 setenv.sh (or bat).
- supply the postgres driver to Tomcats lib directory.
Monitor process
Alternate solution to be considered if the previous fails.
Create a process which monitors the tomcat process. When a restart is requested the monitor firstly shuts down one process and then starts the new one.
We separate the binary distribution in to two directories:
- mes-application - in this catalog we put all the files that ware in the old binary distribution
- qcadoo-monitor - here we create a minimal tomcat distribution the monitoring web application
TEST
I tested Tomcat 7 because I have to check 3 problems with Tomcat :
1.Tomcat generally crushes after 3-6 hot redeploys
2.Qcadoo MES may have memory leaks on startup and shutdown
3.exploded WAR's have many problems, maybe configuring Tomcat to not explode the WAR is an solution
I check this problems with application with spring, hibernate and struts integration example, which we find in this page:
http://www.mkyong.com/struts/struts-spring-hibernate-integration-example/
When I downloads Tomcat 7 and I decided , that I pick up third problem, I find and open folder Tomcat, next open folder conf and open file server.xml
When we open this file, we find verse <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> ,
and we change this vers for <Host name="localhost" appBase="webapps" unpackWARs="false" autoDeploy="false">
When I change and safe this file, I started Tomcat 7 and I check is Tomcat 7 working.
Tomcat 7 working after this change, Next I decided, that I pick up second problem with many leaks.
I started Tomcat 7 , I found procces in System Monitor in Ubuntu, and I looks to use my memory by tomcat
After started my computer use 593980k but Tomcat used 4.4 % it's 26135k , next I deploy and started applicattion with spring, hibernate and struts integration example by tomcat 7 manager ,and I checked , how Tomcat 7 works and look to many leaks, I give table with my analysis, in this table show percentage use memory by tomcat 7 and use memory in my computer,
Percentage use memory after deploy application |
Use Memory |
Memory which use by Tomcat 7 |
Percentage use memory udeploy applicattion |
Use Memory |
Memory which use by Tomcat 7 |
---|---|---|---|---|---|
4.9 % |
606712k |
29728 k |
4.9 % |
585904k |
28709k |
5.4 % |
611612k |
33027k |
5.4 % |
590780k |
31902k |
5.6 % |
613836k |
34374k |
5.6 % |
593136k |
33215k |
5.8 % |
616192k |
35739k |
5.8% |
595360k |
33945k |
5.7 % |
616200k |
35123k |
5.7% |
595536k |
33945k |
5.8 % |
617432k |
35811k |
5.8 % |
596476k |
34595k |
5.6 % |
615332k |
34458k |
5.6 % |
594492k |
33291k |
5.7 % |
616828k |
35159k |
5.7% |
595988k |
33971k |
5.9% |
618192k |
36473k |
5.9% |
597600k |
35258k |
6.0 % |
619548k |
37172k |
6.0% |
598708k |
35922k |
5.5 % |
614952k |
33822k |
5.5 % |
594120k |
32676k |
5.6 % |
615084k |
34444k |
5.6% |
594244k |
33277k |
5.5 % |
615704k |
33863k |
5.5 % |
594732k |
32710k |
5.7 % |
616952k |
35166k |
5.7 % |
596360k |
33992k |
5.8 % |
620424k |
35984k |
5.8 % |
600204k |
34811k |
5.9 % |
622416k |
36722k |
5.9 % |
601444k |
35485k |
5.6 % |
619804k |
34709k |
5.6 % |
599088k |
33548k |
5.7 % |
621160k |
35406k |
5.7 % |
600320k |
34218k |
After this analysis , Tomcat 7 don't make many leaks memory. Tomcat 7 use maximum 6.0 % my memory which was use by my computer.
Maximum Percentage use memory after deploy application: 6,0%
Maximum Memory which use by Tomcat 7 after deploy applicattion: 37172 k
Maximum Percentage use memory after udeploy application: 6,0% to bomb out
Maximum Memory which use by Tomcat 7 after udeploy applicattion: 35922k
In logs is everyting good, I don't found errors,
While I made tests, run application, stop application , tomcat 7 don't crushed and to bomb out.
After this tests we may Deploying mes-application on Tomcat 7 we tutorial find in this page:
http://wiki.qcadoo.org/display/QCDMESBLP/Deploying+mes-application+on+Tomcat+7