When do you need to use separate domains in Glassfish?

If you want to host multiple, fairly independent applications on a Glassfish server, do you need separate domains? In particular:

  • Can applications in the same domain interfere with each other in any way?
  • Can different applications in the same domain listen on different IP addresses / ports?

If so, when / why are you really using a separate domain?

+4
source share
2 answers

From a logical point of view, separate domains or the coexistence of several applications in the same domain are similar (you can configure HTTP ports, etc.).

The main difference is that in one case you have one JVM that runs all applications, and in the other case you have several JVMs. This can make a big difference. On one of our client sites, we initially deployed everything in one domain / JMV, but finally decided to split the deployment in multiple domains / JVM, because it gave better performance, especially garbage collection time. So yes, applications can intervene, but very indirectly.

In addition, Java EE applications cannot really be stopped or started, so the domain is the smallest unit you can turn on and off. In some cases, this is convenient.

Finally, there are things that are per-domain, like an app. server log levels, timer persistence, etc. If you need two applications with different settings for such things, you will need two domains.

+6
source

Consider this scenario. You have 2 applications deployed in your domain: the lightweight frontend application and the backend processing application (say, execute as a scheduled task every hour and process a huge amount of data). In such a scenario, you may have a problem with the backend application, which will use all the resources of your virtual machine that make the frontend application immune to extreme scenarios or, even worse, kill jvm (say, due to a memory error or space errors gen).

If you split this into two domains, even if your backend is slow, the other application is safe because it has its own virtual machine and memory for playback.

+1
source

All Articles