J2EE Technologies and Distributed Multi-Tiered Application Development

Download Report

Transcript J2EE Technologies and Distributed Multi-Tiered Application Development

J2EE Technologies and Distributed
Multi-Tiered Application Development
Presented by
Steven Reagan, Jijun Lu, Marwan Sleiman, Wangang Xie
Semester Project
CSE333 – Distributed Component Systems (Spring 2004)
Instructor
Prof. Steven A. Demurjian
Department of Computer Science and Engineering
University of Connecticut
[email protected]
[email protected]
[email protected]
[email protected]
J2EE--1
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--2
Introduction





Java is widely used in academia as well as in
industry.
Developers are more concerned about the speed &
security of their applications as they are deployed
over the internet, J2EE provides the necessary
tools and technologies to facilitate their work.
The J2EE platform offers a multi-tiered distributed
application model.
We will present J2EE as a multi-tier solution for
applications. A database application will be studied.
Different alternatives in our prototype will be
compared.
J2EE--3
Why J2EE?




Java is free.
Java is portable: Platform independent and enables
compressible executable jar files.
Java is reusable: using past code in current
problems is time saving.
J2EE has powerful technologies:
 Java Server Pages (JSPs)
 Java Servlet
 JDBC
 Enterprise JavaBeans (EJBs)
 Java Messaging Server (JMS)
 Java Secure Socket Extension (JSSE)
J2EE--4
Motivation – Why Multi-Tier?
Benefits of Multi-Tier Deployment.







Portable and platform independent.
Better flexibility for scaling-up and scaling-out.
Lower deployment cost on a controlled server than
deploying software on all the user terminals.
Possibility of securing deployments using firewalls and/or
secure connections.
Easier to troubleshoot and localize errors.
Filters overload (undesired traffic) from the clients on the
servers.
Filters abnormal access to the server.
J2EE--5
Our Prototype architecture
Direct JDBC
Middle Tier
HTTP Server
Sockets
HTTP
JDBC
Servlet
JMS
JDBC
Database
JDBC
JMS
Client (Application/Browser)
J2EE Middle Tier
J2EE--6
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--7
Sockets (API)



host or
A socket is an interface between
server
app layer and transport layer
process sends/receives messages
to/from its socket
socket analogous to door
process
 sending process shoves
socket
message out door
TCP with
 sending process assumes
transport infrastructure on other buffers,
variables
side of door which brings
message to socket at receiving
process
host or
server
controlled by
app developer
process
socket
Internet
TCP with
buffers,
variables
controlled
by OS

API: (1) choice of transport protocol; (2) ability to
implement encryption.
J2EE--8
The Socket Technology

We implemented the socket programming with TCP
because it is connection oriented and provides a reliable
point-to-point communication channel that client-server
applications can use to communicate with each other.

TCP socket connections are setup in the following way:
1.
A server has a server socket, bound to a specific port
number to listen for any client willing to make a
connection.
2.
Knowing the hostname and port number, the client
sends a connection request to the server.
3.
The server accepts the connection and gets a new
socket bound to a new port.
4.
A socket is created on the client and communication
begins.
J2EE--9
Patterns - Tiers

Client Tier
Requests different sizes of files from the database ( 1k to 8M )
Contains TCP Client Socket
Connects with the middle-tier
Communicates the database request and result via HashMap over the Socket
Calculates the response time for each file request

Middle – Tier
Contains the Server Socket
Gets the database command from the Client Socket
Connects to the MySQL databse server.
Returns the SQL results to the client.
Handles multiple Client connection by using multithreading.

Database Tier
Contains the MySQL server.
J2EE--10
Experiments done
Different sizes of
database files: 1k to 8M
Different numbers of
clients.


Data
1 Client
5 Clients
10 Clients
20 Clients
30 Clients
1K
141
251
254
224
320
2K
120
151
129
149
142
8K
191
140
132
157
151
16K
190
179
135
168
143
32K
201
188
138
176
170
256K
240
244
267
341
200
512K,
262
481
570
661
649
1M
400
790
895
1443
2121
4M
971
2914
4481
7172
9563
8M
1682
5320
5876
Out of Memory
Out of Memory
J2EE--11
Graph: Average Response Time (ms)
12000
10000
1 Client
8000
5 Clients
6000
10 Clients
20 Clients
4000
30 Clients
2000
8M
4M
1M
25
6K
51
2K
,
32
K
16
K
8K
2K
1K
0
J2EE--12
Evaluation of the results.


We remark that, for small file sizes (1k to 8k), the response
time decreases as the file size increases. This unusual
behavior is the result of the overhead of the initial
handshaking when the connection is established.
System limitations on the middle-tier/server sides caused
the program to crash:
 A typical Dell workstation (P4, 2.6 GHz, 1GB RAM)
was unable to support more than 30 concurrent socket
connections.
 As we increased the memory size of the machines used,
bigger files we exchanged without memory overflow.
J2EE--13
Socket Security consideration

JSSE provides us with SSLSocket , and
SSLServer Socket classes, which are extensions
to the classical Socket , and Server Socket. They
add a layer of security protections over the
underlying TCP network transport protocol.
Those protections include:

Integrity Protection. SSL protects against
modification of messages by intruders.
Authentication. In most modes, SSL provides peer
authentication.
Confidentiality (Privacy Protection). In most
modes, SSL encrypts the data sent between
client and server.
J2EE--14
Socket Security consideration

SSL protocol overview:
TCP/IP Protocol Stack With SSL
TCP/IP Layer
Protocol
Application Layer
HTTP, NNTP, Telnet, FTP, etc.
Secure Sockets Layer
SSL
Transport Layer TCP
Internet Layer
IP

The SSL Process/Handshaking:
Negotiate the cipher suite.
Authenticate identity (optional).
Establish information security by agreeing on encryption
mechanisms
J2EE--15
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan).
Java Sockets (Marwan).
Middle-tier architecture (Steven)
Java Servlets (Steven).
Java Message Service (JMS) (Jijun).
Java Database Connectivity (Wangang).
Comparison of the four methods (Wangang).
Conclusion.
J2EE--16
Middle Tier Communication

A Middle Tier Application defines a public API
accessible to all Clients.
 A Client application remotely access any
available public method. The Client must be
able communicate:
 The remote method to invoke.
 The arguments for the remote method.
 The return value(s) expected.

Thus, we need an interface to facilitate this
notion of remote method invocation.
 RMI does this already! However, it is typically
only used for communication between standalone
client and server applications.
– Separate plugin required for each client to communicate
with a Servlet Middle Tier.
J2EE--17
Middle Tier Communication (cont’d)

We established a simple interface for Client/Middle Tier
communication.


Used for each Middle Tier implementation for consistency.
A Table (Object) is always transmitted between the Client
and Middle Tier Applications.

Client to Middle Tier
 Table Contains:
– String – Remote Method Name.
– Object[] – Remote Method Parameters.

Middle Tier to Client
 Table Contains:
– Object – Return Value.
– Exception – Any Exception thrown by the Middle Tier or Remote
Method.
 Method Invoked using the Java Reflection API:
– Method method = this.getClass().getDeclaredMethod(name, types);
– Object result = method.invoke(this, args);
J2EE--18
Middle Tier Communication (cont’d)

A consistent model has been chosen for our Middle Tier
architecture. Conceptually, each implementation consists
of four files.
 Client Side:
 Client.java – Test Program.
– Constant for each implementation (Does not change).
 Database.java – “Artificial Database”.
– Appears to Client programmers as the Database.
– Handles communication to and from the Middle Tier.
– Specific for each Middle Tier choice (Sockets, HTTP).

Server Side:
 MiddleTier.java – Middle Tier Application.
– Handles communication from and to the Client.
– Specific for each implementation.
 Database.java – JDBC Wrapper.
– Constant for each implementation (Does not change).
J2EE--19
Middle Tier Communication (cont’d)
Client.java
Database db = new Database();
File = db.getFile(“filename”);
Database.java
…
public void addFile(String filename, byte[] data) throws SQLException {
…
}
Public File getFile(String filename) throws SQLException {
table.put(“name”, “getFile”);
table.put(“args”, new Object[] {filename});
sendRequestToMiddleTier(table);
}
Client Side
MiddleTier.java
…
public requestMade(Table table) {
Method method = this.getClass().getDeclaredMethod(table.get(“name”),
table.get(“argTypes”);
Object result = method.invoke(this, args);
sendResponse(result);
}
public File getFile(String filename) throws SQLException {
return database.getFile(filename);
}
Server Side
Database.java
…
public File getFile(String filename) throws SQLException {
PreparedStatement ps = connection.prepareStatemnt(“SELECT Data FROM
file WHERE Name = ?”);
…
return file;
}
J2EE--20
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan).
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--21
Servlets

Java program that runs within a web server
(Apache Tomcat, Sun One Server, JBoss, …)
 Typically small in size.
 Receive/Respond to requests made from web
clients over HTTP (Hyper Text Transfer
Protocol).
 Dynamic User-Oriented Content.
 Server-Side.

Middle Tier Solutions.
 Many benefits.
J2EE--22
Servlet (cont’d)


Four Methods Commonly Implemented.
 doGet – HTTP GET.
 doPost – HTTP Post.
 init – Beginning of Servlet Life Cycle.
 destroy – End of Servlet Life Cycle.
Life Cycle
 Controlled by the web container where the Servlet was
deployed.
 Upon request the following steps are performed:
 1. If the Servlet instance does not exists, the web container:
– Loads the Servlet class and creates an instance..
– Initializes the Servlet (init method).
 2. Invokes the service method passing in request/response
objects.

If the web container needs to remove the Servlet, the
Servlet’s destroy method is called.
J2EE--23
Dynamic Content

Earliest Attempts:
 Applets:
 Focused on Client platform for dynamic experience.
 Advantages:
– Rich User Interfaces.
 Disadvantages:
– Must be downloaded by the Client.
– Slow!

CGI scripts:
 Dynamic Content generated on Server Side.
 Advantages:
– May be written in many languages (C, C++, Perl, …)
– Faster than applets (Server Side).
 Disadvantages:
– Platform Dependence.
J2EE--24
Dynamic Content (cont’d)

Benefits of the Servlet:
 Portable.
 Run on any J2EE supported Server.

Simplified Deployment.
 Standard Packaging.
– Single Web Application Archive (WAR) file.

Fast.
 Server Side.
 Servlet instances persist across client requests.
– No need for the Server to constantly be spawning new
processes.
J2EE--25
Example
Todays Date:
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("Todays Date: " + new Date() + "<br>");
}
J2EE--26
Middle Tier

By definition, a Middle Tier Implements a
request/response programming model.
 Servlets fit the request/response paradigm!
 Natural choice for web service developers.

Requests and Responses are made over HTTP.
 Any Serializeable object may be sent or
received via HTTP.
 Thus, any Client or Web Service that can
communicate over HTTP may access a Middle
Tier’s set of API methods.
 Java Desktop Applications.
 HTML documents.
 Java Web Services.
J2EE--27
Middle Tier (cont’d)
Client (Browser)
HTTP
Client (Application)
JDBC
HTTP
Java Servlet
Database
Web Service
HTTP
J2EE--28
Middle Tier (cont’d)

Benefits:
 Servlet is a Java Program written in the Java
Programming language.
 Access to entire set of Java APIs.
 Portable (Write Once Run Anywhere).
 Java VM manages Servlets.
– Little Concern about Memory Leaks or Garbage
Collection.
 Resource pooling (Database connections).

Simplified Deployment.
 Run on any J2EE enable web server.
 Standard Packaging.
– Single Web Application Archive (WAR) file.

Servlet instances can persist Across multiple clients.
 Minimal external processes.
J2EE--29
Performance


Three Tier Architecture:
 Tier 1: Client Tier.
 Tier 2: Servlet Middle Tier.
 Tier 3: Database Backend.
Request Response Times:
 Single Client.
 Retrieval of files ranging from 1k to 8M.

Multiple Clients.
 Retrieval of files ranging from 1k to 8M.
Client (Application)
HTTP
Tier 1
JDBC
Java Servlet
Database
Tier 2
Tier 3
J2EE--30
Performance (cont’d)

Average Response Times:
One Client
Five Clients
Data Received Response Time (ms)
1K
10.00
2K
10.00
8K
10.00
16K
10.00
32K
10.00
256K
40.00
512K
90.00
1M
180.00
4M
671.00
8M
1332.00
Data Received Response Time (ms)
1K
92.20
2K
109.00
8K
94.00
16K
110.00
32K
102.00
256K
213.00
512K
376.20
1M
651.00
4M
2175.00
8M
5153.00
Ten Clients
Twenty Clients
Thirty Clients
Data Received Response Time (ms)
1K
119.00
2K
123.00
8K
120.00
16K
121.00
32K
143.00
256K
311.00
512K
603.00
1M
1087.70
4M
4173.70
8M
Out of Memory
Data Received Response Time (ms)
1K
166.00
2K
149.00
8K
152.55
16K
276.80
32K
236.50
256K
517.35
512K
1011.40
1M
1844.95
4M
Out of Memory
8M
Out of Memory
Data Received Response Time (ms)
1K
185.33
2K
179.67
8K
181.67
16K
173.33
32K
289.33
256K
664.60
512K
Out of Memory
1M
Out of Memory
4M
Out of Memory
8M
Out of Memory
J2EE--31
Performance (cont’d)

Average Response Times:
Average Response Time
6000.00
5000.00
Response Time (ms)
4000.00
One Client
Five Clients
Ten Clients
Twenty Clients
Thirty Clients
3000.00
2000.00
1000.00
0.00
1
2
8
16
32
256
512
1000
4000
8000
Data Received (K)
J2EE--32
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--33
Java Message Service(JMS)





A specification that describes a common way for
Java programs to create, send, receive and read
distributed enterprise messages
loosely coupled communication
Asynchronous messaging
Reliable delivery
 A message is guaranteed to be delivered once
and only once.
Outside the specification
 Security services
 Management services
J2EE--34
A JMS Application




JMS Clients
 Java programs that send/receive messages
Messages
Administered Objects
 preconfigured JMS objects created by an admin
for the use of clients
 ConnectionFactory, Destination (queue or topic)
JMS Provider
 messaging system that implements JMS and
administrative functionality
 SunONE (SUN)
 WebSphere (IBM)
 WebLogic (BEA)
J2EE--35
A JMS Application (cont’d)
Administrative
Tool
Bind
JNDI Namespace
Lookup
JMS Client
Logical
Connection
JMS Provider
J2EE--36
JMS Messaging Domains

Point-to-Point (PTP)
 built around the concept of message queues
 each message has only one consumer
Msg
Msg
consumes
Client1
sends
Client2
Queue
acknowledges
J2EE--37
JMS Messaging Domains

Publish-Subscribe systems
 uses a “topic” to send and receive messages
 each message has multiple consumers
subscribes
Client2
Msg
delivers
Client1
publishes Topic
subscribes
Client3
delivers
J2EE--38
JMS API Programming Model
Connection
Factory
creates
Connection
Message
Producer
creates
sends to
Destination
Session
creates
creates
Msg
Message
Consumer
receives
from
Destination
J2EE--39
Producer Sample

Setting up connections and sessions
// Obtain a JNDI connection
InitialContext jndiContext=new InitialContext();
//look up for the connection factory
ConnectionFactory cf=jndiContext.lookup(connectionfactoryname);
//create a connection
Connection connection=cf.createConnection();
//create a session
Session session=connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
//create a destination object
Destination dest1=(Queue) jndiContext.lookup(“/jms/myQueue”); //for PointToPoint
Destination dest2=(Topic)jndiContext.lookup(“/jms/myTopic”); //for publish-subscribe
J2EE--40
Producer Sample (cont’d)

Creating producer
MessageProducer producer=session.createProducer(dest1);

Send a message
Message m=session.createTextMessage();
m.setText(“just another message”);
producer.send(m);

Closing the connection
connection.close();
J2EE--41
Consumer Sample (Asynchronous)



Setup the connection, create a session
Create consumer
Registering the listener
// registering the listener
MessageListener listener=new myListener();
consumer.setMessageListener(listener);

myListener should have onMessage()
// onMessage() method
public void onMessage(Message msg){
// read the massage and do something
// see next slides
}
J2EE--42
Listener Example
public void onMessage(Message message) {
TextMessage msg = null;
try {
if (message instanceof TextMessage) {
msg = (TextMessage) message;
System.out.println("Reading message: " + msg.getText());
} else {
System.out.println("Message of wrong type: " +
message.getClass().getName());
}
} catch (JMSException e) {
System.out.println("JMSException in onMessage(): " + e.toString());
}
} catch (Throwable t) {
System.out.println("Exception in onMessage():" + t.getMessage());
}
J2EE--43
JMS in Our Application


Three Tier Architecture:
 Tier 1: JMS Client Tier.
 Tier 2: JMS Middle Tier.
 Tier 3: Database Backend.
In our project, we do not enable multi clients.
 No “multi thread support” in this JMS middle
tier.
JMS Messaging
Tier 1
JMS Middle
Tier
Tier 2
JDBC
Database
Tier 3
J2EE--44
Performance

Average Response Times (for one client):
One Client
Data Received Response Time (ms)
1K
10.00
2K
10.00
8K
20.00
16K
20.00
32K
20.00
256K
60.00
512K
331.00
1M
501.00
4M
1392.00
8M
1822.00
J2EE--45
Performance (cont’d)

Average Response Times:
Average Response Time
(One Client)
2000.00
1800.00
1600.00
Response Time (ms)
1400.00
1200.00
JMS
Servlet
1000.00
Direct JDBC
Socket
800.00
600.00
400.00
200.00
0.00
1
2
8
16
32
256
512
1000
4000
8000
Data Received (K)
J2EE--46
Performance (cont’d)


Pros:
 Loosely coupled
 Asynchronous
 Reliable
 Scalable
Cons:
 JMS is complicated: management, server
monitoring, and security issues
 Differences exist between various
implementations.
J2EE--47
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--48
JDBC- Java Database Connectivity




A Java API for connecting programs written in
Java to relational databases
Data Access Interface
Access many data sources
 Database access
 Spreadsheets
 Flat Files
Performs common task like
 Connection pooling
 Batch updates
 Transaction management
J2EE--49
JDBC- Java Database Connectivity

General steps:








Importing Packages
Registering the JDBC drivers
Opening a Connection to a Database
Creating a Statement Object
Executing a Query and Returning a Results Set Object
Processing the Result Set
Closing the Result Set and Statement Objects
Closing the Connection
J2EE--50
JDBC-Architecture

Two-tier architecture


The top level: visible to application programs
The lower level: consists of drivers for individual
engines
J2EE--51
JDBC- Classes and Interface
Connection
prepareStatement
subclasses
Statement
subclasses
PreparedStatement
Input to
PreparedStatement
CallableStatement
Input/Output of
CallableStatement
Data types
executeQuery
getXXX
ResultSet
J2EE--52
JDBC Connect with MySQL
 MySQL Connector/J: an implementation of JDBC 3.0 API
for the MySQL relational database server
public class Connect {
public static void main (String[] args) {
Connection conn = null;
try {
String userName = "testuser";
String password = "testpass";
String url = "jdbc:mysql://localhost/test";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
System.out.println ("Database connection established");
}
catch (Exception e) {
System.err.println ("Cannot connect to database server");
}
finally {
if (conn != null) {
try {
conn.close ();
System.out.println ("Database connection terminated");
}
catch (Exception e) { /* ignore close errors */ }
}
}
}
}
J2EE--53
JDBC Connect with MySQL

Response time
File/Client
1K
2K
8K
16K
32K
256K
512K
1M
4M
8M
1
16
0
0
0
15
16
62
125
438
828
5
6.2
6.2
6.4
3
9.6
34.4
81.2
212.2
1484.4
2978.4
10
7.8
3.2
3.1
4.7
7.8
35.9
84.4
214.2
2128.1
4036.3
20
3.8
3.8
2.4
3.85
6.25
44.55
93
371
2835.9
30
4.2
3.1
3.6
5.2
6.8
31.8
88.1
241.2
2893.8
50
4.66
2.2
3.48
5.34
6.52
35.92
90.68
279.96
3100.66
J2EE--54
JDBC Connect with MySQL

Response time
4500
1 Client
4000
5 Client
3500
10 Client
3000
20 Client
30 Client
2500
50 Client
2000
1500
1000
500
0
1K
2K
8K
16K
32K
256K
512K
1M
4M
8M
J2EE--55
JDBC- Security consideration

JDBC and untrusted applets




JDBC and Java applications


driver should only be used with code loaded from that same source
Network security


assume that normal unsigned applets are untrustworthy
not allow untrusted applets access to local database data
avoid making use of local credentials when connecting to remote
database servers
the network protocols used for database access fixed by the DBMS
vendor or connectivity vendor
Security Responsibilities of Drivers


Sharing TCP connections
Check all local file access
J2EE--56
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--57
Comparison of the four methods

Speed…
 Naturally, the exclusion of a Middle Tier results in
faster request/response times.

Ease of programming…
 Addition of a Middle Tier means a more complicated
design and evolving issues:
 A Server program or web server must be deployed.
 New technologies must be learned (Servlet Programming,
Socket Programming, Java Messaging).
 A Communication interface needs to be developed and tested.

Security…
 Allowing a Client direct access to a database puts the
most critical resource (information) at risk.
 Passwords remain unencrypted in the client’s program files.
–

Available to any slightly skilled user/programmer.
A Middle Tier Application hides data from the (untrusted) Client users.
J2EE--58
Performance

Average Response Times:
Average Response Time
(One Client)
2000.00
1800.00
1600.00
Response Time (ms)
1400.00
1200.00
JMS
Servlet
1000.00
Direct JDBC
Socket
800.00
600.00
400.00
200.00
0.00
1
2
8
16
32
256
512
1000
4000
8000
Data Received (K)
J2EE--59
Performance

Average Response Times:
Average Response Time
(Five Clients)
6000.00
5000.00
Response Time (ms)
4000.00
Servlet
3000.00
Direct JDBC
Socket
2000.00
1000.00
0.00
1
2
3
4
5
6
7
8
9
10
Data Received (K)
J2EE--60
Performance

Average Response Times:
Average Response Time
(Ten Clients)
7000.00
6000.00
Response Time (ms)
5000.00
4000.00
Servlet
Direct JDBC
Socket
3000.00
2000.00
1000.00
0.00
1
2
3
4
5
6
7
8
9
10
Data Received (K)
J2EE--61
Performance

Average Response Times:
Average Response Time
(Twenty Clients)
8000.00
7000.00
Response Time (ms)
6000.00
5000.00
Servlet
Direct JDBC
4000.00
Socket
3000.00
2000.00
1000.00
0.00
1
2
3
4
5
6
7
8
9
10
Data Received (K)
J2EE--62
Performance
Average Response Times:

Average Response Time
(Thirty Clients)
12000
10000
Response Time (ms)
8000
Servlet
Direct SQL
6000
Socket
4000
2000
0
1
Data Received (K)
J2EE--63
Organization of presentation
1.
2.
3.
4.
5.
6.
7.
8.
Introduction and Motivation (Marwan)
Java Sockets (Marwan)
Middle-tier architecture (Steven)
Java Servlets (Steven)
Java Message Service (JMS) (Jijun)
Java Database Connectivity (Wangang)
Comparison of the four methods (Wangang)
Conclusion
J2EE--64
Conclusions


Direct access to the database consistently yields faster request/response
times.
 How important is Speed?
 How important is the Data Set?
 Remember, Middle Tier hides database from user.
 In practice, any Client to Database communication will be
facilitated by a Middle Tier.
 Data almost always more important than the slightly better
request/response times.
It was expected that Socket communication would be faster than HTTP.
because it operates at a lower level. However, results indicated
otherwise. Reasons:
 We use the TCP Socket, which is connection oriented and
provides a reliable point-to-point communication channel. UDP
communication would have been faster, however unreliable.
 In, Servlets, multithreading is done by J2EE, while in the socket
method, we wrote the code by hand.
J2EE--65
Conclusions (cont’d)

JMS provide a loosely coupled communication with
asynchronous and reliable messaging services.
 More complicated and costly.
 Time = Money.
Difficult to use in a system that is inherently
synchronous.
 JMS messaging is more appropriate for Middle Tier to
Component/Java Bean communication.
Servlets hold a deployment advantage over JMS and
Socket Servers.
 Web container is responsible for creating Servlet
processes.
 Socket Server applications must be started and stopped
manually.


J2EE--66