This is a very rudimentary caching server not for production environments.
I wanted to learn the distributed system concepts and I prefer doing realtime projects instead of staying theoretical. I implemented leetcode question on Design LRU Cache and immediately idea clicked to make it distributed so that I get a chance to learn about the following in the order of priority:
- Horizontal Scaling Design (In progress)
- Consistent Hashing & sharding of data (In progress)
- Hands on with gRPC (Implemented already)
- LRU Cache with TTL (Implemented already)
- Leader election (Bully algorithm) - (Planned)
- Replication of data using Raft (Planned)
- Automated deployments using Jenkins (Planned)
- Containerized cluster with Kubernetes (Planned)
- Automated deployment to AWS EKS & GCP GKE (Planned)
- Observability using Grafana & OpenTelemetry (Planned)
- Distributed tracing using Jaeger or Zipkin (Planned)
Note that 9, 10 & 11 as above are stretch goals, but definitely given a chance to be tried.
Ringserver isn't perfect for production workloads and not even useful for playing around with it, but it's good enough for me to learn about distributed system concepts described above and importantly being hands-on in addition to being only theoretical.
Java is my primary & best known programming language and I've chosen it to implement it. Ringserver would require Java 21 and above with a maven setup in local to play around.
I will attempt to write a parallel project with golang as it's fast becoming favorite programming language I love nowadays. But that's for another day to get real handson experience with golang.
Until then, happy learning!
Here is the Service/API Specification:
message SetRequest {
string key = 1;
string value = 2;
int64 ttl = 3; // 0 means no ttl
}
message SetResponse {
bool success = 1;
string message = 2;
}
message GetRequest {
string key = 1;
}
message GetResponse {
string value = 1;
bool found = 2;
}
service LRUCacheService {
rpc Set(SetRequest) returns (SetResponse);
rpc Get(GetRequest) returns (GetResponse);
}Assuming Java 21+ and maven installed and the respective bin directories are in PATH system variable.
To build:
$ mvn clean install
To run:
$ java target/ringserver.jar