調整 Azure Cache for Redis 實例Scale an Azure Cache for Redis instance

「Azure Redis 快取」具有各種不同的快取供應項目,可讓您彈性選擇快取大小和功能。Azure Cache for Redis has different cache offerings, which provide flexibility in the choice of cache size and features. 針對基本、標準或高階快取,您可以在建立之後變更其大小和層級,以跟上您的應用程式需求。For a Basic, Standard or Premium cache, you can change its size and tier after it's been created to keep up with your application needs. 本文說明如何使用 Azure 入口網站和 Azure PowerShell 與 Azure CLI 之類的工具來調整快取。This article shows you how to scale your cache using the Azure portal, and tools such as Azure PowerShell, and Azure CLI.

調整時機When to scale

您可以使用「Azure Redis 快取」的監視功能來監視快取的健康情況和效能,並協助判斷調整快取規模的時機。You can use the monitoring features of Azure Cache for Redis to monitor the health and performance of your cache and help determine when to scale the cache.

您可以監視下列度量,以協助判斷是否需要調整。You can monitor the following metrics to help determine if you need to scale.

  • Redis 伺服器負載Redis Server Load
  • 記憶體使用量Memory Usage
  • 網路頻寬Network Bandwidth
  • CPU 使用量CPU Usage

如果您判斷快取不再符合您應用程式的需求,則可以調整為適合您應用程式的較大或較小快取定價層。If you determine that your cache is no longer meeting your application's requirements, you can scale to a larger or smaller cache pricing tier that is right for your application. 如需判斷要使用哪一個快取定價層的詳細資訊,請參閱 選擇正確的層級For more information on determining which cache pricing tier to use, see Choosing the right tier.

調整快取Scale a cache

若要調整快取,在 Azure 入口網站瀏覽至快取,然後按一下 [資源] 功能表中的 [調整]To scale your cache, browse to the cache in the Azure portal and click Scale from the Resource menu.

調整

從 [選取定價層] 刀鋒視窗中選取想要的定價層,然後按一下 [選取]。Select the desired pricing tier from the Select pricing tier blade and click Select.

定價層

您可以調整具有下列限制的不同定價層:You can scale to a different pricing tier with the following restrictions:

  • 您無法從較高的定價層調整至較低的定價層。You can't scale from a higher pricing tier to a lower pricing tier.
    • 您無法從 進階 快取向下調整至 標準基本 快取。You can't scale from a Premium cache down to a Standard or a Basic cache.
    • 您無法從 標準 快取向下調整到 基本 快取。You can't scale from a Standard cache down to a Basic cache.
  • 您可以從 基本 快取調整到 標準 快取,但您無法同時變更大小。You can scale from a Basic cache to a Standard cache but you can't change the size at the same time. 如果您需要不同的大小,您可以進行後續調整作業,調整到您需要的大小。If you need a different size, you can do a subsequent scaling operation to the desired size.
  • 您無法直接從 基本 快取調整至 進階 快取。You can't scale from a Basic cache directly to a Premium cache. 首先,在單一調整作業中從 基本 調整至 標準,然後在後續的調整作業中從 標準 調整至 進階First, scale from Basic to Standard in one scaling operation, and then from Standard to Premium in a subsequent scaling operation.
  • 您無法從較大的大小向下調整至 C0 (250 MB) 的大小。You can't scale from a larger size down to the C0 (250 MB) size. 不過,您可以在相同的定價層內縮小為任何其他大小。However, you can scale down to any other size within the same pricing tier. 例如,您可以從 C5 標準縮減為 C1 標準。For example, you can scale down from C5 Standard to C1 Standard.

當快取正在調整成新的定價層時,[Azure Redis 快取] 刀鋒視窗中會顯示[正在調整規模] 狀態。While the cache is scaling to the new pricing tier, a Scaling status is displayed in the Azure Cache for Redis blade.

擴縮

調整完成時,狀態會從 [正在調整] 變更為 [執行中]。When scaling is complete, the status changes from Scaling to Running.

如何自動化調整作業How to automate a scaling operation

除了在 Azure 入口網站中調整快取執行個體之外,您還可以使用 PowerShell Cmdlet、Azure CLI 以及使用 Microsoft Azure 管理庫 (MAML) 進行調整。In addition to scaling your cache instances in the Azure portal, you can scale using PowerShell cmdlets, Azure CLI, and by using the Microsoft Azure Management Libraries (MAML).

使用 PowerShell 進行調整Scale using PowerShell

注意

本文已更新為使用 Azure Az PowerShell 模組。This article has been updated to use the Azure Az PowerShell module. Az PowerShell 模組是用來與 Azure 互動的建議 PowerShell 模組。The Az PowerShell module is the recommended PowerShell module for interacting with Azure. 若要開始使用 Az PowerShell 模組,請參閱安裝 Azure PowerShellTo get started with the Az PowerShell module, see Install Azure PowerShell. 若要瞭解如何遷移至 Az PowerShell 模組,請參閱將 Azure PowerShell 從 AzureRM 遷移至 Az。To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

Size 修改、或屬性時,您可以使用 >set-azrediscache 指令程式,透過 PowerShell 調整您的 Azure Cache for Redis 實例 Sku ShardCountYou can scale your Azure Cache for Redis instances with PowerShell by using the Set-AzRedisCache cmdlet when the Size, Sku, or ShardCount properties are modified. 下列範例示範如何將名為 myCache 的快取調整為 2.5 GB 快取。The following example shows how to scale a cache named myCache to a 2.5 GB cache.

   Set-AzRedisCache -ResourceGroupName myGroup -Name myCache -Size 2.5GB

如需使用 PowerShell 進行調整的詳細資訊,請參閱 使用 powershell 調整 Azure Cache for RedisFor more information on scaling with PowerShell, see To scale an Azure Cache for Redis using PowerShell.

使用 Azure CLI 進行調整Scale using Azure CLI

若要使用 Azure CLI 來調整「Azure Redis 快取」執行個體的規模,請呼叫 azure rediscache set 命令,並視所需的調整作業而定,傳入所需的設定變更,包括新的大小、SKU 或叢集大小。To scale your Azure Cache for Redis instances using Azure CLI, call the azure rediscache set command and pass in the desired configuration changes that include a new size, sku, or cluster size, depending on the desired scaling operation.

如需有關如何使用 Azure CLI 來調整規模的詳細資訊,請參閱 變更現有 Azure Redis 快取的設定For more information on scaling with Azure CLI, see Change settings of an existing Azure Cache for Redis.

使用 MAML 進行調整Scale using MAML

若要使用 Microsoft Azure 管理庫 (MAML) 來調整您的「Azure Redis 快取」執行個體規模,請呼叫 IRedisOperations.CreateOrUpdate 方法並傳入 RedisProperties.SKU.Capacity 的新大小。To scale your Azure Cache for Redis instances using the Microsoft Azure Management Libraries (MAML), call the IRedisOperations.CreateOrUpdate method and pass in the new size for the RedisProperties.SKU.Capacity.

    static void Main(string[] args)
    {
        // For instructions on getting the access token, see
        // https://azure.microsoft.com/documentation/articles/cache-configure/#access-keys
        string token = GetAuthorizationHeader();

        TokenCloudCredentials creds = new TokenCloudCredentials(subscriptionId,token);

        RedisManagementClient client = new RedisManagementClient(creds);
        var redisProperties = new RedisProperties();

        // To scale, set a new size for the redisSKUCapacity parameter.
        redisProperties.Sku = new Sku(redisSKUName,redisSKUFamily,redisSKUCapacity);
        redisProperties.RedisVersion = redisVersion;
        var redisParams = new RedisCreateOrUpdateParameters(redisProperties, redisCacheRegion);
        client.Redis.CreateOrUpdate(resourceGroupName,cacheName, redisParams);
    }

如需詳細資訊,請參閱使用 MAML 來管理 Azure Redis 快取 (英文) 範例。For more information, see the Manage Azure Cache for Redis using MAML sample.

調整常見問題集Scaling FAQ

下列清單包含「Azure Redis 快取」規模調整相關常見問題的解答。The following list contains answers to commonly asked questions about Azure Cache for Redis scaling.

可以向上調整為 Premium 快取,或在其中調整、向下調整嗎?Can I scale to, from, or within a Premium cache?

  • 您無法從 進階 快取向下調整至 基本標準 定價層。You can't scale from a Premium cache down to a Basic or Standard pricing tier.

  • 您可以將一個 進階 快取定價層調整為另一個定價層。You can scale from one Premium cache pricing tier to another.

  • 您無法直接從 基本 快取調整至 進階 快取。You can't scale from a Basic cache directly to a Premium cache. 首先,在單一調整作業中從 基本 調整至 標準,然後在後續的調整作業中從 標準 調整至 進階First, scale from Basic to Standard in one scaling operation, and then from Standard to Premium in a subsequent scaling operation.

  • 如果在建立 進階 快取時已啟用叢集,您可以 變更叢集大小If you enabled clustering when you created your Premium cache, you can change the cluster size. 如果在建立快取時未啟用叢集,之後依然可以設定叢集。If your cache was created without clustering enabled, you can configure clustering at a later time.

    如需詳細資訊,請參閱 如何設定進階 Azure Redis 快取的叢集功能For more information, see How to configure clustering for a Premium Azure Cache for Redis.

調整之後,是否必須變更我的快取名稱或存取金鑰?After scaling, do I have to change my cache name or access keys?

否,在調整作業期間,您的快取名稱和金鑰不會變更。No, your cache name and keys are unchanged during a scaling operation.

調整運作方式如何?How does scaling work?

  • 基本 快取在調整為不同的大小時會關閉,並會使用新的大小佈建新的快取。When a Basic cache is scaled to a different size, it is shut down and a new cache is provisioned using the new size. 在此期間,快取無法使用,而且快取中的所有資料都會遺失。During this time, the cache is unavailable and all data in the cache is lost.
  • 基本 快取在調整為 標準 快取時,會佈建複本快取,且會從主要快取將資料複製到複本快取。When a Basic cache is scaled to a Standard cache, a replica cache is provisioned and the data is copied from the primary cache to the replica cache. 調整程序期間仍可使用快取。The cache remains available during the scaling process.
  • 標準 快取調整為 不同的大小 或高階快取時,其中一個複本會關閉並重新布建至新的大小和傳送的資料,然後另一個複本會在重新布建之前執行容錯移轉,類似于在其中一個快取節點失敗時所發生的處理常式。When a Standard cache is scaled to a different size or to a Premium cache, one of the replicas is shut down and reprovisioned to the new size and the data transferred over, and then the other replica performs a failover before it is reprovisioned, similar to the process that occurs during a failure of one of the cache nodes.

我是否會在調整期間遺失快取中的資料?Will I lose data from my cache during scaling?

  • 基本 快取調整為新的大小時,會遺失所有資料,且無法在調整作業期間使用快取。When a Basic cache is scaled to a new size, all data is lost and the cache is unavailable during the scaling operation.
  • 基本 快取調整為 標準 快取時,通常會保留快取中的資料。When a Basic cache is scaled to a Standard cache, the data in the cache is typically preserved.
  • 標準 快取調整為較大的大小或層,或者 進階 快取調整為較大的大小時,通常會保留所有資料。When a Standard cache is scaled to a larger size or tier, or a Premium cache is scaled to a larger size, all data is typically preserved. 標準進階 快取向下調整為較小大小時,根據調整時快取中與新大小相關的資料量,資料可能會遺失。When scaling a Standard or Premium cache down to a smaller size, data may be lost depending on how much data is in the cache related to the new size when it is scaled. 如果縮小時遺失資料,則會使用 allkeys-lru 收回原則來收回金鑰。If data is lost when scaling down, keys are evicted using the allkeys-lru eviction policy.

我的自訂資料庫設定在調整期間會受到影響嗎?Is my custom databases setting affected during scaling?

如果您在快取建立期間為 databases 設定設定了自訂值,請記住某些定價層具有不同的資料庫限制If you configured a custom value for the databases setting during cache creation, keep in mind that some pricing tiers have different databases limits. 以下是在此案例中進行調整時的一些考量:Here are some considerations when scaling in this scenario:

  • 調整為較現有階層具有較低 databases 限制的定價層時:When scaling to a pricing tier with a lower databases limit than the current tier:
    • 如果您使用預設數字 databases,即所有定價層為 16,則不會遺失資料。If you are using the default number of databases, which is 16 for all pricing tiers, no data is lost.
    • 如果您要使用的自訂數字 databases,落在您要調整之階層限制範圍內,則會保留此 databases 設定,並且不會遺失資料。If you are using a custom number of databases that falls within the limits for the tier to which you are scaling, this databases setting is retained and no data is lost.
    • 如果您要使用的自訂數字 databases,超出新階層的限制,則會將 databases 設定降低至新階層的限制,而且在已移除的資料庫中的所有資料都會遺失。If you are using a custom number of databases that exceeds the limits of the new tier, the databases setting is lowered to the limits of the new tier and all data in the removed databases is lost.
  • 調整為具有與現有階層相同或更高 databases 限制的定價層時,會保留您的 databases 設定,而且不會遺失資料。When scaling to a pricing tier with the same or higher databases limit than the current tier, your databases setting is retained and no data is lost.

標準和進階快取有 99.9% SLA 的可用性時,則資料遺失沒有 SLA。While Standard and Premium caches have a 99.9% SLA for availability, there is no SLA for data loss.

是否可以在調整期間使用我的快取?Will my cache be available during scaling?

  • 標準進階 快取在調整作業期間會保持可用。Standard and Premium caches remain available during the scaling operation. 不過,調整標準和進階快取時可能會發生連線中斷 (從基本調整至標準快取時也一樣)。However, connection blips can occur while scaling Standard and Premium caches, and also while scaling from Basic to Standard caches. 這些連線中斷應該很短暫,而且 Redis 用戶端應可立即重新建立其連線。These connection blips are expected to be small and redis clients should be able to re-establish their connection instantly.
  • 基本 快取在將作業調整至不同大小的期間,會處於離線狀態。Basic caches are offline during scaling operations to a different size. 基本 調整至 標準 時,基本快取仍可使用,但可能會遇到短暫的連線中斷。Basic caches remain available when scaling from Basic to Standard but, may experience a small connection blip. 若發生連線中斷,Redis 用戶端應可立即重新建立其連線。If a connection blip occurs, redis clients should be able to re-establish their connection instantly.

異地複寫的調整限制Scaling limitations with Geo-replication

一旦將異地複寫連結新增至兩個快取之間,您就無法再起始調整作業或變更叢集內的分區數目。Once you have added a Geo-replication link between two caches, you will no longer be able to initiate a scaling operation or change the number of shards in a cluster. 您必須將快取取消連結之後,才能發出這些命令。You must unlink the cache to issue these commands. 如需詳細資訊,請參閱 設定異地複寫For more information, see Configure Geo-replication.

不支援的作業Operations that are not supported

  • 您無法從較高的定價層調整至較低的定價層。You can't scale from a higher pricing tier to a lower pricing tier.
    • 您無法從 進階 快取向下調整至 標準基本 快取。You can't scale from a Premium cache down to a Standard or a Basic cache.
    • 您無法從 標準 快取向下調整到 基本 快取。You can't scale from a Standard cache down to a Basic cache.
  • 您可以從 基本 快取調整到 標準 快取,但您無法同時變更大小。You can scale from a Basic cache to a Standard cache but you can't change the size at the same time. 如果您需要不同的大小,您可以進行後續調整作業,調整到您需要的大小。If you need a different size, you can do a subsequent scaling operation to the desired size.
  • 您無法直接從 基本 快取調整至 進階 快取。You can't scale from a Basic cache directly to a Premium cache. 首先,在單一調整作業中從 基本 調整至 標準,然後在後續作業中從 標準 調整至 進階First scale from Basic to Standard in one scaling operation, and then scale from Standard to Premium in a subsequent operation.
  • 您無法從較大的大小向下調整至 C0 (250 MB) 的大小。You can't scale from a larger size down to the C0 (250 MB) size.

如果調整作業失敗,服務會嘗試還原作業,而且快取會還原成原始大小。If a scaling operation fails, the service tries to revert the operation, and the cache will revert to the original size.

調整需要多長的時間?How long does scaling take?

調整時間取決於快取中的資料量,較大量的資料需要較長的時間才能完成。Scaling time depends on how much data is in the cache, with larger amounts of data taking a longer time to complete. 調整大約需要20分鐘。Scaling takes approximately 20 minutes. 針對叢集快取,每個分區的調整花費大約20分鐘。For clustered caches, scaling takes approximately 20 minutes per shard.

如何分辨調整何時完成?How can I tell when scaling is complete?

在 Azure 入口網站中,您可以看到調整作業進行中。In the Azure portal, you can see the scaling operation in progress. 調整完成時,快取的狀態會變更為 [執行中] 。When scaling is complete, the status of the cache changes to Running.