Code Monkey home page Code Monkey logo

15721-s24-cache2's Introduction

15721-s24-cache2

15-721 Spring 2024 - Cache #2

LRU Cache Server

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.

Features

  • 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.

Getting Started

Prerequisites

  • Rust and Cargo (latest stable version recommended)
  • Rocket Framework
  • Docker

Installation

  1. Clone the repository:

    git clone [email protected]:cmu-db15721-s24-cache2.git
    cd 15721-s24-cache2/server
  2. Build the project:

    docker build -t istziio .
  3. 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.

Example

$ 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

Usage

Health Check

  • Endpoint: GET /
  • Description: Checks if the server is running.
  • CURL Command:
    curl http://localhost:8000/

Fetch File

  • 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>

Cache Stats

  • 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

Set Cache Size

  • 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>

Benchmark

To run benchmark, simple run bench.sh

15721-s24-cache2's People

Contributors

17zhangw avatar apavlo avatar j-howhuang avatar oscarzhou0107 avatar scottlinnn 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.