rustcached - 用rust實現的一個memcached克隆
rustcached - 用rust實現的一個memcached克隆
Features:
- Aside from what's listed in Missing below, we support all memcached commands and are fully compatible </ul>
- binary protocol
stats- UDP
- unix sockets
deletewith expires (memcached dropped this support in 1.4)flush_allwith expiresverbosityis recognised but ignored- SASL </ul>
Missing:
Performance
rustcache is about half as fast as memcached according to memslap:
rustcached:
$ memslap --servers=localhost:11211 --test=set --concurrency=10 --debug --execute-number=10000 --flag --flush
Threads connecting to servers 10
Took 3.145 seconds to load data
$ memslap --servers=localhost:11211 --test=get --concurrency=10 --debug --execute-number=10000 --flag --flush
Threads connecting to servers 10
Took 4.976 seconds to read data memcached:
$ memslap --servers=localhost:11212 --test=set --concurrency=10 --debug --execute-number=10000 --flag --flush
Threads connecting to servers 10
Took 2.736 seconds to load data
$ memslap --servers=localhost:11212 --test=get --concurrency=10 --debug --execute-number=10000 --flag --flush
Threads connecting to servers 10
Took 3.933 seconds to read data Code organisation:
cmd.rs: control starts here, command line arguments parsed, and the server startedstore.rs: houses the memcached application logic (e.g. what does "add" mean and how do I apply it?)lru.rs: the LRU cacheparser.rs: protocol parsingserver.rs: socket handling and response writing
Todo:
- We're using the default rust allocator (jemalloc) for everything, instead of a slab allocator like memcached
- you can exhaust memory in the parser with an unlimited key/value length
- you can't
setvalues larger than the memcached length limits, but you canappend/prependpast them - We copy a lot of stuff around right now that we don't have to, especially in the response builder
lru.rsusesArc<T>but there's probably a way to just useRc<T>when we go single-threaded
Future features:
- we use LRU right now like memcached does, but I want to try ARC in a real environment
- eager deletion of expired items during idle periods
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!