This project implements a multi-threaded proxy server in C, inspired by this Proxy Server project.
This project demonstrates how a proxy server handles client requests using multi-threading and caching to enhance performance.
- Semaphore is used instead of
pthread_join()and condition variables for thread synchronization. sem_wait()andsem_post()don’t require thread IDs, making them simpler and more efficient.
To understand:
- How client requests are processed by servers.
- Handling multiple client requests simultaneously.
- Concurrency control using locks and semaphores.
- Caching mechanisms and their impact on performance.
- Performance Boost: Reduces server load and speeds up requests.
- Access Control: Restricts specific websites.
- Anonymity: Masks client IP addresses.
- Security: Encrypts requests to prevent unauthorized access.
- Threading
- Locks
- Semaphores
- Caching (LRU algorithm)
- Multiple Client Responses: Each client’s response is cached separately, leading to incomplete website loading.
- Fixed Cache Size: Large websites may not fit in the cache.
- Multiprocessing: Boost performance through parallelism.
- Content Filtering: Control access to specific websites.
- POST Requests: Extend support for different HTTP methods.
- Clone the repository:
git clone <repository-url> cd MultiThreadedProxyServerClient
- Build the project:
make all
- Run the proxy server:
./proxy <port-number>
- Test it by opening:
http://localhost:<port>/https://www.cs.princeton.edu/
- Linux Only: The proxy runs on Linux.
- Browser Cache: Disable browser caching for accurate testing.
- Without Cache: To disable caching, rename the Makefile entry from
proxy_server_with_cache.ctoproxy_server_without_cache.c.
- First Access: If a website is opened for the first time, the cache will miss (
url not found). - Subsequent Access: The cache retrieves the data, and
Data is retrieved from the cacheis displayed.
Contributions are welcome! Feel free to submit pull requests.
Enjoy coding! 🎉