java 为什么我们在同一台服务器上使用多个应用服务器实例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4569159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 07:00:42  来源:igfitidea点击:

Why do we use multi application server instances on the same server

javatomcatjakarta-eejbossglassfish

提问by Sebastien Lorber

I guess there is a good reason, but I don't understand why sometimes we put for example 5 instances having the same webapplications on the same physical server.

我想有一个很好的理由,但我不明白为什么有时我们会在同一台物理服务器上放置例如 5 个具有相同 Web 应用程序的实例。

Has it something to do with an optimisation for a multi processor architecture? The max allowed ram limit for JVM or something else?

它与多处理器架构的优化有关吗?JVM 或其他东西的最大允许 ram 限制?

回答by Favonius

Hmmm... After a long time I am seeing this question again :)

嗯......过了很长时间我再次看到这个问题:)

Well a multiple JVM instances on a single machine solves a lot of issues. First of let us face this: Although JDK 1.7 is coming into picture, a lot of legacy application were developed using JDK 1.3 or 1.4 or 1.5. And still a major chunk of JDK is divided among them.

一台机器上的多个 JVM 实例解决了很多问题。首先让我们面对这一点:尽管 JDK 1.7 即将出现,但许多遗留应用程序是使用 JDK 1.3 或 1.4 或 1.5 开发的。JDK 的主要部分仍然在它们之间分配。

Now to your question:

现在回答你的问题:

Historically, there are three primary issues that system architects have addressed by deploying multiple JVMs on a single box:

从历史上看,系统架构师通过在单个机器上部署多个 JVM 来解决三个主要问题:

  1. Garbage collection inefficiencies:As heap sizes grow, garbage collection cycles--especially for major collections--tended to introduce significant delays into processing, thanks to the single-threaded GC. Multiple JVMs combat this by allowing smaller heap sizes in general and enabling some measure of concurrency during GC cycles (e.g., with four nodes, when one goes into GC, you still have three others actively processing).

  2. Resource utilization:Older JVMs were unable to scale efficiently past four CPUs or so. The answer? Run a separate JVM for every 2 CPUs in the box (mileage may vary depending on the application, of course).

  3. 64-bit issues:Older JVMs were unable to allocate heap sizes beyond the 32-bit maximum. Again, multiple JVMs allow you to maximize your resource utilization.

  4. Availability:One final reason that people sometimes run multiple JVMs on a single box is for availability. While it's true that this practice doesn't address hardware failures, it does address a failure in a single instance of an application server.

  1. Garbage collection inefficiencies:随着堆大小的增长,由于单线程 GC,垃圾收集周期——尤其是主要收集——往往会给处理带来显着的延迟。多个 JVM 通常通过允许较小的堆大小并在 GC 周期期间启用某种并发度量来解决这个问题(例如,对于四个节点,当一个节点进入 GC 时,您仍然有其他三个节点在积极处理)。

  2. Resource utilization:较旧的 JVM 无法有效地扩展到四个左右的 CPU。答案?为盒子中的每 2 个 CPU 运行一个单独的 JVM(当然,里程可能因应用程序而异)。

  3. 64-bit issues:较旧的 JVM 无法分配超过 32 位最大值的堆大小。同样,多个 JVM 允许您最大限度地利用资源。

  4. Availability:人们有时在一个机器上运行多个 JVM 的最后一个原因是为了可用性。虽然这种做法确实没有解决硬件故障,但它确实解决了应用服务器的单个实例中的故障。

Taken from ( http://www.theserverside.com/discussions/thread.tss?thread_id=20044)

取自 ( http://www.theserverside.com/discussions/thread.tss?thread_id=20044)

I have mostly seen weblogic. Here is a link for further reading:

我主要看到了weblogic。这是进一步阅读的链接:

http://download.oracle.com/docs/cd/E13222_01/wls/docs92/perform/WLSTuning.html#wp1104298

http://download.oracle.com/docs/cd/E13222_01/wls/docs92/perform/WLSTuning.html#wp1104298

Hope this will help you.

希望这会帮助你。

回答by Sanjay T. Sharma

I guess you are referring to application clustering.

我猜你指的是应用程序集群。

AFAIK, JVM's spawned with really large heap size have issues when it comes to garbage collection though I'm sure by playing around with the GC algorithm and parametersyou can bring down the damage to a minimum. Plus, clustered applications don't have a single point of failure. If one node goes down, the remaining nodes can keep servicing the clients. This is one of the reasons why "message based architectures" are a good fit for scalability. Each request is mapped to a message which can then be picked up by any node in a cluster.

AFAIK,JVM 产生的非常大的堆大小在垃圾收集方面存在问题,尽管我确信通过使用 GC 算法和参数可以将损害降至最低。此外,集群应用程序没有单点故障。如果一个节点出现故障,其余节点可以继续为客户端提供服务。这是“基于消息的架构”非常适合可扩展性的原因之一。每个请求都映射到一条消息,然后可以由集群中的任何节点获取。

Another point would be to service multiple requests simultaneously in case your application unfortunately uses synchronized keyword judiciously. We currently have a legacy application which has a lot of shared state (unfortunately) and hence concurrent request handling is done by spawning around 20 JVM processes with a central dispatching unit which does all the dispatching work. ;-)

另一点是同时为多个请求提供服务,以防您的应用程序不幸明智地使用了 synchronized 关键字。我们目前有一个遗留应用程序,它有很多共享状态(不幸的是),因此并发请求处理是通过产生大约 20 个 JVM 进程来完成的,中央调度单元完成所有的调度工作。;-)

回答by Peter Lawrey

I would suggest you use around least JVM per NUMA region. If a single JVM uses more than one NUMA region (often a single CPU) the performance can degrade significantly, due to a significant increase in the cost of accessing main memory of another CPU.

我建议您在每个 NUMA 区域使用最少的 JVM。如果单个 JVM 使用多个 NUMA 区域(通常是单个 CPU),由于访问另一个 CPU 的主内存的成本显着增加,性能可能会显着降低。

Additionally using multiple servers can allow you to

此外,使用多个服务器可以让您

  • use different versions of java or your your applications server.
  • isolate different applications which could interfere (they shouldn't but they might)
  • limit GC pause times between services.
  • 使用不同版本的 java 或您的应用程序服务器。
  • 隔离可能干扰的不同应用程序(他们不应该,但他们可能)
  • 限制服务之间的 GC 暂停时间。

EDIT: It could be historical. There may have been any number of reasons to have separate JVMs in the past but since you don't know what they were, you don't know if they still apply and it may be simpler to leave things as they are.

编辑:这可能是历史性的。过去可能有很多原因需要单独的 JVM,但由于您不知道它们是什么,您不知道它们是否仍然适用,保持原样可能更简单。

回答by Gareth Davis

An additional reason to use mutliple instance is serviceability.

使用多个实例的另一个原因是可维护性。

For example if you multiple different applications for multiple customers then having seperate instances of the appserver for each application can make life a little easier when you have to do an appserver restart during a release.

例如,如果您为多个客户提供多个不同的应用程序,那么当您必须在发布期间重新启动应用程序服务器时,为每个应用程序拥有单独的应用程序服务器实例可以使生活更轻松。

回答by rai.skumar

Suppose you have a average configuration host and installed single instance of the web/app server. Now your application becomes more popular and number of hits increases 2 fold. What you do now ?

假设您有一个普通的配置主机并安装了 web/app 服务器的单个实例。现在您的应用程序变得更受欢迎,点击次数增加了 2 倍。你现在做什么?

Add one more physical server of same configuration and instal the application and load balance these two hosts.

再添加一台相同配置的物理服务器并安装应用程序并平衡这两个主机的负载。

This is not end of life for your application. Your application will keep on becoming more popular and hence the need to scale it up. What's going to be your strategy ?

这不是您的应用程序的生命周期结束。您的应用程序将继续变得越来越流行,因此需要对其进行扩展。你的策略是什么?

  • keep adding more hosts of same configuration
  • buy a more powerful machine where you can create more logical application servers
  • 不断添加更多相同配置的主机
  • 购买更强大的机器,您可以在其中创建更多逻辑应用程序服务器

Which option will you go far ?

哪个选项你会走多远?

You will do cost analysis, which will involve factors like- actual hardware cost, Cost of managing these servers (power cost, space occupied in data center) etc.

您将进行成本分析,这将涉及诸如实际硬件成本、管理这些服务器的成本(电力成本、数据中心占用的空间)等因素。

Apparently, it comes that the decision is not very easy. And in most cases it's more cost effective to have a more powerful machine.

显然,这个决定并不是很容易。在大多数情况下,拥有更强大的机器更具成本效益。