关于用于 Redis 的 Azure 缓存About Azure Cache for Redis

Azure Cache for Redis 基于 Redis 软件提供内存中数据存储。Azure Cache for Redis provides an in-memory data store based on the Redis software. Redis 极大地提高了在后端数据存储上使用的应用程序的性能和可伸缩性。Redis improves the performance and scalability of an application that uses on backend data stores heavily. 它将经常访问的数据保留在可快速读写的服务器内存中,从而能够处理大量应用程序请求。It is able to process large volumes of application request by keeping frequently accessed data in the server memory that can be written to and read from quickly. Redis 为新式应用程序带来了关键的低延迟、高吞吐量数据存储解决方案。Redis brings a critical low-latency and high-throughput data storage solution to modern applications.

Azure Cache for Redis 提供 Redis 开放源代码 (OSS Redis) ,还提供 Redis 实验室的一款商业产品 (Redis Enterprise) 作为托管服务。Azure Cache for Redis offers both the Redis open-source (OSS Redis) and a commercial product from Redis Labs (Redis Enterprise) as a managed service. 它提供安全的专用 Redis 服务器实例,且完全兼容 Redis API。It provides secure and dedicated Redis server instances and full Redis API compatibility. 该服务由 Microsoft 管理并在 Azure 中托管,可供 Azure 内外的任何应用程序访问。The service is operated by Microsoft, hosted on Azure, and accessible to any application within or outside of Azure.

Azure Cache for Redis 可用作分布式数据或内容缓存、会话存储和消息中转站等。Azure Cache for Redis can be used as a distributed data or content cache, a session store, a message broker, and more. 它可单独部署,也可与其他 Azure 数据库服务(如 Azure SQL 或 Cosmos DB)一起部署。It can be deployed as a standalone or along side with other Azure database services, such as Azure SQL or Cosmos DB.

关键方案Key scenarios

Azure Cache for Redis 通过支持常见的应用程序体系结构模式来提高应用程序性能。Azure Cache for Redis improves application performance by supporting common application architecture patterns. 部分最常用的模式包括:Some of the most common include the following:

模式Pattern 说明Description
数据缓存Data cache 数据库通常很大,无法直接加载到缓存中。Databases are often too large to load directly into a cache. 通常是使用缓存端模式,只在需要时才将数据加载到缓存中。It is common to use the cache-aside pattern to load data into the cache only as needed. 系统对数据进行更改时,还会同时更新缓存,然后将缓存分发给其他客户端。When the system makes changes to the data, the system can also update the cache, which is then distributed to other clients. 另外,系统还可以设置数据的过期时间,或者使用逐出策略触发对缓存的数据更新。Additionally, the system can set an expiration on data, or use an eviction policy to trigger data updates into the cache.
内容缓存Content cache 许多网页都是基于使用静态内容(例如页眉、页脚、横幅)的模板生成的。Many web pages are generated from templates that use static content such as headers, footers, banners. 这些静态项不应经常更改。These static items shouldn't change often. 与后端数据存储相比,使用内存中缓存可以快速地访问静态内容。Using an in-memory cache provides quick access to static content compared to backend datastores. 此模式降低了处理时间和服务器负载,使 Web 服务器能够更快地做出响应。This pattern reduces processing time and server load, allowing web servers to be more responsive. 这可减少处理负载所需的服务器数量。It can allow you to reduce the number of servers needed to handle loads. Azure Cache for Redis 提供 Redis 输出缓存提供程序,支持对 ASP.NET 使用此模式。Azure Cache for Redis provides the Redis Output Cache Provider to support this pattern with ASP.NET.
会话存储Session store 此模式通常用于购物车和其他用户历史记录数据。Web 应用程序可能需要将此类信息与用户 Cookie 相关联。This pattern is commonly used with shopping carts and other user history data that a web application may want to associate with user cookies. 在 Cookie 中存储过多内容可能会对性能造成负面影响,因为 Cookie 会变大,并且每次请求都需要传递和验证 Cookie。Storing too much in a cookie can have a negative impact on performance as the cookie size grows and is passed and validated with every request. 常用解决方案是使用 Cookie 作为键来查询数据库中的数据。A typical solution uses the cookie as a key to query the data in a database. 使用内存中缓存(例如 Azure Redis 缓存)将信息与用户关联在速度上要比与整个关系数据库交互快得多。Using an in-memory cache, like Azure Cache for Redis, to associate information with a user is much faster than interacting with a full relational database.
作业和消息队列Job and message queuing 当需要花费时间来执行与请求相关联的操作时,应用程序通常将任务添加到队列中。Applications often add tasks to a queue when the operations associated with the request take time to execute. 长时间运行的操作将排队等待按顺序处理,通常由另一服务器进行处理。Longer running operations are queued to be processed in sequence, often by another server. 这种将工作推迟的方法称为任务队列。This method of deferring work is called task queuing. Azure Cache for Redis 提供了一个分布式队列,用以在应用程序中启用此模式。Azure Cache for Redis provides a distributed queue to enable this pattern in your application.
分布式事务Distributed transactions 有时候,应用程序需要将针对后端数据存储的一系列命令作为单个原子操作来执行。Applications sometimes require a series of commands against a backend data-store to execute as a single atomic operation. 所有命令都必须成功,否则,所有命令都必须回退到初始状态。All commands must succeed, or all must be rolled back to the initial state. Azure Cache for Redis 支持将一批命令作为单个事务来执行。Azure Cache for Redis supports executing a batch of commands as a single transaction.

Redis 版本Redis versions

Azure Cache for Redis 支持 OSS Redis 版本 4.x 和 6.0(预览版)。Azure Cache for Redis supports OSS Redis version 4.x and, as a preview, 6.0. 我们已决定跳过 Redis 5.0,为你提供最新版本。We've made the decision to skip Redis 5.0 to bring you the latest version. 以前,Azure Cache for Redis 仅维护一个 Redis 版本。Previously, Azure Cache for Redis only maintained a single Redis version. 以后,它将提供一个较新的主要版本升级,以及至少一个较旧的稳定版本。It will provide a newer major release upgrade and at least one older stable version going forward. 你可以选择最适合你的应用程序的版本You can choose which version works the best for your application.

服务层Service tiers

Azure Redis 缓存在下述层中提供:Azure Cache for Redis is available in the following tiers:

Tier 说明Description
基本Basic 在单个 VM 上运行的 OSS Redis 缓存。An OSS Redis cache running on a single VM. 该层没有服务级别协议 (SLA),非常适用于开发/测试和非关键工作负载。This tier has no service-level agreement (SLA) and is ideal for development/test and non-critical workloads.
StandardStandard 在配置完全相同的两个 VM 上运行的 OSS Redis 缓存。An OSS Redis cache running on two VMs in a replicated configuration.
高级Premium 高性能 OSS Redis 缓存。High-performance OSS Redis caches. 该层提供更高的吞吐量、更低的延迟、更好的可用性和更多功能。This tier offers higher throughput, lower latency, better availability, and more features. 与基本或标准缓存相比,高级缓存部署在功能更强大的 VM 上。Premium caches are deployed on more powerful VMs compared to those for Basic or Standard caches.
EnterpriseEnterprise 高性能缓存由 Redis 实验室的 Redis Enterprise 软件提供支持。High-performance caches powered by Redis Labs' Redis Enterprise software. 该层支持 Redis 模块,包括 RediSearch、RedisBloom 和 RedisTimeSeries。This tier supports Redis modules including RediSearch, RedisBloom, and RedisTimeSeries. 此外,它提供的可用性甚至比高级层的更高。In addition, it offers even higher availability than the Premium tier.
Enterprise FlashEnterprise Flash 经济高效的大型缓存由 Redis 实验室的 Redis Enterprise 软件提供支持。Cost-effective large caches powered by Redis Labs' Redis Enterprise software. 该层将 Redis 数据存储扩展到 VM 上的非易失存储器,该存储器的价格低于 DRAM 的价格。This tier extends Redis data storage to non-volatile memory, which is cheaper than DRAM, on a VM. 它总体上降低了每 GB 内存的成本。It reduces the overall per-GB memory cost.

功能比较Feature comparison

Azure Cache for Redis 定价提供了每个层的详细比较。The Azure Cache for Redis Pricing provides a detailed comparison of each tier. 下表介绍了每个层支持的部分功能:The following table helps describe some of the features supported by tier:

功能说明Feature Description 基本Basic StandardStandard 高级Premium EnterpriseEnterprise Enterprise FlashEnterprise Flash
服务级别协议 (SLA)Service Level Agreement (SLA) -
数据加密Data encryption
网络隔离Network isolation
缩放Scaling
OSS 群集OSS cluster - -
数据持久性Data persistence - - 预览Preview 预览Preview
模块Modules - - -
导入/导出Import/Export - -
计划的更新Scheduled updates - -

选择正确的层Choosing the right tier

选择 Azure Cache for Redis 层时,应考虑以下事项:You should consider the following when choosing an Azure Cache for Redis tier:

  • 内存:基本层和标准层提供 250 MB - 53 GB;高级层提供 6 GB - 1.2 TB;企业层提供 12 GB - 14 TB。Memory: The Basic and Standard tiers offer 250 MB - 53 GB; the Premium tier 6 GB - 1.2 TB; the Enterprise tiers 12 GB - 14 TB. 若要创建大于 120 GB 的高级层缓存,可使用 Redis OSS 群集。To create a Premium tier cache larger than 120 GB, you can use Redis OSS clustering. 有关详细信息,请参阅 Azure Redis 缓存定价For more information, see Azure Cache for Redis Pricing. 有关详细信息,请参阅如何为高级 Azure Redis 缓存配置群集功能For more information, see How to configure clustering for a Premium Azure Cache for Redis.
  • 性能:高级层和企业层中的缓存部署在处理器速度更快的硬件上,可提供比基本层或标准层更好的性能。Performance: Caches in the Premium and Enterprise tiers are deployed on hardware that has faster processors, giving better performance compared to the Basic or Standard tier. 高级级别缓存的吞吐量更高,延迟更低。Premium tier Caches have higher throughput and lower latencies. 有关详细信息,请参阅 Azure Cache for Redis 性能For more information, see Azure Cache for Redis performance.
  • 针对 Redis 服务器的专用核心:除 C0 之外的所有缓存均运行专用 VM 核心。Dedicated core for Redis server: All caches except C0 run dedicated VM cores. 根据设计,Redis 只使用一个线程进行命令处理。Redis, by design, uses only one thread for command processing. Azure Cache for Redis 利用其它核心进行 I/O 处理。Azure Cache for Redis utilizes additional cores for I/O processing. 拥有更多的内核可能不会产生线性缩放,但可提高吞吐量性能。Having more cores improves throughput performance even though it may not produce linear scaling. 而且,较大 VM 的带宽限制通常比较小 VM 的更高。Furthermore, larger VM sizes typically come with higher bandwidth limits than smaller ones. 这有助于避免网络饱和,从而避免应用程序超时。That helps you avoid network saturation, which will cause timeouts in your application.
  • 网络性能:如果工作负载需要较高的吞吐量,则可使用高级层或企业层,这两层可提供比基本层或标准层更高的带宽。Network performance: If you have a workload that requires high throughput, the Premium or Enterprise tier offers more bandwidth compared to Basic or Standard. 另外,在每个层中,缓存大小越大,带宽越高,因为是由基础 VM 托管缓存。Also within each tier, larger size caches have more bandwidth because of the underlying VM that hosts the cache. 有关详细信息,请参阅 Azure Cache for Redis 性能For more information, see Azure Cache for Redis performance.
  • 客户端连接的最大数量:高级级别提供的可以连接到 Redis 的客户端数量是最大的,缓存大小越大,连接数量越大。Maximum number of client connections: The Premium tier offers the maximum number of clients that can connect to Redis, with a higher number of connections for larger sized caches. 群集不会增加可用于群集缓存的连接数。Clustering does not increase the number of connections available for a clustered cache. 有关详细信息,请参阅 Azure Redis 缓存定价For more information, see Azure Cache for Redis pricing.
  • 高可用性:Azure Cache for Redis 提供了多个 高可用性选项。High availability: Azure Cache for Redis provides multiple high availability options. 它保证标准、高级或企业缓存的可用性符合我们的 SLAIt guarantees that a Standard, Premium, or Enterprise cache is available according to our SLA. SLA 仅涉及与缓存终结点的连接。The SLA only covers connectivity to the cache endpoints. SLA 不涉及对数据丢失的防护。The SLA does not cover protection from data loss. 我们建议使用高级层和企业层中的 Redis 数据暂留功能来提高复原能力,防止数据丢失。We recommend using the Redis data persistence feature in the Premium and Enterprise tiers to increase resiliency against data loss.
  • 数据暂留:高级层和企业层可用于分别在 Azure 存储账户和托管磁盘中暂留缓存数据。Data persistence: The Premium and Enterprise tiers allow you to persist the cache data to an Azure Storage account and a Managed Disk respectively. 底层基础结构问题可能会导致潜在的数据丢失。Underlying infrastructure issues might result in potential data loss. 我们建议使用这些层中的 Redis 数据暂留功能来提高复原能力,防止数据丢失。We recommend using the Redis data persistence feature in these tiers to increase resiliency against data loss. Azure Cache for Redis 同时提供 RDB 和 AOF(预览版)选项。Azure Cache for Redis offers both RDB and AOF (preview) options. 可通过 Azure 门户和 CLI 启用数据持久性。Data persistence can be enabled through Azure portal and CLI. 对于高级层,请参阅如何为高级 Azure Cache for Redis 配置暂留For the Premium tier, see How to configure persistence for a Premium Azure Cache for Redis.
  • 网络隔离:Azure 专用链接和虚拟网络 (VNET) 部署为 Azure Cache for Redis 提供增强的安全性和流量隔离。Network isolation: Azure Private Link and Virtual Network (VNET) deployments provide enhanced security and traffic isolation for your Azure Cache for Redis. 使用 VNET,可以进一步通过网络访问控制策略来限制访问。VNET allows you to further restrict access through network access control policies. 有关详细信息,请参阅如何为高级 Azure Cache for Redis 配置虚拟网络支持For more information, see How to configure Virtual Network support for a Premium Azure Cache for Redis.
  • 扩展性:企业层支持 RediSearchRedisBloomRedisTimeSeriesExtensibility: Enterprise tiers support RediSearch, RedisBloom and RedisTimeSeries. 这些模块向 Redis 添加了新的数据类型和功能。These modules add new data types and functionality to Redis.

创建缓存后,可以将其从基本层升级到高级层。You can scale your cache from the Basic tier up to Premium after it has been created. 目前不支持纵向缩放到更低的层。Scaling down to a lower tier is not supported currently. 有关缩放的分步说明,请参阅如何缩放 Azure Redis 缓存如何自动执行缩放操作For step-by-step scaling instructions, see How to Scale Azure Cache for Redis and How to automate a scaling operation.

企业层的特殊注意事项Special considerations for Enterprise tiers

企业层依赖于 Redis Enterprise,它是 Redis 实验室提供的商业版 Redis。The Enterprise tiers rely on Redis Enterprise, a commercial variant of Redis from Redis Labs. 客户将通过 Azure 市场产品/服务获取此软件的许可证并为其付费。Customers will obtain and pay for a license to this software through an Azure Marketplace offer. Azure Cache for Redis 将有助于获取许可证,使你无需单独执行此操作。Azure Cache for Redis will facilitate the license acquisition so that you won't have to do it separately. 若要在 Azure 市场中购买,必须具备以下先决条件:To purchase in the Azure Marketplace, you must have the following prerequisites:

  • Azure 订阅具有有效的付款方式。Your Azure subscription has a valid payment instrument. 不支持 Azure 额度或免费 MSDN 订阅。Azure credits or free MSDN subscriptions are not supported.
  • 如果你使用的是专用市场,它必须包含 Redis 实验室企业产品/服务。If you use a private Marketplace, it must contain the Redis Labs Enterprise offer.

重要

Azure Cache for Redis Enterprise 缓存需要标准网络负载均衡器,这些均衡器与缓存实例分开收费。Azure Cache for Redis Enterprise cache require standard network Load Balancers that are charged separately from cache instances themselves. 有关更多详细信息,请参阅负载均衡器定价Refer to the Load Balancer pricing for more details. 如果为多个可用性区域配置 Enterprise 缓存,则从 2021 年 7 月 1 日起,将按标准网络带宽费率对数据传输进行计费。If an Enterprise cache is configured for multiple Availability Zones, data transfer will be billed at the standard network bandwidth rates starting from July 1, 2021.

此外,数据持久性会添加托管磁盘。In addition, data persistence adds Managed Disks. 在企业数据持久性功能的公共预览版期间,可免费使用这些资源。The use of these resources will be free during the public preview of Enterprise data persistence. 该功能正式发布后,可能不再免费。This may change when the feature becomes generally available.

后续步骤Next steps