enterprise javabeans™ (ejb™) architecture scalability/load test
DESCRIPTION
TRANSCRIPT
BOF-1303, EJB™ Scalability/Load Test1
Enterprise JavaBeans™ (EJB™) Architecture Scalability/Load Test
Ted [email protected] Software, Inc.www.rswsoftware.com
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/2
Agenda
• The Current Landscape: Performance Testing & EJBs
• Example Case Study using EJB-test• Survey EJB Performance Test
Strategies & Techniques
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/3
Performance Testing & EJBs
Presentation tier Data tierMiddle tier
: web client
: webclient
: client
: EJB server
: webclient
: EJB
: web server
: EJB
:Internet
: database server
: client
: client
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/4
Our "OrderEntry" Example
WebLogic 5.1.0 : EJB server
Cloudscape : database
server
orderentry.jar: Session EJB
product.jar: Entity EJB
vendor.jar: Entity EJB
customer.jar: Entity EJB
<<requests>>
<<responses>>
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/5
EJB-test
Strategy:1. Create Java driver "client" for EJB under test
• Goal: time method requests on EJB's interface (business methods)
• Automate code generation through Java Reflection API & EJB code patterns
2. Simulate load using that client• Run the client in multithreaded load generator• Map in data from tables (or use generated data)
3. Aggregate log data• Response times• Exceptions• Data: actual vs. expected
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/6
Select the EJB to be tested from the
Jars in your classpath
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/7
EJB-test automatically
generates a Java Test Client specific to the
selected EJB and optimized for WebLogic or WebSphere
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/8
The automatically generated Java Test
Client times the method calls to the
selected EJB
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/9
Define the load to execute and run the
test.
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/10
Select the results to view
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/11
Select the response time data to view
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/12
Compare 2 test executions
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/13
OEVendor vs. OELoad
• A simple response time comparison reveals which bean is the bottleneck
• Potential sources of bottleneck:– Design– Deployment– Environment
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/14
Comparing EJB Deployments
OEProduct
ejb-jar.xml:37 <trans-attribute>Supports
OEVendor
ejb-jar.xml:37 <trans-attribute>Required
weblogic-cmp-rdbms-jar.xml:29 <transaction-isolation>TRANSACTION_SERIALIZABLE
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/15
Strategies & Techniques
• Load Testing• Data-driven Load Testing• Multithreaded & Multi-JVM Loads• Distributed Load Testing• Scenario (Multi-bean) Testing• Other Interesting EJB Tests
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/16
EJB Load Testing
• Objective – Measure EJB's ability to server increasing
number of client requests– Most Common Metrics
• Transactions per Second (TPS)—throughput• Response time—client-side
– Other Interesting Metrics• Error rate (exceptions)• Correctness (expected vs. actual values)• Method-level response times
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/17
Data-driven EJB Load Testing
• Objective – Test EJBs with realistic data sets
• Approach– Particular data combinations often comprise a
"use-case"– Data set triggers business rules or call graphs
of interest– Automation Leverage: Data from CSV "maps"
into a static client driver• Hurdles
– Marrying clients to data sets
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/18
EJB Load Testing System Topology
: client host
B : test client
Data tierMiddle tier
: EJB server
A : EJB
: database server
Test client threads each
time their calls to the EJB's
methods
B : client thread
B : EJB
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/19
Multithreaded & Multi-JVM Load Generation
• Objective– Better simulation of load
• Approach– Multithreaded load generation simulates a
multi-client load (concurrent requests)– Dividing load across JVMs creates multiple
socket connections to server
• Hurdles– Thread safety & execution coordination
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/20
Distributed Load Testing
• Objective– Generate a load simulation that is large
enough• Approach
– Distribute client JVMs across multiple machines
• Hurdles– Still have thread safety and client coordination– Aggregating result logs– Client execution environment
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/21
Distributed Load Testing Nirvana
: EJB-test server
EJB Servers
: EJB server
: EJB
: EJB
Client Hosts
: client host
: test client
: test client
: test client
: client host
: test client
: test client
: test client
: client host
: test client
: test client
: test client
: EJB server
: EJB
: EJB
EJB-test
Servlet engine
AutoGen™ code
generator
SyncLoad ™
Desktops
: NT host
: browser
: Solaris host
: browser
: NT host
: browser
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/22
Other Interesting EJB Tests
• Stress Testing• Mixed/Randomized Loads• Scenario Testing• Security Testing• Configuration Testing
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/23
Anatomy of an EJB Test Client Driver
2 Lookup Home Interface in JNDI Tree
java.lang.Object homeObject = jndi.lookup("OECustomer");com.testmybeans.customer.CustomerHome home = (com.testmybeans.customer.CustomerHome) javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object) homeObject, com.testmybeans.customer.CustomerHome.class);
java.lang.Object homeObject = jndi.lookup("OECustomer");com.testmybeans.customer.CustomerHome home = (com.testmybeans.customer.CustomerHome) javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object) homeObject, com.testmybeans.customer.CustomerHome.class);
1
Get JNDI InitialContext
//[WebSphere302 getInitialContext] public static Context getInitialContext(String urlName) throws javax.naming.NamingException { Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, "iiop://" + urlName); env.put("java.naming.factory.initial", "com.ibm.ejs.ns.jndi.CNInitialContextFactory"); env.put("javax.naming.Context.INITIAL_CONTEXT_FACTORY", "com.ibm.ejs.ns.jndi.CNInitialContextFactory"); InitialContext ctx = new InitialContext(env); return ctx; }
//[WebSphere302 getInitialContext] public static Context getInitialContext(String urlName) throws javax.naming.NamingException { Hashtable env = new Hashtable(); env.put(Context.PROVIDER_URL, "iiop://" + urlName); env.put("java.naming.factory.initial", "com.ibm.ejs.ns.jndi.CNInitialContextFactory"); env.put("javax.naming.Context.INITIAL_CONTEXT_FACTORY", "com.ibm.ejs.ns.jndi.CNInitialContextFactory"); InitialContext ctx = new InitialContext(env); return ctx; }
BOF-1303, EJB™ Scalability/Load Test [email protected] http://www.ejbtest.com/24
Anatomy of an EJB Test Client Driver
3
Get a Bean Instance
if (m_ds.getRule().equals("Data table")) h = home.findByPrimaryKey(pkey0);else h = home.create(arg0);
if (m_ds.getRule().equals("Data table")) h = home.findByPrimaryKey(pkey0);else h = home.create(arg0);
5
Log Results
timer.start (m_cSetters, "setCustomerAddress", sValue);h.setCustomerAddress(sValue);timer.stopAndLog();
timer.start (m_cSetters, "setCustomerAddress", sValue);h.setCustomerAddress(sValue);timer.stopAndLog();4
timer.start(m_cSetters, "setCustomerAddress", sValue);h.setCustomerAddress(sValue);timer.stopAndLog();
timer.start(m_cSetters, "setCustomerAddress", sValue);h.setCustomerAddress(sValue);timer.stopAndLog();
Exercise Bean's Business Methods
BOF-1303, EJB™ Scalability/Load Test25