集群 Apache Tomcat6
我有一个使用 Tomcat6+Struts+Hibernate+MySql 的 Java 企业 Web 应用程序。目前它是公开启动并在单个服务器上运行的。为了解决性能问题,我们应该将应用程序移至集群环境。无论如何,我想使用 Tomcat6 集群,如下所示:
- 一台负载平衡机器,包括一个 Web 服务器(Apache+mod_proxy)作为前端
- 一些应用程序服务器机器,每台运行一个 tomcat6 实例
- 一个会话管理后端 最后是
- 一个数据库服务器,
例如this
负载均衡器机器接收所有请求,并根据均衡算法将它们重定向到相应的 tomacat6 机器。完成业务部分后,响应返回到网络服务器,最后返回给用户。在这种情况下,前端机器处理所有请求和响应,因此它将成为应用程序中的瓶颈点。
在Apache Tomcat集群中,有没有办法实现负载均衡机制和Web服务器?我的意思是在前端放置一个负载均衡器,并将请求/响应处理部分留给多个 Web 服务器。
I've got a Java Enterprise Web Application which uses Tomcat6+Struts+Hibernate+MySql. at the time being it's publicly up and running on a single server. In order to performance issues we should move the application to a clustered environment. Anyhow I wanna use Tomcat6 clustering as below:
- A Load Balancing machine including a web server (Apache+mod_proxy) as front-end
- Some application server machines, each one running a tomcat6 instance
- A session management back-end
- And finally a db server
something like this
The load balancer machine receives all the requests and depending on the balancing algorithm redirects them to the respective tomacat6 machine. After doing the business part, the response is returned to the webserver and at the end to the user. In this scenario the front-end machine processes all the requests and responses so it'd be a bottleneck point in the application.
In Apache Tomcat clustering, is there a way to load balancing mechanism and web servers? I mean putting a load balancer in the front end and leave the request/response processing part to multiple web servers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Tomcat 不支持内置集群。所发生的情况是负载均衡器分发请求,因此各个 Tomcat 实例不需要知道发生了什么。
您所要做的就是确保您的应用程序可以处理它。例如,您必须意识到缓存可能已过时。
假设实例 1 的缓存中有对象 X,并且 X 被实例 2 上处理的请求修改。实例 2 中的缓存将是正确的,实例 1 中的缓存现在将过时。
解决方案是使用支持集群的缓存或对可修改的实例禁用缓存。但这对 Tomcat 来说并不重要。
Tomcat has no support for clustering built in. What happens is that the load balancer distributes requests, so the various Tomcat instances don't need to know what is happening.
What you have to do is to make sure your application can handle it. For example, you must be aware that caches can be stale.
Say instance 1 has object X in it's cache and X is modified by a request processed on instance 2. The cache in instance 2 will be correct, the cache from instance 1 will be stale now.
The solution is to use a cache which supports clustering or disable caching for instances which can be modified. But that doesn't matter to Tomcat.