CSCI 320 - Operating Systems & Concurrency
Spring 2019
Rust Web Server, part 2
Assignment
In this assignment, we will enhance the web server previously developed. A big part of this assignment is performance assessment
of different variations. To facilitate this, I strongly
recommend that you maintain multiple versions of your server using git. Note
that you can use Github desktop without hosting your code on Github. If you
do use Github, ensure that your repository is private.
Testers
webtest
To test Steps 1 and 2, make a modified version of your webget
program from
Rust Assignment 2.
Call this version webtest
, and have it follow the following conventions for its
command-line arguments:
- The first argument is the hostname/ip address.
- This is followed by one or more file requests.
- The last argument is the number of times to issue the requests.
The program should construct a multi-file GET request from those command-line arguments. Here is
an example of an invocation of the program and the corresponding request:
webtest file100.html file1000.html file10000.html 3
GET request, issued 3 times:
GET /file100.html
/file1000.html
/file10000.html
HTTP/1.1
Host: localhost
For Step 3, use locust.io to test the performance of your server.
This program allows you to write Python scripts to describe workload tests. It will then spawn as
many test users as you would like. To install it, type in the command line on a machine with
Python installed:
pip install locustio
or
python3 -m pip install locustio
Once it is installed, you can write a Python program as a configuration file. For example:
from locust import HttpLocust, TaskSet, task
import http.client
http.client._MAXHEADERS = 1000
class MyTaskSet(TaskSet):
@task(2)
def index(self):
self.client.get("/file100.html")
@task(1)
def about(self):
self.client.get("/file1000.html")
class MyLocust(HttpLocust):
task_set = MyTaskSet
min_wait = 5000
max_wait = 15000
This program issues GET requests for the files file100.html
and
file1000.html
. It issues requests for file100.html
twice as often as
requests for file1000.html
. Each simulated user will wait between 5 and 15 seconds
between issuing requests.
To run a test using the above program (named locust_test_1.py
), assuming a server
running at 192.168.0.102
and listening to port 8888
, type:
locust -f locust_test_2.py --host=http://192.168.0.102:8888
When you execute this, the UI for the program will be viewable through your web browser at http://127.0.0.1:8089/
. From there, you specify the number of users to simulate and the number of users created per second. The test will continue indefinitely until you stop it. It will give you a nice summary of the test results.
Server Modifications
Follow these steps:
- Modify your program to handle a GET request for multiple files at once.
The server should send each of the requested files.
Here is an example of such a request:
GET /index.html
/file1.html
/file2.html
/file3.html
/file4.html
HTTP/1.1
Host: localhost
- Modify your program so that each file in a multi-GET request is handled
by a separate thread.
- Devise at least three different performance workloads using locust.io
Note that, in general, it is best to run your tests on a
different machine than that which is running your server. Each of your
workloads should represent a different type of stress on the server.
- Implement and assess at least three of the following ideas for improving
the performance of your server:
- Maintain a cache of previously requested pages.
- Prioritize requests. One example of a priority scheme is to answer
requests for shorter files first.
- Instead of reading an entire file into RAM and then sending it over
the socket, read in a file incrementally, sending the contents
incrementally as well.
- Any other reasonable idea that you might devise.
For your server to work correctly with locust.io, you will need to ensure the following is the case with your HTTP header:
- Make sure there are two newline characters between the header and the returned code.
- Include a
Content-Length:
line that includes the number of bytes it intends to send back. locust.io will use this value to ensure it has received everything.
- Document your performance workloads and your assessment results.
Discuss in this document which combinations of improvements were most effective
in comparison with your baseline implementation from Step 1 (and with each
other).
Submit your webtest
program along with each version of your web server that you tested, along with a PDF of
your assessment document, via Moodle.
Grading
Steps 1 and 2 are each worth 10 points. Each part of Step 4 is worth 5 points.
Any variation beyond the third is worth 5 points extra credit. The final
assessment document is worth 15 points; in addition, full credit for the
other steps depends on the content of the document, so don't forget to do it!
Therefore,
the total value of the assignment is 50 points. No credit
will be given for code that fails to compile. Partial credit may be given for
incomplete or flawed versions of a given step.
Acknowledgement
This assignment was adapted from materials developed by David Evans at the University of Virginia.