Distributed Java Communications
Download
Report
Transcript Distributed Java Communications
Distributed Java
Communications
Eric Lind
CS522 Semester Project
December 9, 2002
How does one distribute using
Java?
Many different methods are available
Sockets
RMI
CORBA
XML (SOAP or JAX)
How do I decide which to use?
Each new trend claims to be
faster/stronger/better
Can be hard to compare different
methods
Numbers are hard to come by
Which numbers to use?
Project Benchmarks
Use a simple chat application
Contrived, yes, but still demonstrates
features of each method
Measure data written and read by each
client or server
Not concerned with low-level traffic, but
with the application level data.
Sockets
Server
Port
Port
Connection Request
Bi-Directional Connection
Client
Port
Sockets
Advantages:
Nearly universal
Uses the smallest
amount of data to
communicate
Bi-directional
Disadvantages:
Pretty low-level
Must do many
things by hand
No additional
services provided
RMI
Registry
Obtain Remote
Reference
RMIChat
Obtain Remote
Reference
receive(Message)
Port
Port
RMIChat
receive(Message)
Each RMIChat object must implement both
the client and server interface
RMI
Advantages:
Standard Java
API
Allows remote
objects to be
treated as if local
Includes some
services
Disadvantages:
Uses client-pull
(clients must also
be servers for 2way comm.)
Setup code is
cumbersome
Marshalling is
slow
CORBA
IIOP
ORB
CORBAChat
ORB
CORBAChat
As with RMI, each CORBAChat object must
act as both client and server
CORBA
Advantages:
Open standard
Many platforms /
languages
Provides
additional
services
Generally faster
than RMI
Disadvantages:
Not “Java-friendly”
Uses client-pull
Tends to be trickier
than other methods
Had considerable
trouble with
generated classes
JAX-RPC
Tomcat (or any Servletenabled Web Server)
Chat Service
Ties
Runtime
SOAP Message
HTTP
SOAP Message
HTTP
Runtime
Runtime
Stubs
JAXChat
Stubs
JAXChat
JAX-RPC
Advantages:
Uses SOAP (can
talk to non-Java
platforms)
Very easy to
develop
Uses HTTP
(eases security
concerns)
Disadvantages:
Uses SOAP (XML
is very verbose)
Requires web
server
Restricts data that
can be sent
Still buggy
Benchmark Results
3500
2922
3000
2494
2000
2411
2399
2500
Sockets
RMI
JAX-RPC
1755
1500
1000
500
126 169
138 181
0
Setup
"" (35 bytes)
"Test Message" (47
bytes)
Conclusions
Sockets have the lowest overhead
RMI does not add much (only 43 extra
bytes)
XML adds a lot of overhead (19 times)
Must convert binary data to text
SOAP envelope is huge
Conclusions (cont.)
RMI is probably the best for pure-Java
applications
Low overhead
Normal Java semantics
RMI over IIOP should put RMI on par
with CORBA for speed.
Conclusions (cont.)
Web Services are (supposedly) platform
neutral
Good model for general data access,
not so good for bandwidth constrained
applications
CORBA is still the only viable, crossplatform communications protocol, but
it’s not easy to use