针对高可用性设计应用程序Design your application for high availability

Azure Batch 是一项区域性服务。Azure Batch is a regional service. Batch 在所有 Azure 区域提供,但在创建 Batch 帐户时,必须将其与区域相关联。Batch is available in all Azure regions, but when a Batch account is created it must be associated with a region. 然后,Batch 帐户的所有操作会应用到该区域。All operations for the Batch account then apply to that region. 例如,池和关联的虚拟机 (VM) 在 Batch 帐户所在的区域中创建。For example, pools and associated virtual machines (VMs) are created in the same region as the Batch account.

设计使用 Batch 的应用程序时,必须考虑到 Batch 在某个区域不可用的可能性。When designing an application that uses Batch, you must consider the possibility of Batch not being available in a region. 可能会遇到罕见的情况,即:整个区域出现问题、区域中的整个 Batch 服务出现问题,或者特定 Batch 帐户出现问题。It's possible to encounter a rare situation where there is a problem with the region as a whole, the entire Batch service in the region, or a problem with your specific Batch account.

如果使用 Batch 的应用程序或解决方案必须始终可用,则应将其设计为可以故障转移到另一区域,或者始终在两个或更多个区域之间拆分工作负荷。If the application or solution using Batch always needs to be available, then it should be designed to either failover to another region or always have the workload split between two or more regions. 两种方法都需要至少两个 Batch 帐户,每个帐户位于不同的区域中。Both approaches require at least two Batch accounts, with each account located in a different region.

多个 Batch 帐户位于多个区域中Multiple Batch accounts in multiple regions

在不同的区域中使用多个 Batch 帐户时,应用程序可以在另一区域的某个 Batch 帐户变得不可用时继续运行。Using multiple Batch accounts in various regions provides the ability for your application to continue running if a Batch account in another region becomes unavailable. 如果应用程序必须高度可用,则使用多个帐户尤其重要。Using multiple accounts is especially important if your application needs to be highly available.

在某些情况下,可能会将应用程序设计成始终使用两个或更多个区域。In some cases, an application may be designed to always use two or more regions. 例如,在需要的容量相当大时,则可能需要使用多个区域,以应对出现大型应用程序或者将来出现增长的情况。For example, when you need a considerable amount of capacity, using multiple regions may be needed to handle either a large-scale application or cater for future growth.

有关如何提供故障转移的设计注意事项Design considerations for providing failover

在提供故障转移到备用区域的功能时,需要考虑的要点是:解决方案中的所有组件都必须考虑;不能直接设置另一个 Batch 帐户。A key point to consider when providing the ability to failover to an alternate region is that all components in a solution need to be considered; it is not sufficient to simply have a second Batch account. 例如,在大多数 Batch 应用程序中,需要一个 Azure 存储帐户,而存储帐户和 Batch 帐户需要位于同一区域中,这样才能获得可以接受的性能。For example, in most Batch applications, an Azure storage account is required, with the storage account and Batch account needing to be in the same region for acceptable performance.

设计可以故障转移的解决方案时,请注意以下几点:Consider the following points when designing a solution that can failover:

  • 在每个区域预先创建所有必需的帐户,例如 Batch 帐户和存储帐户。Pre-create all required accounts in each region, such as the Batch account and storage account. 创建帐户通常不收费,只有在存储数据或使用帐户的时候才收费。There often is not any charge for having accounts created, only when there is data stored or the account is used.
  • 确保提前设置帐户的配额,这样就能够使用 Batch 帐户分配必需的核心数。Make sure quotas are set on the accounts ahead of time, so you can allocate the required number of cores using the Batch account.
  • 使用模板和/或脚本在区域中自动部署应用程序。Use templates and/or scripts to automate the deployment of the application in a region.
  • 始终更新所有区域中的应用程序二进制文件和引用数据。Keep application binaries and reference data up-to-date in all regions. 保持更新可确保将区域快速联机,不需等待文件的上传和部署。Staying up-to-date will ensure the region can be brought online quickly without having to wait for the upload and deployment of files. 例如,如果使用 Batch 应用程序包来存储和引用需安装在池节点中的自定义应用程序,则在生成新版应用程序后,应将其上传到每个 Batch 帐户并通过池配置对其进行引用(或者使新版本成为默认版本)。For example, if a custom application to install on pool nodes is stored and referenced using Batch application packages, then when a new version of the application is produced, it should be uploaded to each Batch account and referenced by the pool configuration (or make the new version the default version).
  • 在调用 Batch、存储以及任何其他服务的应用程序中,轻松地将客户端或负载切换到另一区域。In the application calling Batch, storage, and any other services, easily switchover clients or the load to the different region.
  • 若要确保故障转移成功,最佳做法是在进行正常操作时频繁地切换到备用区域。A best practice to ensure a failover will be successful is to frequently switchover to an alternate region as part of normal operation. 例如,如果两个部署位于不同的区域,则每月切换到备用区域一次。For example, with two deployments in separate regions, switchover to the alternate region every month.

后续步骤Next steps