开发者

How to distribute a j2ee application on multiple servers?

I'm using JSP+Struts2+Tomcat6+Hibernate+MySQL as my J2EE developing environment. Due to the pr开发者_StackOverflow社区oject'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?


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.


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.


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.

interface User
{
  void setAddress(String name,
                  String street,
                  String zip,
                  String city,
                  String country);
}

instead of

interface User
{
  void setName(String name);
  void setStreet(String street);
  void setZip(String zip);
  void setCity(String city);
  void setCountry(String country);
}

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜