3

I have a website, consisting of about 20 Java Web applications (Servlet/JSP based webapps), of varying sizes, each handling different areas of the site.

The combined size of all 20 war's is 350mb, however by combining them I anticipate being able to ultimately reduce that and realise combined caching benefits.

Is it best to keep them separate, or merge them into a single Uber webapp war file? (and why)

I'm particularly interested in knowing any technical drawbacks of merging them.

Crollster
  • 2,751
  • 2
  • 23
  • 34
  • I'm actually looking for supported technical advice on whether to merge, rather than opinions (@ the person who initiated the close vote) – Crollster Aug 26 '14 at 06:58
  • there is no right or wrong answer here. It depends on the environment, code, team etc. – kazanaki Aug 26 '14 at 10:39

2 Answers2

1

I "vote" to combine them.

Pros

  • Code sharing: If you combine them, you can share code between them (becase there will be only one).
    This does not apply to just your code, it also applies all the external libraries you use which will be the bigger gain I think.

  • Less memory: Combined will also require less memory (might be very significant) because the external libraries used by multiple apps will only have to be loaded once.

  • Maintainability: Also if you change something in your code base or database, you only have to change it in one place and re-deploy one app only.

  • Easier synchronization: If the separate apps do something critical in the database for example, it's harder to synchronize them compared to the case when everything is in one app.

  • Easier collaboration between different parts/modules of the code. If they are combined, you can simply call methods of other modules. If they are in different web apps, you have to do it in a dirty way like HTTP calls, RMI etc.

Cons

  • It will be bigger (obviously). If you worry about it being too big, just exclude the libs from the deployment war, place it under the tomcat libs.

  • The separate apps might use different versions of the same lib. But it's better to sort them out early when it can be done easier and with less work.

  • Another drawback can be the longer deployment time. Again, "outsourcing" the libs can help making it faster.

icza
  • 389,944
  • 63
  • 907
  • 827
  • Thank you. That was my feeling too. It's certainly an attractive option. The other drawback to consider is that of QA - changing a dependent library requires the whole applications be retested. – Crollster Aug 26 '14 at 07:13
  • Never ever synchronize multiple threads inside a web application. You will block multiple frontend users since only IO but not application code is non blocking in most JSP containers. – ooxi Aug 26 '14 at 07:28
  • 1
    @ooxi I never said "synchronizing client threads". They can be background operations. – icza Aug 26 '14 at 07:29
  • Major cons of combined app, server startup time would be high. From development point of view it is not good if it takes too much time start – Sumit Gupta Apr 18 '16 at 08:35
1

There is no drawback in terms of size, memory issues or performance when used in single file as systems are getting faster each day. And as you said running in different apps or same one, the total combined resources consumed will be the same in terms of processing or computation power. Now its a maintenance and administration issues that decides to keep a single or multiple. If you have multiple modules which might changes frequently and independently of one another, its better to have multiple webapps, talking via RMI or WS calls for intercommunication(if required). If all of them are oriented as one unit, where everything changes at once you may go with single app. having multi apps will help to install and update each one easily with respect to change in functionality at module level

deploying multiple applications to Tomcat

http://www.coderanch.com/t/471496/Tomcat/Deploying-multiple-applications-WAR

Hope it helps

Community
  • 1
  • 1
Chakradhar K
  • 501
  • 13
  • 40