CS 5523 Operating Systems
Laboratory 3 - Spring 2003
Comparing Threaded Servers

Objectives:

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:

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:

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:

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:

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:

  • 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.