A simple distributed caching system built to practice core distributed systems concepts such as load balancing, caching, concurrency, health checks, and failure handling. The system consists of:
- Origin Server – the source of truth for data.
- Proxy Nodes – cache data using TTL-based expiration.
- Load Balancer – distributes client requests across proxies.
- Client – sends GET and METRICS requests to the load balancer.
- TTL/LRU-based caching at each proxy.
- Round-robin or least-loaded load balancing.
- Health checks and automatic failure detection.
- Metrics reporting from proxies and the load balancer.
- Simple newline‑terminated JSON request/response protocol.
- Support for multiple cache types (TTLCache and LRUCache) configurable per proxy.
--cache_type ttl(TTL cache with configurable ttl)--cache_type lru(LRU cache with configurable capacity)
python origin/origin_server.py
python proxy/proxy_node.py --port 8001 --origin_port 8000 --cache_type lru
python proxy/proxy_node.py --port 8002 --origin_port 8000 --cache_type ttl
python proxy/proxy_node.py --port 8003 --origin_port 8000 --cache_type lru
python load_balancer/load_balancer.py --port 9000 --proxies 127.0.0.1:8001 127.0.0.1:8002 127.0.0.1:8003
python client/client.py --port 9000 --get article/1
python client/client.py --port 9000 --metrics
To easily start and stop the full distributed system, use the provided scripts in the scripts/ directory.
./scripts/start_cluster.sh
This launches:
- Origin server
- All proxy nodes (started with LRUCache by default)
- Load balancer
Proxies are started with the provided cache type via start_cluster.sh.
./scripts/kill_cluster.sh
This safely terminates all running components using both tracked PIDs and process-name matching.
origin/ - origin server and data files
proxy/ - proxy node, cache, metrics
load_balancer/ - load balancer + node manager
client/ - client CLI
This project demonstrates a clean and minimal implementation of distributed caching with clear separation between origin, proxies, load balancer, and client.