GoCached - Distributed Cache System

software active
Technologies:
GogRPCRaftRedis Protocol

A high-performance distributed caching system built in Go, implementing the Redis protocol with additional features for distributed environments.

Features

  • Redis Protocol Compatible - Drop-in replacement for Redis in many use cases
  • Distributed by Design - Uses Raft consensus for high availability
  • Memory Efficient - Custom memory allocator optimized for cache workloads
  • Persistence Options - Support for RDB and AOF persistence modes
  • Monitoring Built-in - Prometheus metrics and distributed tracing

Architecture

The system consists of three main components:

  1. Cache Server - Handles client connections and command processing
  2. Consensus Layer - Raft-based replication for consistency
  3. Storage Engine - Pluggable backend (memory, disk, hybrid)

Performance

Benchmarks on a 3-node cluster:

  • 1M+ ops/second for reads
  • 500K+ ops/second for writes
  • Sub-millisecond latency at p99
  • Linear scalability up to 10 nodes

Use Cases

  • Session storage
  • API response caching
  • Real-time analytics
  • Message queuing
  • Leaderboards and counters

Implementation Highlights

// Example of the command processing pipeline
type Command interface {
    Execute(ctx context.Context, db *Database) (interface{}, error)
    Replicate() bool
}

// Raft integration for consistency
func (s *Server) Apply(log *raft.Log) interface{} {
    var cmd Command
    if err := decode(log.Data, &cmd); err != nil {
        return err
    }
    return cmd.Execute(context.Background(), s.db)
}

Future Plans

  • Geo-distributed replication
  • Advanced eviction policies
  • Built-in load balancing
  • Kubernetes operator
  • Multi-tenancy support