multi threaded proxy.ppt

Upload: proxiesforrent

Post on 04-Jun-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 multi threaded proxy.ppt

    1/13

    Multi threaded proxy

  • 8/14/2019 multi threaded proxy.ppt

    2/13

    Step 1: Implement a barebonesproxy

  • 8/14/2019 multi threaded proxy.ppt

    3/13

    Opens a TCP server socket to listen for TCPconnections on a particular port.

    When a new connection is setup, the proxy reads in aHTTP request; yourcode needs to be compatible withHTTP GET requests sent by the curl HTTP client.

    The cheap proxy should then pass on that HTTP request

    to the relevant webserver, download the data received,and send it back to the client on the TCP connection thatthe client had established. You need to ensure that youcan handle interleaving of requests from multiple clientsby maintaining su ffi cient state so that you return a

    response received from a webserver back to the correctclient.

    http://proxiesforrent.com/http://proxiesforrent.com/
  • 8/14/2019 multi threaded proxy.ppt

    4/13

    Rather than constantly poll sockets to receivedata, you should implement

    network I/O code using the select call. Also, makesure to handle all errors so

    that your implementation is robust.

  • 8/14/2019 multi threaded proxy.ppt

    5/13

    Step 2: Make the proxy multi-threaded

  • 8/14/2019 multi threaded proxy.ppt

    6/13

    To improve the throughput o ff ered, make yourpaid proxy multi-threaded. The proxy

    would work in the same way as above, except thatwhenever data is to be

    received, a new thread is spawned to do so.However, you should limit the

    number of threads in your code to at most 20,rather than let the number of

    threads grow unbounded.

    http://proxiesforrent.com/http://proxiesforrent.com/
  • 8/14/2019 multi threaded proxy.ppt

    7/13

    Step 3: Add a cache to theproxy

  • 8/14/2019 multi threaded proxy.ppt

    8/13

    To further improve throughput, add a cache to yourcheap proxy server . At any given time,

    the cache should contain at most 10 MB of data. To evictdata from the cachewhen there is a cache miss, implement the Least-

    Recently-Used (LRU) cachereplacement policy, i.e., always insert into the cache the

    most recently accessedobject and to incorporate it into the cache, evict the

    appropriate number ofleast recently used objects from the cache. Ensure that

    reads from and writesto your cache are thread-safe.

    http://proxiesforrent.com/http://proxiesforrent.com/
  • 8/14/2019 multi threaded proxy.ppt

    9/13

    Step 4: Deploy the proxy onEC2

  • 8/14/2019 multi threaded proxy.ppt

    10/13

    Sign up to Amazon EC2(http://aws.amazon.com/ec2/) and provision a

    Microinstance; Amazon o ff ers for free one Microinstance that runs Linux (http:

    //aws.amazon.com/free/). Make sure you setup a

    Micro instance andthat you use Linux, else you will be charged foryour usage of EC2.

    Run your proxy on a EC2 Micro instance and test

    it by fetching web pages viait running curl on departmental machines at UCR.

  • 8/14/2019 multi threaded proxy.ppt

    11/13

    Requirements and Deliverables

    All your code must be written in C. Network I/O should use theselect, recv, and send calls. Use the pthread library forthreading and inter-thread synchronization.

    The following two deliverables are expected at the end of thisproject, both due before class on 31st January 2011.

    Deploy your proxy on EC2 and email me the address at whichyour proxy is accessible. The address expected is of theformat hostname:port or IPAddress:port. I will then evaluate

    your implementation with my test suite, which will fetch webpages via your proxy.

    Email me an archive that contains all your source code.

  • 8/14/2019 multi threaded proxy.ppt

    12/13

    Grading policy

    This project is worth 20 points.

    10 points: I will go over your source code to ensure yourimplementation of (a) select-based socket programming,

    (b) thread pool, and (c) thread-safe cache look correct.10 points: I will fetch web pages via your best paid proxy

    service using the curl HTTP client. Your proxy must berobust enough to handle web requests to arbitrary websites. The submission that yields the maximumthroughput will be granted 10 points. The number ofpoints awarded to all others will be in proportion to thefraction of this maximum throughput their proxy o ff ers.

    http://proxiesforrent.com/http://proxiesforrent.com/http://proxiesforrent.com/http://proxiesforrent.com/
  • 8/14/2019 multi threaded proxy.ppt

    13/13

    Thanking you..For more info log on too..

    http://proxiesforrent.com

    http://proxiesforrent.com/http://proxiesforrent.com/http://proxiesforrent.com/