简体   繁体   English

Web 套接字 + Tomcat/Glassfish + 集群 + 负载平衡 - 有哪些选项?

[英]Web Sockets + Tomcat/Glassfish + Cluster + Load Balancing - What are the options?

I'm working on a Java SE 7 / Java EE 6 application that may use either Tomcat 7 or Glassfish 3.1 (probably GlassFish, but this has not been decided yet).我正在开发一个 Java SE 7/Java EE 6 应用程序,它可以使用 Tomcat 7 或 Glassfish 3.1(可能是 GlassFish,但尚未决定)。 The application will take advantage of the new WebSockets technology that has recently achieved widespread adoption across all major browsers.该应用程序将利用新的 WebSockets 技术,该技术最近已在所有主要浏览器中得到广泛采用。

Through much research, forum reading and mailing list monitoring I have determined that (currently, AFAICT) neither mod_jk/isapi_redirect nor mod_proxy reliably (or at all) support WebSockets.通过大量研究、论坛阅读和邮件列表监控,我确定(目前,AFAICT)无论是 mod_jk/isapi_redirect 还是 mod_proxy 都不可靠(或根本)支持 WebSockets。 Since these are the two tried and tested methods for load balancing/directing traffic in a Tomcat or GlassFish cluster, this obviously represents a problem.由于这是在 Tomcat 或 GlassFish 集群中用于负载平衡/引导流量的两种久经考验的方法,这显然代表了一个问题。

On the other hand, however, Tomcat and GlassFish both have built-in web servers that are widely touted to be just as efficient at serving static content as Apache or IIS, and therefore it is generally not recommended to place Apache or IIS in front of one of these servers UNLESS you need redundancy/load balancing.然而,另一方面,Tomcat 和 GlassFish 都有内置的 Web 服务器,这些服务器被广泛吹捧为与 Apache 或 IIS 一样有效地提供静态内容,因此通常不建议将 Apache 或 IIS 放在前面这些服务器之一,除非您需要冗余/负载平衡。

So, all of this leads me to these questions:所以,所有这些都让我想到了这些问题:

  1. Is Apache or IIS even needed anymore to load balance in a Tomcat/GlassFish cluster?在 Tomcat/GlassFish 集群中是否还需要 Apache 或 IIS 来平衡负载? Wouldn't it be just as efficient (or more so?) to simply place a standard load balancer, like what you would use in any other scenario, in front of a cluster of Tomcat or GlassFish servers and forego the intermediary web server altogether?简单地将标准负载平衡器(就像您在任何其他场景中使用的那样)放置在 Tomcat 或 GlassFish 服务器集群前面并完全放弃中间 Web 服务器,难道不是同样有效(或更多?)? Or is there still some technical reason that standard load balancers won't work with TC/GF?或者标准负载平衡器不能与 TC/GF 一起工作是否还有一些技术原因? Assuming a standard load balancer could be used, one could simply find one that supports WebSockets (like Coyote) and use it.假设可以使用标准负载均衡器,您可以简单地找到一个支持 WebSockets 的负载均衡器(如 Coyote)并使用它。
  2. If a standard load balancer will simply not work with Tomcat/GlassFish, what other options are there?如果标准负载平衡器根本无法与 Tomcat/GlassFish 一起使用,还有哪些其他选择? How can one effect performant and reliable WebSocket technology using Java EE?如何使用 Java EE 实现高性能和可靠的 WebSocket 技术?

Caveat : I prefer not to consider load-balancing technologies that are limited to dumb round-robin protocols (such as Round-Robin DNS).警告:我不想考虑仅限于愚蠢循环协议(例如循环 DNS)的负载平衡技术。 I do not consider these options reliable/redundant, as one could easily be sent to a server that was down or already handling a much larger number of connections than another server in the cluster.我不认为这些选项可靠/冗余,因为它们很容易被发送到已关闭或已经处理的连接数比集群中的另一台服务器多得多的服务器。 Obviously I know that something like Round-Robin DNS could easily be used with WebSockets without any compatibility concerns.显然我知道像 Round-Robin DNS 这样的东西可以很容易地与 WebSockets 一起使用,而没有任何兼容性问题。

We were going to use an approach with having our Tomcat instances directly after a standard load balancer.我们将使用一种方法,在标准负载均衡器之后直接拥有我们的 Tomcat 实例。 We use SSL heavily in our setup.我们在设置中大量使用 SSL。 To keep things simple behind our load balancers and avoid different configurations for SSL/no SSL in our web container we wanted to terminate SSL in our load balancers.为了让我们的负载均衡器保持简单,并避免在我们的 Web 容器中使用不同的 SSL/无 SSL 配置,我们希望在我们的负载均衡器中终止 SSL。

However, the SSL decrypting hardware for our load balancers was quite buggy.然而,我们的负载平衡器的 SSL 解密硬件有很多问题。 Hence we ended up with web servers (nginx) between our web containers and our load balancers for the sole purpose of decrypting SSL.因此,我们最终在我们的 Web 容器和我们的负载平衡器之间使用了 Web 服务器(nginx),其唯一目的是解密 SSL。

This is a special case that applied to us but is worth keeping in mind.这是一个适用于我们的特殊情况,但值得牢记。 Apart from this I do not see a reason to keep a web server between your load balancer and your web container.除此之外,我认为没有理由在负载均衡器和 Web 容器之间保留 Web 服务器。 The load balancer should work just fine with the web container.负载均衡器应该可以很好地与 Web 容器配合使用。 Aim for simplicity and minimzing the different components in your setup.力求简单并尽量减少设置中的不同组件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM