Homework 11

22C:116, Fall 1999

Due Friday Nov 19, 1999, in class

Douglas W. Jones

  1. Background Consider the problem of writing an efficient web server. Your server must handle many requests from different clients, where each request involves transmitting a copy of some file from your server to the client. The least efficient way to code this server would be:
    	repeat
    	   await request from client c for file f
    	   establish connection to c
    	   open f
    	   repeat
    	      for each sector of f
    	      send the sector over the connection to c
    	   until all sectors sent
    	   terminate connection to c
            forever
    
    Assume that the host system for this server has the usual features of a good modern operating system such as a file system, a disk scheduler, caching of frequently referenced disk sectors in RAM, etc.

  2. Part A: Explain the poor performance of this option, and explain what would be needed to improve the performance.

    Part B: Show how to obtain this improved performance by redesigning the web server using appropriate thread primitives.

    Part C: Assume that your design is deluged with thousands of requests from far away users. What effect does this have on: 1) the time it takes to get the first sector of each user's file back to that user, and 2) the time it takes to give each user the entire file. If you limited the number of concurrent threads in your solution to part B, how would this change your answers above?

  3. A Question: Do question 4 on page 547 of the text.

  4. Part A: Describe clearly and concisely the independent variables that most directly influence the choice between the following alternatives: Moving the process to the machine that has the file, moving the file to the machine that has the process, or moving just the bytes required by the read and write operations requested by that process.

    Part B: Briefly characterize applications that would work best with each of the above alternatives.