15-721 Spring 2024 - Cache #2
This server implements a Least Recently Used (LRU) caching mechanism, providing a simple interface for fetching files from a simulated S3 storage and managing them within an LRU cache. The server is built using Rust and the Rocket framework.
- Health Check: Verify the server's health.
- Fetch File: Retrieve files, either served from the cache or fetched from "S3" and then cached.
- Cache Stats: Get statistics about the current state of the cache.
- Set Cache Size: Adjust the maximum size of the cache dynamically.
- Rust and Cargo (latest stable version recommended)
- Rocket Framework
- Docker
-
Clone the repository:
git clone [email protected]:cmu-db15721-s24-cache2.git cd 15721-s24-cache2/server
-
Build the project:
docker build -t istziio .
-
Run the server:
docker compose up -d
Important
Under development stage, the server cluster can be access ONLY within the specific Docker network. Client side needs to be in the same Docker bridge network for the correct redirection.
$ docker exec -it server-servernode_1-1 /bin/bash
root@node1:/data> apt-get update && apt-get install curl -y
root@node1:/data> curl -L http://node2:8000/s3/test1.txt # make sure -L flag is set for auto redirect to the correct node
- Endpoint:
GET /
- Description: Checks if the server is running.
- CURL Command:
curl http://localhost:8000/
- Endpoint:
GET /s3/<path>
- Description: Retrieves a file from the cache or fetches it from the simulated S3 storage if not present in the cache. Error reports if file not existed.
- CURL Command:
curl http://localhost:8000/s3/<path-to-file>
- Endpoint:
GET /stats
- Description: Returns statistics about the cache, such as current size, maximum size, and number of entries.
- CURL Command:
curl http://localhost:8000/stats
- Endpoint:
POST /size/<new_size>
- Description: Adjusts the maximum size of the cache.
- CURL Command:
curl -X POST http://localhost:8000/size/<new-size-in-bytes>
To run benchmark, simple run bench.sh