Git Product home page Git Product logo

multithreadedproxyserverclient's Introduction

Multi Threaded Proxy Server with and without Cache

This project is implemented using C and Parsing of HTTP referred from Proxy Server

Index

Project Theory

[Back to top]

Introduction
Basic Working Flow of the Proxy Server:

How did we implement Multi-threading?
  • Used Semaphore instead of Condition Variables and pthread_join() and pthread_exit() function.
  • pthread_join() requires us to pass the thread id of the the thread to wait for.
  • Semaphore’s sem_wait() and sem_post() doesn’t need any parameter. So it is a better option.
Motivation/Need of Project
  • To Understand →
    • The working of requests from our local computer to the server.
    • The handling of multiple client requests from various clients.
    • Locking procedure for concurrency.
    • The concept of cache and its different functions that might be used by browsers.
  • Proxy Server do →
    • It speeds up the process and reduces the traffic on the server side.
    • It can be used to restrict user from accessing specific websites.
    • A good proxy will change the IP such that the server wouldn’t know about the client who sent the request.
    • Changes can be made in Proxy to encrypt the requests, to stop anyone accessing the request illegally from your client.
OS Component Used ​
  • Threading
  • Locks
  • Semaphore
  • Cache (LRU algorithm is used in it)
Limitations ​
  • If a URL opens multiple clients itself, then our cache will store each client’s response as a separate element in the linked list. So, during retrieval from the cache, only a chunk of response will be send and the website will not open
  • Fixed size of cache element, so big websites may not be stored in cache.
How this project can be extended? ​
  • This code can be implemented using multiprocessing that can speed up the process with parallelism.
  • We can decide which type of websites should be allowed by extending the code.
  • We can implement requests like POST with this code.

Note :-

  • Code is well commented. For any doubt you can refer to the comments.

How to Run

$ git clone https://github.com/Lovepreet-Singh-LPSK/MultiThreadedProxyServerClient.git
$ cd MultiThreadedProxyServerClient
$ make all
$ ./proxy <port no.>

Open http://localhost:port/https://www.cs.princeton.edu/

Note:

  • This code can only be run in Linux Machine. Please disable your browser cache.
  • To run the proxy without cache Change the name of the file (proxy_server_with_cache.c to proxy_server_without_cache.c) MakeFile.

Demo

  • When website is opened for the first time (url not found) then cache will be miss.
  • Then if you again open that website again then Data is retrieved from the cache will be printed.

Contributing

[Back to top]

Feel free to add some useful. You can see How this code can be extended. Use ideas from there and feel free to fork and CHANGE.

Enjoy CODE and pull requests are highly appreciated.

multithreadedproxyserverclient's People

Contributors

lovepreet-singh-lpsk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.