根據一天中 Azure 時間 DNS 回應雲端伺服器的應用程式DNS Responses Based on Time of Day with an Azure Cloud App Server

適用於:Windows Server(以每年次管道)、Windows Server 2016Applies To: Windows Server (Semi-Annual Channel), Windows Server 2016

您可以使用本主題以了解如何在應用程式的流量分配,使用 DNS 原則一天的時間為基礎的應用程式的不同分散執行個體。You can use this topic to learn how to distribute application traffic across different geographically distributed instances of an application by using DNS policies that are based on the time of day.

本案例可用於您想来直接傳輸到其他應用程式的伺服器,例如網頁伺服器裝載 Microsoft Azure、上位於其他時區時區中的位置。This scenario is useful in situations where you want to direct traffic in one time zone to alternate application servers, such as Web servers that are hosted on Microsoft Azure, that are located in another time zone. 這可讓您在應用程式執行個體的山峰載入餘額流量主要伺服器資料傳輸多載句點這樣的時間。This allows you to load balance traffic across application instances during peak time periods when your primary servers are overloaded with traffic.

注意

若要了解如何使用的智慧型 DNS 回應 DNS 原則,不使用 Azure,請查看使用 DNS 原則智慧 DNS 回應根據一天的時間在To learn how to use DNS policy for intelligent DNS responses without using Azure, see Use DNS Policy for Intelligent DNS Responses Based on the Time of Day.

根據一天的 Azure 雲端應用程式伺服器的時間智慧 DNS 回應的範例Example of Intelligent DNS Responses Based on the Time of Day with Azure Cloud App Server

以下是如何使用 DNS 原則,以根據一天的時間餘額應用程式流量的範例。Following is an example of how you can use DNS policy to balance application traffic based on the time of day.

此範例中使用一虛構家公司,以 Contoso 禮品服務,透過他們的網站,contosogiftservices.com 全球提供 online 贈送方案。This example uses one fictional company, Contoso Gift Services, which provides online gifting solutions across the globe through their Web site, contosogiftservices.com.

只有在單一先 datacenter(的公用 IP 192.68.30.2) 西雅圖裝載 contosogiftservices.com 網站。The contosogiftservices.com web site is hosted only at a single on-premises datacenter in Seattle (with public IP 192.68.30.2).

先 datacenter 也位於 DNS 伺服器。The DNS server is also located in the on-premises datacenter.

在商務用最近突波,contosogiftservices.com 已經有更多的訪客每日,針對部分服務的可用性問題報告。With a recent surge in business, contosogiftservices.com has a higher number of visitors every day, and some of the customers have reported service availability issues.

Contoso 禮品服務執行網站分析,並探索之間 6 PM 和 9 PM 本地時間每個夜晚突波中已資料傳輸到西雅圖網頁伺服器。Contoso Gift Services performs a site analysis, and discovers that every evening between 6 PM and 9 PM local time, there is a surge in the traffic to the Seattle Web server. Web 伺服器無法縮放處理流量增加在這些山峰的時數,導致阻斷服務來針對。The Web server cannot scale to handle the increased traffic at these peak hours, resulting in denial of service to customers.

若要確保 contosogiftservices.com 針對從網站取得回應式的經驗,以 Contoso 禮品服務決定期間時段它將會租借 virtual 電腦 (VM) Microsoft Azure 裝載一份其網頁伺服器上。To ensure that contosogiftservices.com customers get a responsive experience from the Web site, Contoso Gift Services decides that during these hours it will rent a virtual machine (VM) on Microsoft Azure to host a copy of its Web server.

Contoso 禮品服務取得 VM (192.68.31.44 從 Azure 公用 IP 位址)並開發自動化部署網頁伺服器每日 Azure 上之間 5-10 PM,允許一個意外小時。Contoso Gift Services gets a public IP address from Azure for the VM (192.68.31.44) and develops the automation to deploy the Web Server every day on Azure between 5-10 PM, allowing for a one hour contingency period.

注意

如需 Azure Vm 的詳細資訊,請查看電腦虛擬文件For more information about Azure VMs, see Virtual Machines documentation

這樣的查詢 30%傳送到執行 Azure 中的網頁伺服器的執行個體之間 5-9 下午每日,區域範圍和 DNS 原則設定的 DNS 伺服器。The DNS servers are configured with zone scopes and DNS policies so that between 5-9 PM every day, 30% of queries are sent to the instance of the Web server that is running in Azure.

下圖描述此案例。The following illustration depicts this scenario.

回應天的時間 DNS 原則

如何智慧 DNS 回應根據一天 Azure 與的時間伺服器的應用程式的運作方式How Intelligent DNS Responses Based on Time of Day with Azure App Server Works

這篇文章示範如何設定將會解答 DNS 查詢具有兩個不同的應用程式伺服器 IP 位址的 DNS 伺服器一個網頁伺服器是西雅圖,以及另一個是在 Azure 資料中心。This article demonstrates how to configure the DNS server to answer DNS queries with two different application server IP addresses - one web server is in Seattle and the other is in an Azure datacenter.

新的 DNS 原則尖峰的 6 至 9 下午西雅圖為基礎的設定之後, DNS 伺服器會傳送 seventy 每一分戶端包含西雅圖網頁伺服器的 IP 位址的 DNS 回應的和通知三十每一分的 DNS 回應戶端包含 Azure 網頁伺服器的 IP 位址藉此引導 client 資料傳輸到新的 Azure Web 伺服器,並負荷防止西雅圖網頁伺服器。After the configuration of a new DNS policy that is based on the peak hours of 6 PM to 9 PM in Seattle, the DNS server sends seventy per cent of the DNS responses to clients containing the IP address of the Seattle Web server, and thirty per cent of the DNS responses to clients containing the IP address of the Azure Web server, thereby directing client traffic to the new Azure Web server, and preventing the Seattle Web server from becoming overloaded.

其他時候,天的一般查詢處理程序發生,並且包含記錄網頁伺服器上場所 datacenter 中的預設區域領域從傳送回覆。At all other times of day, the normal query processing takes place and responses are sent from default zone scope which contains a record for the web server in the on-premises datacenter.

在 Azure 記錄 10 分鐘 TTL 可確保記錄已過期從 LDNS 快取 Azure 從移除 VM 之前。The TTL of 10 minutes on the Azure record ensures that the record is expired from the LDNS cache before the VM is removed from Azure. 其中一個優點這類縮放比例是您可以讓您 DNS 資料先,並保留縮放比例出 Azure 需要要求。One of the benefits of such scaling is that you can keep your DNS data on-premises, and keep scaling out to Azure as demand requires.

如何設定智慧 DNS 回應根據一天 Azure 的 App 伺服器的時間 DNS 原則How to Configure DNS Policy for Intelligent DNS Responses Based on Time of Day with Azure App Server

若要設定時間的一天應用程式負載平衡查詢回應 DNS 原則,您必須執行下列步驟。To configure DNS policy for time of day application load balancing based query responses, you must perform the following steps.

注意

您必須是針對您想要設定的區域授權的 DNS 伺服器上執行這些步驟。You must perform these steps on the DNS server that is authoritative for the zone you want to configure. 資格 DnsAdmins,或等,才能執行下列程序。Membership in DnsAdmins, or equivalent, is required to perform the following procedures.

下列章節提供詳細的設定指示操作。The following sections provide detailed configuration instructions.

重要

以下的各節包含包含許多參數值範例範例 Windows PowerShell 命令。The following sections include example Windows PowerShell commands that contain example values for many parameters. 請確認值是適用於您的部署,執行下列命令之前,先取代範例值這些命令列中。Ensure that you replace example values in these commands with values that are appropriate for your deployment before you run these commands.

建立區域範圍Create the Zone Scopes

時區領域是區域的唯一執行個體。A zone scope is a unique instance of the zone. DNS 區域可以有多個區域領域,與每個包含 DNS 記錄它自己設定的區域範圍。A DNS zone can have multiple zone scopes, with each zone scope containing its own set of DNS records. 相同記錄可能會出現在多個領域,以不同的 IP 位址或相同的 IP 位址。The same record can be present in multiple scopes, with different IP addresses or the same IP addresses.

注意

根據預設,區域領域存在於 DNS 區域。By default, a zone scope exists on the DNS zones. 這個區域領域作為區域,具有相同的名稱,並在這個領域中工作舊版 DNS 作業。This zone scope has the same name as the zone, and legacy DNS operations work on this scope.

您可以使用下列命令範例建立裝載 Azure 記錄領域區域。You can use the following example command to create a zone scope to host the Azure records.

Add-DnsServerZoneScope -ZoneName "contosogiftservices.com" -Name "AzureZoneScope"

如需詳細資訊,請查看新增-DnsServerZoneScopeFor more information, see Add-DnsServerZoneScope

若要的區域領域加入資料Add Records to the Zone Scopes

下一個步驟是加入到區域領域代表網頁伺服器主機資料。The next step is to add the records representing the Web server host into the zone scopes.

AzureZoneScope,記錄 www.contosogiftservices.com 已新增的 IP 位址 192.68.31.44,在公用 Azure 雲端中。In AzureZoneScope, the record www.contosogiftservices.com is added with IP address 192.68.31.44, which is located in the Azure public cloud.

同樣地,在 [預設區域範圍 (contosogiftservices.com),記錄 (www.contosogiftservices.com) 會執行西雅圖先 datacenter 中的網頁伺服器的 IP 位址 192.68.30.2 加入。Similarly, in the default zone scope (contosogiftservices.com), a record (www.contosogiftservices.com) is added with IP address 192.68.30.2 of the Web server running in the Seattle on-premises datacenter.

在第二個下列 cmdlet,不包含 – ZoneScope 參數。In the second cmdlet below, the –ZoneScope parameter is not included. 因此,記錄加入 ZoneScope 預設值。Because of this, the records are added in the default ZoneScope.

此外,Azure Vm 的記錄 TTL 會保留在 600s(10 分鐘),以便 LDNS 不要快取它較長的時間-干擾負載平衡。In addition, the TTL of the record for Azure VMs is kept at 600s (10 mins) so that the LDNS do not cache it for a longer time - which would interfere with load balancing. 此外,Azure Vm 可確保的快取記錄甚至戶端無法解析應變額外 1 小時的。Also, the Azure VMs are available for 1 extra hour as a contingency to ensure that even clients with cached records are able to resolve.

Add-DnsServerResourceRecord -ZoneName "contosogiftservices.com" -A -Name "www" -IPv4Address "192.68.31.44" -ZoneScope "AzureZoneScope" –TimeToLive 600

Add-DnsServerResourceRecord -ZoneName "contosogiftservices.com" -A -Name "www" -IPv4Address "192.68.30.2"

如需詳細資訊,請查看新增-DnsServerResourceRecordFor more information, see Add-DnsServerResourceRecord.

建立 DNS 原則Create the DNS Policies

建立區域範圍之後,您可以建立 DNS 原則,連入查詢分配這些範圍,下列,就會發生。After the zone scopes are created, you can create DNS policies that distribute the incoming queries across these scopes so that the following occurs.

  1. 下午 6 至 9 PM 每天,從的用 30%時,收到網頁伺服器的 IP 位址 DNS 因應日光 Azure 資料中心中的用 70%收到西雅圖先網頁伺服器的 IP 位址。From 6 PM to 9 PM daily, 30% of clients receive the IP address of the Web server in the Azure datacenter in the DNS response, while 70% of clients receive the IP address of the Seattle on-premises Web server.
  2. 其他時候,用所有戶端都收到西雅圖先網頁伺服器的 IP 位址。At all other times, all the clients receive the IP address of the Seattle on-premises Web server.

必須以當地的 DNS 伺服器的時間來表示一天的時間。The time of the day has to be expressed in local time of the DNS server.

若要建立的 DNS 原則,您可以使用下列命令範例。You can use the following example command to create the DNS policy.

Add-DnsServerQueryResolutionPolicy -Name "Contoso6To9Policy" -Action ALLOW –-ZoneScope "contosogiftservices.com,7;AzureZoneScope,3" –TimeOfDay “EQ,18:00-21:00” -ZoneName "contosogiftservices.com" –ProcessingOrder 1

如需詳細資訊,請查看新增-DnsServerQueryResolutionPolicyFor more information, see Add-DnsServerQueryResolutionPolicy.

立即所需的 DNS 原則,將根據一天的時間伺服器 Azure 網路流量被設定 DNS 伺服器。Now the DNS server is configured with the required DNS policies to redirect traffic to the Azure Web server based on time of day.

請注意運算式:Note the expression:

-ZoneScope "contosogiftservices.com,7;AzureZoneScope,3" –TimeOfDay “EQ,18:00-21:00”

這個運算式 ZoneScope 和減重組合指示 DNS 伺服器的時間,而傳送 Azure 網頁伺服器的 IP 位址的時間通知三十每一分 seventy 每一分傳送西雅圖網頁伺服器的 IP 位址設定 DNS 伺服器。This expression configures the DNS server with a ZoneScope and weight combination that instructs the DNS server to send the IP address of the Seattle Web server seventy per cent of the time, while sending the IP address of the Azure Web server thirty per cent of the time.

您可以建立數千 DNS 原則根據您的資料傳輸管理的需求,且所有的新原則已經套用動態-不需要重新 DNS 伺服器-連入查詢。You can create thousands of DNS policies according to your traffic management requirements, and all new policies are applied dynamically - without restarting the DNS server - on incoming queries.