J2EE Best Practices and Design Considerations

Similar documents
How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer

3-Tier Architecture. 3-Tier Architecture. Prepared By. Channu Kambalyal. Page 1 of 19

Evidence based performance tuning of

Winning the J2EE Performance Game Presented to: JAVA User Group-Minnesota

WebSphere Server Administration Course

IBM WebSphere Server Administration

Java EE 7: Back-End Server Application Development

Core J2EE Patterns, Frameworks and Micro Architectures

SOFT 437. Software Performance Analysis. Ch 5:Web Applications and Other Distributed Systems

Japan Communication India Skill Development Center

Course Description. Course Audience. Course Outline. Course Page - Page 1 of 5

An Oracle White Paper July Oracle Primavera Contract Management, Business Intelligence Publisher Edition-Sizing Guide

MID-TIER DEPLOYMENT KB

Insight into Performance Testing J2EE Applications Sep 2008

Distributed Database Design

Tuning Your GlassFish Performance Tips. Deep Singh Enterprise Java Performance Team Sun Microsystems, Inc.

Configuration Management of Massively Scalable Systems

Chapter 4. Architecture. Table of Contents. J2EE Technology Application Servers. Application Models

Oracle WebLogic Foundation of Oracle Fusion Middleware. Lawrence Manickam Toyork Systems Inc

JReport Server Deployment Scenarios

JBoss Seam Performance and Scalability on Dell PowerEdge 1855 Blade Servers

A Comparison of Software Architectures for E-Business Applications

Client/server is a network architecture that divides functions into client and server

Using Tomcat with CA Clarity PPM

Definition of SOA. Capgemini University Technology Services School Capgemini - All rights reserved November 2006 SOA for Software Architects/ 2

B M C S O F T W A R E, I N C. BASIC BEST PRACTICES. Ross Cochran Principal SW Consultant

Internet Engineering: Web Application Architecture. Ali Kamandi Sharif University of Technology Fall 2007

WEB, HYBRID, NATIVE EXPLAINED CRAIG ISAKSON. June 2013 MOBILE ENGINEERING LEAD / SOFTWARE ENGINEER

Enterprise Application Integration

Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat

Magento & Zend Benchmarks Version 1.2, 1.3 (with & without Flat Catalogs)

Java DB2 Developers Performance Best Practices

Holistic Performance Analysis of J2EE Applications

How To Develop A Web Service In A Microsoft J2Ee (Java) 2.5 (Oracle) 2-Year Old (Orcient) 2Dj (Oracles) 2E (Orca) 2Gj (J

Java-technology based projects

Java 2 Platform, Enterprise Edition (J2EE) Bruno Souza Java Technologist, Sun Microsystems, Inc.

<Insert Picture Here> Java Application Diagnostic Expert

27 th March 2015 Istanbul, Turkey. Performance Testing Best Practice

Monitoring HP OO 10. Overview. Available Tools. HP OO Community Guides

Contents Introduction... 5 Deployment Considerations... 9 Deployment Architectures... 11

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

CACHÉ: FLEXIBLE, HIGH-PERFORMANCE PERSISTENCE FOR JAVA APPLICATIONS

Understanding Application Servers

Managing Complexity in Mobile Application Deployment Using the OSGi Service Platform

Chapter -5 SCALABILITY AND AVAILABILITY

Performance Optimization Guide

Performance Optimization For Operational Risk Management Application On Azure Platform

Toad for Oracle 8.6 SQL Tuning

Java Monitoring. Stuff You Can Get For Free (And Stuff You Can t) Paul Jasek Sales Engineer


CHAPTER 1 - JAVA EE OVERVIEW FOR ADMINISTRATORS

Neelesh Kamkolkar, Product Manager. A Guide to Scaling Tableau Server for Self-Service Analytics

Cache Database: Introduction to a New Generation Database

Component Middleware. Sophie Chabridon. INT - INF Department - Distributed Systems team 2006

Using jvmstat and visualgc to Solve Memory Management Problems

Mobile Application Performance

Glassfish, JAVA EE, Servlets, JSP, EJB

The EMSX Platform. A Modular, Scalable, Efficient, Adaptable Platform to Manage Multi-technology Networks. A White Paper.

Partitioning and Clustering Demonstration

Java Performance. Adrian Dozsa TM-JUG

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

White Paper: 1) Architecture Objectives: The primary objective of this architecture is to meet the. 2) Architecture Explanation

Effective Java Programming. measurement as the basis

Performance Best Practices Guide for SAP NetWeaver Portal 7.3

Enterprise Applications

JAVA Technologies QUARTER 1 DESKTOP APPLICATIONS - ESSENTIALS QUARTER 2 NETWORKING AND OPERATING SYSTEMS ESSENTIALS. Module 1 - Office Applications

Architectural Overview

Outline: Operating Systems

Project SailFin: Building and Hosting Your Own Communication Server.

Building Web Applications, Servlets, JSP and JDBC

Distributed Objects and Components

PARALLELS CLOUD STORAGE

EJB & J2EE. Component Technology with thanks to Jim Dowling. Components. Problems with Previous Paradigms. What EJB Accomplishes

Evaluation Methodology of Converged Cloud Environments

SQL Server Business Intelligence on HP ProLiant DL785 Server

Oracle WebLogic Server 11g Administration

Performance Modeling for Web based J2EE and.net Applications

C/S Basic Concepts. The Gartner Model. Gartner Group Model. GM: distributed presentation. GM: distributed logic. GM: remote presentation

Enterprise Performance Tuning: Best Practices with SQL Server 2008 Analysis Services. By Ajay Goyal Consultant Scalability Experts, Inc.

New Methods for Performance Monitoring of J2EE Application Servers

Multi-Channel Clustered Web Application Servers

Contents. Client-server and multi-tier architectures. The Java 2 Enterprise Edition (J2EE) platform

Implementing the Shop with EJB

Tuning WebSphere Application Server ND 7.0. Royal Cyber Inc.

Chapter Outline. Chapter 2 Distributed Information Systems Architecture. Middleware for Heterogeneous and Distributed Information Systems

25 May Code 3C3 Peeling the Layers of the 'Performance Onion John Murphy, Andrew Lee and Liam Murphy

Japan Communication India Skill Development Center

Information Systems Analysis and Design CSC John Mylopoulos. Software Architectures Information Systems Analysis and Design CSC340

Unit 4 i5/os Work Management

V3 Storage Architecture Overview and Implications for VDI. May 2016

Net-WMS FP Net-WMS SPECIFIC TARGETED RESEARCH OR INNOVATION PROJECT. Networked Businesses. D.8.1 Networked architecture J2EE compliant

CONSUMER DEMAND MONITORING AND SALES FORECASTING (CDMFS) SYSTEM

WebSphere Architect (Performance and Monitoring) 2011 IBM Corporation

Agenda. Enterprise Application Performance Factors. Current form of Enterprise Applications. Factors to Application Performance.

Rational Application Developer Performance Tips Introduction

Cognos8 Deployment Best Practices for Performance/Scalability. Barnaby Cole Practice Lead, Technical Services

Part 3 - Performance: How to Fine-tune Your ODM Solution. An InformationWeek Webcast Sponsored by

CS Developing Web Applications with Java Technologies

QLIKVIEW ARCHITECTURE AND SYSTEM RESOURCE USAGE

Elements of Advanced Java Programming

Transcription:

J2EE Best Practices and Design Considerations J2EE Patterns information@middleware-company.com +1 (877) 866-JAVA Copyright 2002

A Brief Overview of Transactions Transactions guarantee determinism Transactions give you four virtues or ACID properties Atomicity Consistency Isolation Durability 2

Transaction Scope and Performance Balance is everything Narrower scopes Increase transaction traffic Decrease transaction latency Broader scopes Decrease transaction traffic Increase transaction latency 3

Likely Discoveries (Provided transactional scope does not extend to the client layer) Transactional traffic is much more costly than latency Transactional storms cause: Increased chance of rollbacks Increased chance of transaction interaction: Unexpected state Longer-lived transactions cause Isolation conflicts: Blocking and waiting More manageable and consistent operations Examples of longer-lived transactions include: Performing multiple updates within a single database transaction Using a session façade to demarcate transactions for entity beans 4

Take-away Points Abstract and cache your data to: Decrease client complexity Decrease network latency and traffic Be aware of how "up to date" you really need your data If an operation does not require pure data, give them latest If an operation does not require latest data, give them stale etc... Increase transactional scope to: Ensure data consistency Reduce traffic 5

Roadmap Where are we? Transactions J2EE Design Concerns EJB and Data Concerns General Design Choices and Strategies What We Can Control 6

A Graphical Look EJB Container Servlet, Applet, or Command- Line Client RMI Session Bean JDBC Entity Bean JDBC Database 7

Decision Points Use session beans with Java objects when Large volumes of data are retrieved in single SQL calls You are working with very small bits of data You have exclusive data (due to caching) You have programmers who are not familiar with OO data objects You have existing, (working) SQL code Use Entity Beans when You have shared data (due to caching) CMP is not prevented due to DB Optimizations You can take advantage of ejb20 relationship-management Data objects can be generated from UML diagrams through tools 8

When to Use Container-Managed Persistence Advantages of container-managed persistence Less code Faster to develop Advantages of bean-managed persistence More control (complex mappings) Can take advantage of existing tuned SQL (triggers) Less new learning (reuse and extend old JDBC code/components) CMP is a more realistic choice now because of: New EJB 2.0 relationship management New EJB 2.0 local interfaces 9

When to Use Stateful v. Stateless? Say we have a stateful business process (e.g. shopping cart) We can keep our state in one of three places In the client's memory In the server's memory On the database disk Thick Client (Applet/ Application) Thin Client (Browser) Server (JSP, Servlets, EJB) Database 10

Pros and Cons Database Pros: Database is a transactional/recoverable device Database Cons: Disk I/Os and network roundtrips are required Need to write code to marshal state in and out of component Client Pros: If client crashes we expect to lose state anyway. No disk I/Os Client Cons: Requires network overhead marshalling state back and forth The client API becomes more complex due to additional state parameters Need to write code to marshal state in and out of component Server Pros: No code to marshal state in and out of component No network roundtrips nor disk I/Os to marshal state No single point of failure if clustering/replication is used (judiciously) 11

XML As a Data Transfer Mechanism XML is useful when communicating between disparate systems XML transformation and parsing is slow Do not use XML for data transfer within a J2EE system The existing APIs work just fine Remember OO? J2EE applications are all Java Do transfer data between heterogeneous systems as XML when the benefits it offers can be realized 12

Roadmap Where are we? Transactions J2EE Design Concerns EJB and Data Concerns General Design Choices and Strategies What We Can Control 13

Dividing up your team 3 basic approaches Horizontal partitioning Developers specialize in APIs Examples: JSP team, an entity bean team, etc Vertical partitioning Developers focus on use cases and are generalists (use all APIs) Hybrid partitioning One subject matter expert per use case Developers specialize in APIs and move from use case to use case If goal is to get project success quickly and consistently, go for horizontal or hybrid If goal is to educate developers, go for vertical 14

Reality and Reuse Rocky history of reusing components within an organization Projects are too different, too much politics for reuse Rather than reuse, we recommend striving for Common vocabulary between projects Empowers communication Common design patterns Enables developers to easily transition between projects Common frameworks Pseudo-reuse via copy-pasting of code between projects Can achieve this via a "best practices task force" 15

Choosing an Application Server If you have no time, you could just go with market leader Warning: vendor may not handle your needs in optimal way Recommended process for selection of server List all features you want Weight and prioritize the feature list Eliminate vendors that don t meet majority of criteria Download application servers from 2-3 remaining vendors In a lab environment, measure features most important to you Scalability Usability Performance 16

Choosing an Application Server...continued Deploy vertical slice into those application servers You know how well the server handles your needs Entire process takes 2-4 weeks Can occur in parallel with development if you code portably Consultants can help you through this process 17

A Vertical Slice What is a vertical slice? One or two use-cases in your system Example: search engine, or product catalog but not complete site You build this slice, using all the relevant J2EE APIs: JSPs, servlets, EJBs, etc Benefits of implementing a vertical slice Gain experience with J2EE Reduce risk of 'unsound architecture' Prove project works to stakeholders show them working use-case Answers question: "Will it scale?" can performance tune slice early Helps you refine design patterns Not throwaway code: Slice is real piece of working system 18

When to Use 3-Tier v. 4-Tier Thick Client (Applet/ Application) Thin Client (Browser) 3 tier J2EE Server (JSP, Servlet, EJB) Database Thick Client (Application) Thin Client (Applet or Browser) Web Server (JSP, Servlet) 4 tier EJB Server (EJB) Database 19

When to Use 3-Tier v. 4-Tier...continued Load-balancing Required and only possible in 3 tier Efficiency No RPCs in 3-tier possibly no IPCs (inter-process calls) Adaptability 3-tier is more self-adapting than 4-tier Resources are used for whatever purpose is needed currently Either web server or application server Security Firewall may be deployed in-between boxes in 4-tier Fail-over 4-tier has no fail-over capability in this limited scenario 20

Increase Responsiveness When Programming EJBs Use Local Interfaces Use Session or Message-driven façade Cache Data Read-only Entity Beans Data Transfer Objects Cache JNDI Resources EJB Home Objects Data Sources JMS Connection Factories 21

Increase Responsiveness...continued Serialization Use the transient keyword for fields that you don t want serialized Use smaller transport objects to send the subset of info you need Reduce network traffic Make coarse-grained network calls ( chunk your remote requests) Always be aware of your remote boundaries Key to designing correctly: perceived performance Be smart about how you optimize E.g. don t optimize a Swing GUI if the app sits idle most of the time Don t put long-running tasks on the UI thread Put them on a new thread to give your GUIs snappier performance 22

Increase Responsiveness...continued Garbage collection Null out references that are no longer needed They are more likely to be GC ed Use lazy initialization, this is a powerful technique MySingleton singleton = null;... if (singleton == null) singleton = new MySingleton(); return singleton; 23

Increase Productivity Use/build frameworks What is a framework? Set of related classes which you specialize and/or instantiate to implement an application or subsystem Why are they useful? The framework is not just a collection of classes it also defines a generic design Bi-directional flow of control means the framework can contain much more functionality than a traditional library Obstacle: learning curve 24

Roadmap Where are we? The Good of the Many: Data Tiers and Transaction Concepts J2EE Design Concerns What We Can Control Handling Java Threads Memory Management Accurate Benchmarks 25

Handling Java Threads With EJB thread management is handled for us Vendors allow us to tune the # of threads in the App Server Too many threads cause increased competition for resources Too few threads cause under-utilization of CPU We can choose to deploy to multiple instances Each VM has its own thread pool limit Each tier has its own thread behavior Web-tier uses greater number of threads of a shorter duration EJB-tier uses fewer threads of a greater duration Deploying to multiple CPUs decreases CPU exhaustion 26

Memory Management More is Better Do not starve your OS If you have 2GB ram available save 256mb for the OS Use Xms<x-Amount>m -Xmx<x-Amount>m arguments to VM Ensure the minimum and maximum are identical You are certain to get what you need at startup You can easily partition your ram among multiple instances Remember: Actual RAM use can be twice that declared 27

Obtaining Accurate Benchmarks System-centric System.currentTimeMillis() Invasive, inaccurate by as much as tens of milliseconds May be all you have CPU utilization Memory use Test... Test... Test... Every application is different Fix what you can it s the least you can do Use StringBuffers in place of Strings if doing much concatenation Reuse objects where possible since object creation is costly Development-time performance measurement Sitraka PerformaSure Borland OptimizeIt 28

Obtaining Accurate Benchmarks...continued User-centric What really counts Difficult to determine Network issues User error/unexpected behavior Real-world load Requires the right tools Deployed/Live performance measurement and advice Precise Indepth for J2EE 29

Summary In this presentation we discussed: The Good of the Many: Transactions J2EE Design Concerns When to Use Messaging EJB and Data Concerns General Design Choices and Strategies What We Can Control Handling Java Threads Memory Management Accurate Benchmarks 30