如何将j2ee应用程序分布在多台服务器上?
我使用JSP+Struts2+Tomcat6+Hibernate+MySQL作为我的J2EE开发环境。由于该项目规模较大且即将出现性能问题,因此决定将该项目部署在多台服务器上。 由于该项目是在三层架构中开发的,我们希望为每一层分配一台单独的机器,并通过千兆以太网连接将它们连接起来。所以我们需要一个数据库服务器(MySQL)、一个逻辑服务器(Struts2+POJOs)和一个Web服务器。
我想数据库服务器和逻辑服务器之间的通信不会有问题,但连接网络服务器和逻辑服务器对我来说似乎有点令人困惑。考虑到接下来的阶段我们可能会增加每一层的服务器数量,在这种情况下我的选择是什么?
任何想法将不胜感激!
[编辑]
Tomcat 是逻辑服务器的一部分,它位于 POJO 和 struts 所在的位置,我所说的 Web 服务器是一个前端服务器,它接受用户的请求并将它们分派到逻辑服务器。 另一方面,我们可能想使用多个逻辑服务器。有可能吗?
顺便问一下,JMS 在这里有什么帮助吗?
I'm using JSP+Struts2+Tomcat6+Hibernate+MySQL as my J2EE developing environment. Due to the project's large scale and upcoming performance issues, it's been decided to deploy the project on multiple servers.
Since the project has been developed in 3-tier architecture, we wanna dedicate a separated machines to each tier and connect them via GigaBit Ethenrnet connections. So we're gonna need a DB-Server(MySQL), a Logic-Server(Struts2+POJOs) and a Web-Server.
I suppose the communication between DB-Server and Logic-Server wouldn't be a problem but connecting the web-server and the Logic-Server seems kinda baffling to me. Considering the fact that we might increase the number of server machines of each tier in the next phases, what are my options in this situation?
Any ideas would be highly appreciated!
[EDIT]
Tomcat is a part of the Logic-Server and it lies where POJOs and struts go, What I mean by web-server is a front end server which takes users' requests and dispatches them to the Logic-Server.
On the other hand we might wanna use more than one Logic-Server. Is it even possible?
By the way, would JMS be any help here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
逻辑也需要在 Tomcat 服务器上进行。没有 Web 服务器的 Struts 毫无意义。
或者您的意思是“Web 服务器”,如“理解 HTTP 的哑文件服务器”?在这种情况下,您根本不需要连接它们; Web 浏览器将为您执行此操作:JSP/Servlet 代码会将图像和其他静态内容的 URL 发送到浏览器,浏览器将使用这些 URL 直接从“Web 服务器”下载数据。
您绝对不希望“逻辑服务器”下载这些内容并提供服务。
The logic needs to go on the Tomcat server as well. Struts without a web server makes no sense.
Or did you mean "Web server" as in "dumb file server that understands HTTP"? In that case, you don't connect them at all; the web browser will do that for you: The JSP/Servlet code will send URLs for the images and other static content to the browser and the browser will use those URLs to download the data directly from the "web server".
You definitely don't want the "Logic server" download the stuff and serve it as well.
您甚至可以将 Struts 应用程序拆分为“逻辑服务器”和 Web 服务器吗?
Tomcat 是一个应用程序服务器,因为它可以运行您的逻辑并为您的页面提供服务。
如果您确实想将逻辑运行负载分布到另一台服务器上,请尝试实现面向服务的体系结构。
我的经验仅限于使用:JSF 用于前端和一些数据操作(用于演示),IBM Websphere 用于逻辑(流程是在 Websphere Integration Developer 中设计的,而不是纯 Java),Oracle 用于数据库。所有这些服务器都托管在单独的计算机上。
在您的情况下,您可以使用 Java Web 应用程序来执行逻辑,并且它可以在另一个 Tomcat 服务器上运行(与前端应用程序的服务器分开)。在这种情况下,您将把您的函数公开为 Web 服务,并让前端应用程序调用它们。
Can you even split up a Struts application into a "Logic Server" and a Web Server?
Tomcat is an application server, because it can run your logic and serve your pages.
If you really want to distribute your logic-running load onto another server, try implementing a Service Oriented Architecture.
My experience is limited to using: JSF for front end and some date manipulation (for presentation), IBM Websphere for the logic (the processes are designed in Websphere Integration Developer, not pure Java), and Oracle for the DB. All of these servers are hosted on separate machines.
In your case, you can use a Java web-application to execute your logic, and it can run on another Tomcat server (separate from your front-end application's server). In this case, you will expose your functions as webservices and let the front-end application invoke them.
根据层分发应用程序不一定是一个好主意。与单个 JVM 内的通信相比,网络通信速度较慢。因此,您希望尽量减少不同机器之间的通信。这通常是通过提供粗粒度的接口来实现的,例如,
而不是。
合理的是,如果您更改
User
对象中的一条信息,其他部分也可能会更改。粗粒度接口可确保网络上的方法调用更少。Distributing the application according to the tiers is not necessarily a good idea. Network communication is slow compared to communication within a single JVM. For this reason, you want to minimize the communication between the separate machines. This is usually achieved by providing a coarse grained interfaces, e.g.
instead of
The rational is, that if you change one piece of information in a
User
object, other pieces are likely to be changed as well. The coarse grained interface then ensures fewer method invocations over the network.