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 some way?
- Can different apps in the same domain listen on different IP addresses/ports?
If so, when/why would you actually开发者_StackOverflow中文版 use a separate domain?
From a logical point of view, separate domains or co-existence of several apps in a single domain are similar (You can configure HTTP ports, etc.).
A main difference is that in one case you have one JVM running all the apps, and in the other case you have several JVMs. This can make a big difference. On one of our customer site, we initially deployed everything in one domain/JMV, but finally decided to split the deployment in several domains/JVM because it was giving better performance, especially garbage collection time. So yes, applications can interfere but in a very indirect way.
Also, Java EE apps can't really be shutdown or started, so the domain is the smallest unit that you can power on and off. In some cases, it's handy.
Lastly, there are things that are per-domain, like app. server log levels, timer persistence, etc. If you want two apps with different settings for such things, you will need two domains.
Consider this scenario: You have 2 applications deployed in your domain: lightweight frontend app and backend processing app (Say running as scheduled task every hour and processing huge quantities of data). In such scenario you could have the problem of backend app taking up all the resources your VM has making frontend app unresponsive in extremal scenarios, or even worse, kill the jvm (say out of memory error, or perm gen space errors).
IF you split that into two domains, even if your backend stuff brakes, other application is safe as it has it's own VM and memory to play with.
精彩评论