Session Facades Reduce Remote Calls Transfer Objects Reduce Remote Calls Distributed Transactions Increase Remote Calls

11 Clustering Best Practices 11-1 11 Clustering Best Practices The following topics recommend design and deployment practices that maximize the scalability, reliability, and performance of applications hosted by a WebLogic Server cluster: ■ Section 11.1, General Design Considerations ■ Section 11.2, Web Application Design Considerations ■ Section 11.3, EJB Design Considerations ■ Section 11.4, State Management in a Cluster ■ Section 11.5, Application Deployment Considerations ■ Section 11.6, Architecture Considerations ■ Section 11.7, Avoiding Problems

11.1 General Design Considerations

The following sections describe general design guidelines for clustered applications.

11.1.1 Strive for Simplicity

Distributed systems are complicated by nature. For a variety of reasons, make simplicity a primary design goal. Minimize moving parts and do not distribute algorithms across multiple objects.

11.1.2 Minimize Remote Calls

You improve performance and reduce the effects of failures by minimizing remote calls.

11.1.2.1 Session Facades Reduce Remote Calls

Avoid accessing EJB entity beans from client or servlet code. Instead, use a session bean, referred to as a facade, to contain complex interactions and reduce calls from Web applications to RMI objects. When a client application accesses an entity bean directly, each getter method is a remote call. A session facade bean can access the entity bean locally, collect the data in a structure, and return it by value.

11.1.2.2 Transfer Objects Reduce Remote Calls

EJBs consume significant system resources and network bandwidth to execute—they are unlikely to be the appropriate implementation for every object in an application. 11-2 Using Clusters for Oracle WebLogic Server Use EJBs to model logical groupings of an information and associated business logic. For example, use an EJB to model a logical subset of the line items on an invoice—for instance, items to which discounts, rebates, taxes, or other adjustments apply. In contrast, an individual line item in an invoice is fine-grained—implementing it as an EJB wastes network resources. Implement objects that simply represents a set of data fields, which require only get and set functionality, as transfer objects. Transfer objects sometimes referred to as value objects or helper classes are good for modeling entities that contain a group of attributes that are always accessed together. A transfer object is a serializable class within an EJB that groups related attributes, forming a composite value. This class is used as the return type of a remote business method. Clients receive instances of this class by calling coarse-grained business methods, and then locally access the fine-grained values within the transfer object. Fetching multiple values in one server round-trip decreases network traffic and minimizes latency and server resource usage.

11.1.2.3 Distributed Transactions Increase Remote Calls

Avoid transactions that span multiple server instances. Distributed transactions issue remote calls and consume network bandwidth and overhead for resource coordination.

11.2 Web Application Design Considerations