Docsity

Optimizing a Skeletal Web Proxy Server: Project 2, Study Guides, Projects, Research of Operating Systems

Toggle sidebar
bg1
Project 2 (due 7/7/2003)
An Optimized Skeletal Web Proxy Server
In this project, you will use your web server code as the basis for a proxy server. The proxy
server will have no functionality (yet!) other than being an intermediary between a web server
and a web client. The proxy server will have to be optimized so that it can work very efficiently
when communicating with your own web server running on the same machine.
1. General instructions
• Read the entire instructions carefully before you start implementing anything!
• Be warned: this project will require more independent study of technical material
than Project 1. This tends to be time consuming. Also, you have to decide on the
design of your system.
• Don’t get stuck! If something is hard to implement the way suggested here,
approximate it and go on!
• If you have any questions, ask the instructor or the TA! Use the newsgroup for broad
questions.
2. Description of Project Stages
The project consists of four stages. The stages are not balanced! (Stage 2 should take longer than
the rest.)
2.1. Web Proxy Server and Proxy Capable Client
Using your web server code, implement a multithreaded web proxy server. (You
should have as much code as possible in source files that are shared between the web
server and the proxy server.) A proxy server is an intermediary between a web server
and a client (the client could be another proxy server, however). That is, the proxy
server receives requests for pages that would normally be served by different web
servers. The proxy server will then need to contact the appropriate server and receive
the contents of each page before it can serve them to the client. (Of course, the proxy
server could have cached pages from previous requests, but caching is beyond the
scope of this project.)
The only kind of HTTP request you need to support in your proxy server is a GET
request. Note, however, that a GET request that is addressed to a proxy server has to
have an absolute URI (instead of a relative URI). That is, the requested address will
begin with “http:” and will specify an internet name, instead of just specifying a
relative file path.
Test your proxy server with a standard browser. To set up Netscape to use a proxy, go
to Edit->Preferences->Advanced->Proxies->Manual proxy configuration->HTTP
pf3
pf4

Partial preview of the text

Download Optimizing a Skeletal Web Proxy Server: Project 2 and more Study Guides, Projects, Research Operating Systems in PDF only on Docsity!

Project 2 (due 7/7/2003)

An Optimized Skeletal Web Proxy Server

In this project, you will use your web server code as the basis for a proxy server. The proxy server will have no functionality (yet!) other than being an intermediary between a web server and a web client. The proxy server will have to be optimized so that it can work very efficiently when communicating with your own web server running on the same machine.

1. General instructions

- Read the entire instructions carefully before you start implementing anything! - Be warned: this project will require more independent study of technical material than Project 1. This tends to be time consuming. Also, you have to decide on the design of your system. - Don’t get stuck! If something is hard to implement the way suggested here, approximate it and go on! - If you have any questions, ask the instructor or the TA! Use the newsgroup for broad questions.

2. Description of Project Stages

The project consists of four stages. The stages are not balanced! (Stage 2 should take longer than the rest.)

2.1. Web Proxy Server and Proxy Capable Client

Using your web server code, implement a multithreaded web proxy server. (You should have as much code as possible in source files that are shared between the web server and the proxy server.) A proxy server is an intermediary between a web server and a client (the client could be another proxy server, however). That is, the proxy server receives requests for pages that would normally be served by different web servers. The proxy server will then need to contact the appropriate server and receive the contents of each page before it can serve them to the client. (Of course, the proxy server could have cached pages from previous requests, but caching is beyond the scope of this project.)

The only kind of HTTP request you need to support in your proxy server is a GET request. Note, however, that a GET request that is addressed to a proxy server has to have an absolute URI (instead of a relative URI). That is, the requested address will begin with “http:” and will specify an internet name, instead of just specifying a relative file path.

Test your proxy server with a standard browser. To set up Netscape to use a proxy, go to Edit->Preferences->Advanced->Proxies->Manual proxy configuration->HTTP

Proxy.

Additionally, change your web client from Project 1 to support web proxies. You can do this by adding a command line argument. For instance, your client could be executable as: web_client <#threads> [-proxy proxy_addr] +

Make sure that your client issues requests with absolute URLs when connecting to a proxy server.

2.2. Efficient Web Proxy

Overview An interesting special case is when your web proxy runs on the same machine as your web server and it receives a request for a file serviced by your web server. In this case, your web server and your web proxy server are essentially two modules of the same local application that just happen to run in different address spaces. This is a nice system structure because the role of the proxy server is conceptually very different from the role of the web server and one could run with or without the other. Web servers are responsible for serving pages (ensuring security, retrieving files from the file system, creating dynamic pages, etc.), whereas proxy servers can do higher-level page manipulation (e.g., compression, encryption, caching, etc.) without knowing anything about how pages are stored on disk or how they are generated dynamically.

When your web server runs on the same machine as your proxy server, transmitting files between them through a socket is inefficient. Instead, the two processes can use shared memory to pass file data efficiently. This optimization is what you need to implement in this stage of the project. Note that this task requires additions both to the web server and the proxy server. Make sure that you can enable and disable the optimization (e.g., use a command line argument, or a compile-time flag). This is because you will need to compare the optimized and un-optimized versions eventually.

Architecture and Technical Concerns You are free to implement the basic functionality any way you want, but be sure to document your design in your report. Below, an outline is given of the functionality, but there is significant freedom at every step:

- The proxy server receives a request and extracts the address of the target web server. - If the target web server is on the local machine, the proxy server checks to see if the web server is your own web server. There are two issues here. First, it is a (relatively) hard problem to check whether an internet name is a name (or alias) for the local machine. This project is not about implementing mature Internet protocols, so just do something reasonable (like checking if the name maps to the IP address you know for the current host—do not just compare names!) The second issue is how to detect that the web server that will serve the page is your

your servers are probably programs running forever, the only way for them to exit is through termination by a signal. This could happen, for instance, by pressing Ctrl-C on the keyboard. Define and install signal handlers for some common signals, so that the server cleans up when it exits (“server” being either the proxy server or the web server, depending on which one creates the shared memory). There is no way to do a perfect job—there are signals that cannot be caught, like SIGKILL or SIGSTOP—but take care of some obvious cases. Test to see that your solution works (that is, the shared memory resources are removed).

For signal reference, read the man page for sigaction and follow the pointers to other man pages. See also header file <sys/signal.h>.

2.4. Experiments

Using your client, compare the performance of your optimized and un-optimized web server and proxy server pairs. Show the results of experiments (give actual numbers) and explain. Is using shared memory faster or slower? Is it a bandwidth issue or a latency issue? (Think about the kinds of experiments you need to perform to separate the two.) How do you interpret the results? (What do they tell you about the operating system and its implementation of cross-process synchronization and/or sockets?) Also, compare the performance of the web server and proxy server pair to just the web server. How much slower does the proxy server make the system?

3. Deliverables

You should turn in the following:

- Your code. Make sure it is obvious how to compile and run everything (i.e., supply a README file). Send everything as in Project 1 (email a code archive to the TA and to myself). - A report outlining your design choices and the results of your experiments.

Good luck! Have fun!!!