Azure Redis 缓存说明Azure Cache for Redis description

Azure Redis 缓存基于热门软件 RedisAzure Cache for Redis is based on the popular software Redis. 它通常用作缓存,目的是提高极其依赖后端数据存储的系统的性能和可伸缩性。It is typically used as a cache to improve the performance and scalability of systems that rely heavily on backend data-stores. 提高性能的方式是将经常访问的数据暂时复制到靠近应用程序的快速存储。Performance is improved by temporarily copying frequently accessed data to fast storage located close to the application. 使用 Azure Redis 缓存时,此快速存储位于 Azure Redis 缓存的内存中,而不是通过数据库从磁盘加载。With Azure Cache for Redis, this fast storage is located in-memory with Azure Cache for Redis instead of being loaded from disk by a database.

Azure Redis 缓存也可用作内存中数据结构存储、分布式非关系数据库以及消息代理。Azure Cache for Redis can also be used as an in-memory data structure store, a distributed non-relational database, and a message broker. 若要提高应用程序性能,可充分利用 Redis 引擎低延迟、高吞吐量的性能特点。Application performance is improved by taking advantage of the low-latency, high-throughput performance of the Redis engine.

Azure Redis 缓存提供了安全的专用 Redis 缓存。Azure Cache for Redis provides you access to a secure, dedicated Redis cache. Azure Redis 缓存由 Microsoft 进行管理并承载在 Azure 中,可供 Azure 内外的任何应用程序访问。Azure Cache for Redis is managed by Microsoft, hosted within Azure, and accessible to any application within or outside of Azure.

使用 Azure Redis 缓存Using Azure Cache for Redis

可以通过多种模式使用 Azure Redis 缓存来支持应用程序体系结构或提高应用程序性能。There are many common patterns where Azure Cache for Redis is used to support application architecture or to improve application performance. 部分最常用的模式包括:Some of the most common include the following:

模式Pattern 说明Description
缓存端Cache-Aside 由于数据库可能很大,因此不建议将整个数据库加载到缓存中。Since a database can be large, loading an entire database into a cache is not a recommended approach. 通常使用缓存端模式,只在需要时才将数据项加载到缓存中。It is common to use the cache-aside pattern to load data items into the cache only as needed. 系统在更改后端数据时,也会同时更新分布到其他客户端的缓存。When the system makes changes to the backend data, it can at that time also update the cache, which is distributed with other clients. 另外,系统还可以设置数据项的过期时间,或者通过逐出策略将数据更新重新加载到缓存中。Additionally, the system can set an expiration on data items, or use an eviction policy to cause data updates to be reloaded into the cache.
内容缓存Content Caching 大多数通过模板生成的网页会带有页眉、页脚、工具栏、菜单,等等。这些网页实际上不经常变化,不应以动态方式生成。Most web pages are generated from templates with headers, footers, toolbars, menus, etc. They don't actually change often and should not be generated dynamically. 与使用后端数据存储相比,使用内存中缓存(例如 Azure Redis 缓存)可以让 Web 服务器快速访问此类静态内容。Using an in-memory cache, like Azure Cache for Redis, will give your web servers quick access to this type of static content compared to backend datastores. 此模式可减少以动态方式生成内容所需的处理时间和服务器负荷。This pattern reduces processing time and server load that would be required to generate content dynamically. 这样可以提高 Web 服务器的响应能力,减少处理负荷所需的服务器数。This allows web servers to be more responsive, and can allow you to reduce the number of servers needed to handle loads. Azure Redis 缓存提供 Redis 输出缓存提供程序,支持对 ASP.NET 使用此模式。Azure Cache for Redis provides the Redis Output Cache Provider to help support this pattern with ASP.NET.
用户会话缓存User session caching 此模式通常用于购物车和其他用户历史记录类型的信息。Web 应用程序可能需要将此类信息与用户 Cookie 相关联。This pattern is commonly used with shopping carts and other user history type information 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 is to use the cookie as a key to query the data in a backend 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 当应用程序收到请求时,通常还需要额外的时间来执行与请求相关联的操作。When applications receive requests, often the operations associated with the request take additional time to execute. 通常会将运行时间较长的操作添加到队列中,留待以后处理(可能由其他服务器处理)。It is a common pattern to defer longer running operations by adding them to a queue, which is processed later, and possibly by another server. 这种将工作推迟的方法称为任务队列。This method of deferring work is called task queuing. 多种软件组件专用于提供任务队列支持。There are many software components designed to support task queues. Azure Redis 缓存也以分布式队列的方式提供此支持。Azure Cache for Redis also serves this purpose well as a distributed queue.
分布式事务Distributed transactions 通常会要求应用程序能够以单个操作(原子操作)的方式对后端数据存储执行一系列命令。It is a common requirement for applications to be able to execute a series of commands against a backend data-store as a single operation (atomic). 所有命令都必须成功,否则,所有命令都必须回退到初始状态。All commands must succeed, or all must be rolled back to the initial state. Azure Redis 缓存支持通过单个操作以事务形式执行一批命令。Azure Cache for Redis supports executing a batch of commands as a single operation in the form of Transactions.

Azure Redis 缓存的产品/服务Azure Cache for Redis offerings

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

Tier 说明Description
基本Basic 单节点缓存。A single node cache. 此层支持多种内存大小 (250 MB - 53 GB)。This tier supports multiple memory sizes (250 MB - 53 GB). 此层适用于开发/测试和非关键型工作负荷。This is an ideal tier for development/test and non-critical workloads. 基本层没有服务级别协议 (SLA)The Basic tier has no service-level agreement (SLA)
标准Standard 在 Microsoft 托管的双节点(主/辅)配置中提供复制的缓存,并提供高可用性 SLA (99.9%)A replicated cache in a two-node, primary/secondary, configuration managed by Microsoft, with a high-availability SLA (99.9%)
高级Premium 高级层是面向企业的层。The Premium tier is the Enterprise-ready tier. 高级层缓存支持更多的功能,吞吐量更高,延迟更低。Premium tier Caches support more features and have higher throughput with lower latencies. 高级层中的缓存部署在更强大的硬件上,其性能优于基本层或标准层。Caches in the Premium tier are deployed on more powerful hardware providing better performance compared to the Basic or Standard Tier. 这种优势意味着,在缓存大小相同的情况下,高级层的吞吐量大于标准层。This advantage means the throughput for a cache of the same size will be higher in Premium compared to Standard tier.

Tip

有关高级缓存大小、吞吐量和带宽的详细信息,请参阅 Azure Redis 缓存常见问题解答For more information about size, throughput, and bandwidth with premium caches, see Azure Cache for Redis FAQ.

可以在缓存创建以后将其提升到更高的层。You can scale your cache up to a higher tier after it has already been created. 不允许降到更低的层。Scaling down to a lower tier is not supported. 有关缩放的分步说明,请参阅如何缩放 Azure Redis 缓存如何自动执行缩放操作For step-by-step scaling instructions, see How to Scale Azure Cache for Redis and How to automate a scaling operation.

功能比较Feature comparison

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

功能说明Feature Description 高级Premium 标准Standard 基本Basic
服务级别协议 (SLA)Service Level Agreement (SLA) -
Redis 数据持久性Redis data persistence - -
Redis 群集Redis cluster - -
通过防火墙规则确保安全性Security via Firewall rules
传输中加密Encryption in transit
通过 VNet 增强安全性和隔离性Enhanced security and isolation with VNet - -
导入/导出Import/Export - -
计划的更新Scheduled updates
异地复制Geo-replication - -
重新启动Reboot

后续步骤Next steps