Architecture Problem

Out of these two architectures which one is more performance oriented and why ?

1. Requests will be first gone to FrontController Servlet where authorization and authentication is done and then request is passed to one another SERVLET which will do business validations by calling EJB and forward the results to final jsp page. Servlet name is taken out from XML file based upon the URL type

2. Requests wiil be first gone to FrontController Servlet where authorization and authentication is done and then request is passed to one another CLASS which will dobusiness validations by calling EJBs and forwarding the results to jsp(View) . This class is initialized with Servletconfig and HttpRequest request through reflection (Command Pattern). Class name is decided from XML based upon the URL type.

[826 byte] By [mohit_rathi] at [2007-9-26 21:38:55]
# 1
well, mohit that entirely depends upon ur requirement.
neetukumar at 2007-7-3 21:54:41 > top of Java-index,Other Topics,Patterns & OO Design...
# 2

I can see no difference between those two approaches in a non-distributed servlet environment.

If you have a distributed servlet environment, forwarding to another servlet is definitely better, as you can distribute the servlets that do the processing (and hence automatically benefit from the servlet engine's load balancing support).

ferhat.savci at 2007-7-3 21:54:41 > top of Java-index,Other Topics,Patterns & OO Design...
# 3
1. would be slower, as the second servlet wouldbe launching threads for each invocation (under lots of simultaneous request).
subir at 2007-7-3 21:54:41 > top of Java-index,Other Topics,Patterns & OO Design...
# 4

> Out of these two architectures which one is more

> performance oriented and why ?

Like most performance questions there is no right/wrong answers.As the other have alluded it all depends on the cicumstances. In practice there is little to choose between these two architectures, subtle implementation differences will more likely have a more significant effect. e.g. loading the XML at start-up vs loading at each request. How the XML configuration is shared.

> 1. Requests will be first gone to FrontController

> Servlet where authorization and authentication is done

> and then request is passed to one another SERVLET

> which will do business validations by calling EJB and

> forward the results to final jsp page. Servlet name is

> taken out from XML file based upon the URL type

Done properly, this would probably offer better scalability and fail-over performance and consequently better average performance over a range of loads. The additional network overhead would make it lower performance on lightly loaded systems.

> 2. Requests wiil be first gone to FrontController

> Servlet where authorization and authentication is done

> and then request is passed to one another CLASS which

> will dobusiness validations by calling EJBs and

> forwarding the results to jsp(View) . This class is

> initialized with Servletconfig and HttpRequest

> request through reflection (Command Pattern). Class

> name is decided from XML based upon the URL type.

This would offer better performance on smaller scale softly clustered systems. It would require some form of sticky load balancing to work larger scaled systems. It would probably deteriorate more quickly at high loading, because the granularity of resource requirements per request is larger.

MartinS. at 2007-7-3 21:54:41 > top of Java-index,Other Topics,Patterns & OO Design...