garnet README

The project's README from github.com/microsoft/garnet. As one markdown file: README.md.

Garnet

.NET CI BDN Charts Discord Shield

Garnet is a remote cache-store that offers several unique benefits:

This repo contains the code to build and run Garnet. For more information and documentation, check out our website at https://microsoft.github.io/garnet.

Looking for a fully managed service? Azure Cosmos DB Garnet Cache provides Garnet as a fully managed, enterprise-ready caching solution with built-in high availability, performance guarantees and zero infrastructure management.

What's New 🎉

Feature Summary

Garnet implements a wide range of APIs including raw strings (e.g., gets, sets, and key expiration), analytical (e.g., HyperLogLog and Bitmap), and object (e.g., sorted sets and lists) operations. It can handle multi-key transactions in the form of client-side RESP transactions and our own server-side stored procedures and modules in C#. It allows users to define custom operations on both raw strings and custom object types, all in the convenience and safety of C#, leading to a lower bar for developing custom extensions. Garnet also supports Lua scripts.

Garnet uses a fast and pluggable network layer, enabling future extensions such as leveraging kernel-bypass stacks. It supports secure transport layer security (TLS) communications using the robust SslStream library of .NET, as well as basic access control. Garnet’s storage layer, called Tsavorite, is built for high performance and includes strong database features such as thread scalability, tiered storage support (memory, SSD, and cloud storage), fast non-blocking checkpointing, recovery, operation logging for durability, multi-key transaction support, and better memory management and reuse. Finally, Garnet supports a cluster mode of operation with support for sharding, replication, and dynamic key migration.

Performance Preview

We illustrate a few key results on our website comparing Garnet to leading open-source cache-stores.

Design Highlights

Garnet’s design re-thinks the entire cache-store stack – from receiving packets on the network, to parsing and processing database operations, to performing storage interactions. We build on top of years of our prior research. Below is Garnet’s overall architecture.

Garnet’s network layer is based on a shared memory design, with TLS processing and storage interactions performed on the network IO completion thread, avoiding thread switching overheads in the common case. This approach allows CPU cache coherence to bring the data to the processing logic, instead of traditional shuffle-based network designs, which require data movement to the appropriate shard on the server.

Garnet’s storage design consists of two Tsavorite key-value stores whose fates are bound by a unified operation log. The first store, called the “main store,” is optimized for raw string operations and manages memory carefully to avoid garbage collection. The second, and optional, “object store” is optimized for complex objects and custom data types, including popular types such as Sorted Set, Set, Hash, List, and Geo. Data types in the object store leverage the .NET library ecosystem for their current implementations. They are stored on the heap in memory (which makes updates very efficient) and in a serialized form on disk. In the future, we plan to investigate using a unified index and log to ease maintenance.

A distinguishing feature of Garnet’s design is its narrow-waist Tsavorite storage API, which is used to implement the large, rich, and extensible RESP API surface on top. This API consists of read, upsert, delete, and atomic read-modify-write operations, implemented with asynchronous callbacks for Garnet to interject logic at various points during each operation. Our storage API model allows us to cleanly separate Garnet’s parsing and query processing concerns from storage details such as concurrency, storage tiering, and checkpointing. Garnet uses two-phase locking for multi-key transactions.

Cluster Mode

In addition to single-node execution, Garnet has a fully-featured cluster mode, which allows users to create and manage a sharded and replicated deployment. Garnet also supports an efficient and dynamic key migration scheme to rebalance shards. Users can use standard Redis cluster commands to create and manage Garnet clusters, and nodes perform gossip to share and evolve cluster state. Garnet's cluster mode design is currently passive: this means that it does not implement leader election, and simply responds to cluster commands issued by a user-provided control plane; see this link for details.

Next Steps

Head over to our documentation site, or jump directly to the getting started or releases section.

License

This project is licensed under the MIT License, see the LICENSE file.

Privacy

Privacy information can be found at https://privacy.microsoft.com/en-us/.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Redis is a registered trademark of Redis Ltd. Any rights therein are reserved to Redis Ltd. Any use by Microsoft is for referential purposes only and does not indicate any sponsorship, endorsement or affiliation between Redis and Microsoft.

garnet (microsoft/garnet)

Searching Database…

12.1K ·GitHub
这是什么?Garnet 是微软研究院出品的远程缓存存储:一个键值服务器,现有的 Redis 客户端可以直接连接使用,专为高吞吐、低延迟、持久化和集群分片而构建。
这是嵌入到我应用里的库,还是需要我自己运行的服务器?它是一个独立部署、通过网络访问的服务器,不是库——客户端使用 RESP 协议,所以像 StackExchange.Redis 这样未经修改的 Redis 客户端可以直接使用。
我怎么把它跑起来?下载预构建的发行版或运行 Docker 镜像(仓库里提供了 Dockerfile 和 compose 文件),然后把你的 Redis 客户端指向它;文档站点上有入门指南。
我需要先安装 .NET 或其他东西吗?Garnet 用 .NET 上的 C# 编写。使用 Docker 镜像或已发布的发行版不需要额外安装任何东西;从源码构建则需要 .NET SDK。
集群能自己处理故障转移吗?不能——集群模式是被动的:没有领导者选举,故障转移和重新分片要靠你自己的控制平台下发命令。另外 Vector Sets 和 Range Index 目前仍处于预览阶段。
它在 Linux 和 Windows 上都能运行吗?能——它是跨平台的 .NET 应用,在 Linux 和 Windows 上都有顶尖的性能表现,CI 会为两个平台分别构建 Docker 镜像。
相比我现有的缓存存储,为什么选 Garnet?微软表示,在大量并发客户端连接和小批次请求的场景下,Garnet 的吞吐量和可扩展性远超同类的开源缓存存储;在 Azure 虚拟机上,客户端延迟在第 99.9 百分位通常低于 300 微秒——他们认为这能在大规模部署时节省成本。
除了普通字符串,我还能存什么?支持带过期时间的原始字符串、HyperLogLog 和 Bitmap 等分析类数据,以及有序集合、集合、哈希、列表、Geo 等对象。还支持多键事务和 Lua 脚本,另外有用于最近邻搜索的预览版 Vector Sets 和二级范围索引。
如果数据集超出内存大小,重启后数据还在吗?在。Tsavorite 存储引擎提供快速的非阻塞检查点、恢复、持久化操作日志,以及跨内存、SSD 和云存储的分层存储,所以数据可以比内存更大。
我能给它添加自定义操作吗?你可以在原始字符串和自定义对象类型上定义自定义操作,并用 C# 编写服务端存储过程和模块,享受 .NET 生态的安全性。网络层也是可插拔的。
What are similar projects?redis, dragonfly, Smartstore, phpredis, orleans, valkey, eShopOnWeb, codis
Creator
microsoft
Size
647.7 MB
Stars
12.1K
Age
3y
Commits · 90 Days