|
|
||
Carol McDonald's BlogCommunity: Java Web Services and XML ArchivesSome J2EE Performance TipsPosted by caroljmcdonald on March 09, 2004 at 10:00 AM | Permalink | Comments (2)You need to plan for performance and scalability through out your application development process from architecture to implementation to testing. Like security this is not something that can easily be stuck on at the last minute. During design, coding and testing you need to pay attention to resource consumption:
The following J2EE design patterns can improve performance:
For more on J2EE Patterns see Core J2EE Patterns and J2EE Blueprints Servlet tips: Don't store a lot of data in the HTTP Session because memory consumption affects performance and scalability. Remove servlet sessions when they are no longer needed: call session.invalidate() Session EJB tips: Again because memory consumption affects performance and scalability remove stateful session beans when they are no longer needed (for example when a user logs out) by calling Bean.remove(). Limit the size of objects stored in session beans due to memory cost and performance cost for I/O activation and passivation. For high scalability try to use Stateless session EJBs. You can sometimes convert Stateful EJBs to Stateless by adding parameters containing state information to the Stateless bean methods. Entity Container Managed Persistence: Use CMP Entity Beans for Object oriented transactional persistence. Tuned CMP entity beans can usually offer better performance then BMP entity beans (for large queries, tabular type access for browsing data use the DAO pattern) With EJB 2.0 CMP optimization is possible because persistent fields are only accessible via get and set methods. Containers can optimize based on whether or not a field has been modified, the entity is in a transaction, relation, cache.. CMP optimizations include:
For more information on CMP performance see: Why choose CMP? Consistency Levels in CMP: Consistency levels are tunable in the EJB container, which can improve performance depending on the application. There are two general approaches to ensure consistency. The first is pessimistic locking, which serializes access to an Entity EJB during a transaction and may lead to decreased concurrency. The second approach is optimistic locking, and may result in a larger number of database round trips since it requires a caller to re-try if a consistency check fails at store. Optimistic locking gives better performance when entity contention is not high. Database Isolation Modes a lower database transaction isolation levels reduces work in the database tier, and can lead to better application performance. Choose the lowest cost database transaction isolation level that avoids corrupting the application data. Use a READ_COMMITTED isolation level with optimistic locking if there is a low likelihood of concurrent transactions updating the same rows. Updates will only fail if there has been a collision.
Getting the most out of your Application Server: Tuning the caching and pooling of EJBs and JDBC can have a significant affect on performance. Stateless Session beans, Message Driven Beans and Entity beans are pooled to improve server performance. Pooled EJB instances are all equivalent and indistinguishable from other pooled instances of the same class type. Pooling beans reduces the overhead associated with creating and initializing bean instances. You want to monitor and tune the pool to avoid excessive creation or deletion of instances, but also avoid accumulating unused instances. Increase the bean’s pool size when observing excessive creation and deletion of bean instances. Decrease the bean’s pool size when accumulating a large number of instances in the pool, as this will cause more frequent and longer full Garbage Collection cycles. For example the Sun Java Application Server has the following EJB Container PoolTunables:
These can be set per bean type and/or as global defaults. Stateful Session beans and Entity beans are cached to improve performance. Cached Stateful Session EJBs are associated with a specific user's conversational state. Cached Entity EJBs are associated with a specific primary key. Caching beans gives better performance by reducing activations and passivations, especially since the data associated with an instance must be re-loaded for activation. You want to monitor and tune the cache to minimize the number of activations and passivations, but avoid the accumulation of unused instances in the cache. For Entity beans increase the cache size for beans with concurrent or iterative access patterns. For Stateful session beans set the cache size to the maximum estimated ~ number of concurrent users. In general Increase the cache until a good cache hit rate is reached. Entity Bean Commit options and the cache.
Comit option B performs the best if the Entity bean will be accessed again. If the Entity bean is rarely reused then commit option C is better. Do profiling with your application on your application server to determine what works best. For example the Sun Java Application Server has the following EJB Container Cache Tunables:
These can be set per bean type and/or as global defaults. For more on tuning the EJB pool and cache see: JDBC tips:
For example with the Sun Java Application Server you can tune JDBC
statement caching as follows: For more information on JDBC performance see JMS tips:
XML and
Messaging:
references and more J2EE performance information: Orchestration, Choreography, Collaboration and Java Technology-based Business IntegrationPosted by caroljmcdonald on October 30, 2003 at 08:20 PM | Permalink | Comments (0)some of the latest Web Services "specs" are about Orchestration, Choreography, Collaboration ... Here I am going to give a brief synopsis and pointers for more information on this topic.
Orchestration, Choreography, Collaboration are about composing web services into Business processes,
what does this mean? Orchestration defines the control and data flow between web services to achieve a business process. Orchestration defines an "executable process" or the rules for a business process flow defined in an xml document which can be given to a business process engine to "orchestrate" the process, from the viewpoint of one participant. Choreography defines the sequence and dependencies of interactions between multiple roles to implement a business Process composing multiple web services. Choreography describes the sequence of interactions for Web service messages-it defines the conditions under which a particular web service operation can be invoked. WSDL describes the static interface and Choreography defines the Dynamic behavior external interface from a global view. BPEL4WS primarily focuses on orchestration, while WSCI focuses on choreography. With WSCI each participant in the message exchange defines a WSCI interface. With BPEL4WS you describe an executable process from the perspective of one of the participants. 2 groups have formed to work on Orchestration and Choreography. The OASIS Web BPEL TC was created in April 2003. It has 100+ members representing 50+organizations includes IBM, Microsoft, BEA, Oracle, Sun, SAP The TC is chartered to: Continue work on BPEL4WS: as basis for web services orchestration by creating the needed specifications to formally describe interoperable business processes and business interaction protocols http://www.oasis-open.org/committees/wsbpel The W3C WS Choreography WG was created in Jan. 2003 It has 40+ members representing 25+ organizations including Intalio, BEA, Oracle, Sun, SAP The working group is chartered to : create the definition of a language(s) for describing a choreography, as well as the rules for composition of, and interaction among, such choreographed Web services. WSCI will be considered as Input but will not necessarily be the output of this group. http://www.w3.org/2002/ws/chor/ There is overlap in membership between WS-BPEL and WS-Choreography and these 2 groups are trying to coordinate their work. WS-BPEL is focusing more on the executable business processes, while WS-Choreography is concerned more with the public message exchange among Web services. Process Definition for Java (PD4J or JSR-207) builds on Java Language Metadata technology (JSR-175) to provide an easy to use syntax for describing a business process at the source code level for the J2EE platform http://jcp.org/en/jsr/detail?id=207 Java Business Integration (JBI) JSR-208 enables the creation of a Java business integration environment for specifications such as BPEL4WS and the WS-Choreography. JBI formalizes the contract between BPMs and a normalized message bus. Business Process Machines support Business Process Instances and manage their lifecycle. BPMs will work at the normalized message level in order to align with the JBI environment. http://jcp.org/en/jsr/detail?id=208 EbXML: Business Process Specification Schema BPSS defines the collaborative process in terms of: a Sequence of Business Transactions (Message exchanges) between partners. http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=ebxml-bp For more information: http://developer.java.sun.com/developer/onlineTraining/webcasts/35plus/cmcdonald2/cmcdonald2.html http://www.ebpml.org http://searchwebservices.techtarget.com/originalContent/0,289142,sid26_gci880731,00.html http://sunnetwork.sun.com/sf2003/conf/sessions/display-1470.en.jsp | ||
|
|