How chyavanrao7/reverse_proxy works
Project type and purpose
• This is a small, Java-based reverse proxy / load balancer demonstration project.
• It includes two main subsystems:
a. A TCP/HTTP load balancer (round-robin)
b. Multiple simple HTTP backend servers
File structure
• Top-level:
• LICENSE, README.md, docker-compose.yaml
• backend/ – Java HTTP backend server + Dockerfile
• loadbalancer/ – Java load balancer code
• The presence of Dockerfiles and docker-compose.yaml shows containerization and network orchestration
Key insights from the README
• Load balancer listens on port 8888, forwards to backends on configurable ports
• Uses java.net.ServerSocket/Socket, multithreading (2 threads per connection), round-robin
• Backends respond with simple HTML indicating their port
Main components
a. Client (e.g., curl or browser)
b. Load Balancer (Java process or container)
c. HTTP Backend Servers (3 instances of HttpBackendServer)
d. Docker Network (reverse_net) – optional boundary if containerized
e. Host or VM
Relationships & interactions
• Client → Load Balancer (TCP connection on port 8888)
• Load Balancer → Backend Servers (round-robin, TCP connections to ports 9001, 9002, 9003)
• Bidirectional data flow on each connection (two dedicated threads)
• Docker network interconnects containers by hostname
Architectural patterns & principles
• Reverse proxy / load balancer pattern
• Round-robin scheduling algorithm
• Thread-per-connection (uses ExecutorService)
• Containerized deployment (Docker, docker-compose)
Technologies & frameworks
• Java 17, java.net sockets
• Docker (Dockerfile in each service, docker-compose.yaml)
• Multithreading (Threads, ExecutorService)
Detail without overthinking
• Services (LB, each backend), network boundaries (host vs container), data flows, config files
• Use as many distinct components as exist in the repo (docker-compose, Dockerfiles, Java classes)