Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A lightweight, Go-based distributed in-memory cache. 15000 QPS with P99 latency under 2 ms.

Notifications You must be signed in to change notification settings

Hymeis/Distributed-Cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

17 Commits

Repository files navigation

Distributed-Cache

A lightweight, Go-based distributed in-memory cache with consistent-hashing sharding, singleflight deduplication, size-bounded LRU, protobuf communication, and read-through replication

Architecture

Client β†’ Group.Add("🐺", "Hymeis")
 └─> Cache.Add("🐺", "Hymeis")
 β”œβ”€ insert into in-memory LRU
 └─ async fan-out to R-1 successors:
 └─ for each replica in GetReplicas("🐺", R)[1:]:
 HTTP POST /dcache/<group>/🐺 (SetRequest)
Client β†’ Group.Get("🐺")
 β”œβ”€ LRU hit? ──▢ return "Hymeis"
 └─ cache miss:
 └─ singleflight.Do("🐺", fn):
 └─ pickPeer("🐺") via consistent-hash
 β”œβ”€ peer? ──▢ peerLoad (HTTP+Protobuf) ──▢ return "Hymeis"
 └─ local? ──▢ localLoad:
 β”œβ”€ GetterFunc β†’ origin data
 β”œβ”€ Replication() (see Add flow above)
 └─ return "Hymeis"

wrk2 BenchMark Testing

Sustained a constant 15 000 QPS workload with wrk2, observing:

  • Throughput: 14 982 req/sec (β‰ˆ15 000 target)
  • Mean latency: 0.868 ms
  • P50 / P75 / P90: 0.86 ms / 1.15 ms / 1.44 ms
  • P99: 1.94 ms (well under 10 ms SLO)
  • P99.9 / P99.99: 2.40 ms / 2.86 ms
  • Max observed: 4.00 ms

Next Steps

  • Application side: Maybe make a Leetcode Top K ranking system?

How to run the project

Try

bash run.sh

and check the output shown

About

A lightweight, Go-based distributed in-memory cache. 15000 QPS with P99 latency under 2 ms.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /