CS 5523 Operating Systems
Laboratory 3 - Spring 2003
Comparing Threaded Servers
Objectives:
- Understand the worker-pool model.
- Understand the thread-per-connection model.
- Experiment with servers that use RMI with CORBA.
- Learn about threaded servers.
- Use thread synchronization in a real problem.
- Make meaningful performance measurements and organize them
into graphics and tables.
- Think about experimental design and hypotheses.
Overview:
In this laboratory you will write two versions
of a threaded
server (thread-per-connection and worker-pool) and
compare their performance. In both cases the communication
will be based on Java over TCP.
Requirements:
- You will be writing three versions of the server
(Server Version I, II and III) and a client for testing both
servers.
- Your source code must be clean and clear. (It will be read, and you will
be graded on its quality as well as whether the code works.)
- This project must be done in Java and Java with CORBA.
- You must hand in ALL source for each program separately.
- You must hand in the output files for each part separately.
- You must hand in a word-processed report of 3 to 5 pages (single-spaced, 12 pt type) summarizing
the structure of your program, known bugs, how you tested the program, and
answers to the questions posed in the assignment. Your report should also
an introductory paragraph and a
diagram of the architectural models implemented in this assignment.
- Staple your entire project in the upper left corner. If it is too large
to staple, staple sections in the upper left and clip it together.
- Take care in organizing your output. I do not want a ream of paper
with long listings of numbers.
Server Version I (thread-per-connection):
Server Version I (main thread) listens for a TCP connection request on a well-known
port. After accepting the request, the server creates a
thread to handle the request and resumes listening for another request.
The thread function takes the Socket
returned from the accept method as a parameter.
The thread makes itself a daemon thread, starts itself,
performs the request, closes
the Socket in response to the client's closing and returns.
Server Version I takes
the well-known port
as a command line argument.
Server Version II (worker pool with bounded buffer):
Server Version II is based
on a producer/consumer model with the main thread being the producer
and the worker threads being consumers.
The main thread listens for connection requests and asks the workers
to process them.
Server Version II takes the well-known port,
the size of the
buffer, and the size of the
worker-pool as command line arguments.
Server Version III (CORBA thread per request):
Server Version III is similar to Server Version I, but instead of using
sockets, the server is a remote object. The server creates a new thread object
to handle each request. You will also need to modify the client driver described
in the next section to use CORBA.
Client driver (for parts I and II):
You should also write a client driver program that takes
the following command line arguments: the hostname of the server,
the port name of the server,
the number of connections,
the size of the message body,
and the number of messages per connection.
The client driver will create a thread to perform each connection.
Each connection thread performs the following:
- connect to the specified server.
- for the number of messages per connection:
- send the message
- read the response
- calculate and output statistics
- close the connection
Note, the connection request may fail and have to be retried
when the server is busy, so you will need to put this in its
own loop. The number of connections means the number of successful
connections.
The process should get the time before it tries to make a
connection and after it makes the connection. It should also
read the time after it has received the response. It should
output the time differences between these three points
along with its PID so that the interleaved
messages from the different processes can be distinguished.
Before each client process exits it should print the
the total number of connection retries it experienced and other
relevant statistics. You should write a script to start multiple client
drivers on the same machine as well as testing this with client drivers
on different machines.
The message:
Each message from the client should consist of a header
that contains
five long integers:
- Process ID of client process
- Client message number
- Length of the message body
- 0
- 0
The header is followed by the message body of the specified length.
Each time the client process sends a message, it increments the
client message number. The client does not reset the message counter
when it makes a new connection.
The response consists of a structure containing the following
long integers:
- Process ID of client process
- Client message number
- Length of response body
- Thread ID of thread that processes the message
- Thread message number
The header is followed by the message body of the specified length.
Each time a server thread processes a message, it increments
its thread message number. It does not ever reset the message
number to zero.
Gathering statistics:
You should gather statistics about average and median connection times
and response times for the three different servers. For the worker pool you
should compare results for 1, 5 and 10 threads in the pool.
You should vary the number of client processes and also test with
the client driver running simultaneously on multiple machines. You should organize
your results in tables and graphically and draw conclusions about the measurements
in your report.
Questions:
- Under what circumstances
should Server Version I exit?
- What happens in Server Version I if the main thread
closes the file descriptor after creating a thread to handle
the communication?
- Under what circumstances
should Server Version II exit?
- What are the sources of overhead
in the Server Version I implementation?
- What are the sources of overhead
in the Server Version II implementation?
- What are the sources of overhead
in the Server Version III implementation?
- What is the effect of the start-up phase of the client driver?
- What is the effect of the client message body size on the results?
- In what ways are the resource usage of these servers different
from those of a real threaded web server?
Please don't run big timing tests between 8 am in the morning and 6 pm
at night during the week.
I have given threaded server problems to previous classes (not the same
one) and have done a
post-mortem analysis
of the mistakes. You should read
over the post-mortem and make sure that you understand why the problems pointed
out might be problems. Remember, however, that last year's assignment was
done in C with PThreads and did not have any CORBA.
You are welcome to ask questions about these in class.
Last Revision: April 21, 2003 at 6:45 am by Kay A. Robbins.
This material may be used for educational purposes provided that the source
is credited.