Java Web Applications – Is it Better to Have One or Multiple?

Architecturejavaweb-applications

I am going to develop a server application to provide the functionality of a book keeping software in tomcat server. I can think of two ways to achieve this.

  1. Creating a single web application – Let's say we have to provide invoice management, user management and report management. All these logic is bound to this single web application. Functionalities will be separated by package structure.
  2. Creating multiple web applications – Create separate web app to provide each functionality. ex: single web application for invoice management, another single web app for user management and so on.

One advantage I can think of creating multiple web apps for each functionality is loose coupling. ex: Developer doesn't want to concentrate on invoice related things when he develops on user management module etc. Another advantage is if one customer wants only a sub set of all the features available, We can remove other web apps easily and provide a solution quickly. I wanted to know pros and cons of these two approaches before going to implementation.

Best Answer

If you want to go for maximum scalability you could go for several apps, for example (but not necessarily) implementing the principle of microservices.

Having several apps, allows you to spread the apps more easily accross several web servers, or containers (like Docker or Microsoft's nanoserver) to quickly manage an internet level load peak. In this respect, the monolithic app is not such a good idea anymore for the web.

In both case, you have still the choice of the database and data model: you could for example let several apps connect to the same database. THis has the advantage of realtime synchronisation and consistency. However this will also become the main bottleneck and obstacle to scalability.

This is precisely an aspect promoted by the microservice architecture: each "service" ("app") its own database, so that each "service" could also evolve at its own pace with less risk of breaking data structures used by other apps/functions.