Azure Batch 的成本分析和预算Cost analysis and budgets for Azure Batch

Azure Batch 本身不会产生任何费用,而只有用于运行 Batch 工作负荷的底层计算资源和软件授权才产生费用。There's no charge for Azure Batch itself, only the underlying compute resources and software licenses used to run Batch workloads. 从较高层面讲,成本是由池中的虚拟机 (VM)、从 VM 进行的数据传输,或云中存储的任何输入或输出数据产生的。On a high level, costs are incurred from virtual machines (VMs) in a pool, data transfer from the VM, or any input or output data stored in the cloud. 让我们看一下 Batch 的一些关键组件,以了解成本的起源、如何针对池或帐户设置预算,以及使 Batch 工作负荷更具成本效益的一些方法。Let's take a look at some key components of Batch to understand where costs come from, how to set a budget for a pool or account, and some techniques for making your Batch workloads more cost efficient.

Batch 资源Batch resources

虚拟机是用于 Batch 处理的最重要资源。Virtual machines are the most significant resource used for Batch processing. Batch 中的 VM 使用成本是根据类型、数量和使用持续时间计算的。The cost of using VMs for Batch is calculated based on the type, quantity, and the duration of use. VM 计费选项包括预付费(提前支付)。VM billing options include Pay-In-Advanced (pay in advance). 这两个支付选项根据计算工作负荷而各有优势,这两种支付模式将对帐单产生不同的影响。Both payment options have different benefits depending on your compute workload, and both payment models will affect your bill differently.

如果使用应用程序包将应用程序部署到 Batch 节点 (VM),系统还会对应用程序包使用的 Azure 存储资源收费。When applications are deployed to Batch nodes (VMs) using application packages, you are billed for the Azure Storage resources that your application packages consume. 你还要支付任何输入或输出文件(例如资源文件和其他日志数据)的存储费。You are also billed for the storage of any input or output files, such as resource files and other log data. 一般情况下,与 Batch 关联的存储数据成本远远低于计算资源的成本。In general, the cost of storage data associated with Batch is much lower than the cost of compute resources. 使用 VirtualMachineConfiguration 在池中创建的每个 VM 都有一个使用 Azure 托管磁盘的关联 OS 磁盘。Each VM in a pool created with VirtualMachineConfiguration has an associated OS disk that uses Azure-managed disks. Azure 托管磁盘会产生额外的成本,其他磁盘性能层也有不同的成本。Azure-managed disks have an additional cost, and other disk performance tiers have different costs as well.

Batch 池使用网络资源。Batch pools use networking resources. 具体而言,对于 VirtualMachineConfiguration 池,将使用标准负载均衡器,这需要配置静态 IP 地址。In particular, for VirtualMachineConfiguration pools standard load balancers are used, which require static IP addresses. Batch 使用的负载均衡器对用户订阅帐户可见,但对 Batch 服务帐户不可见。The load balancers used by Batch are visible for User Subscription accounts, but are not visible for Batch Service accounts. 传入和传出 Batch 池 VM 的所有数据会产生标准负载均衡器费用;从池节点检索数据的某些 Batch API(例如“获取任务/节点文件”)、任务应用程序包、资源/输出文件和容器映像会产生费用。Standard load balancers incur charges for all data passed to and from Batch pool VMs; select Batch APIs that retrieve data from pool nodes (such as Get Task/Node File), task application packages, resource/output files, and container images will incur charges.

其他服务Additional services

不包含 VM 和存储的服务可能会影响 Batch 帐户的成本。Services not including VMs and storage can factor in to the cost of your Batch account.

经常与 Batch 配合使用的其他服务可能包括:Other services commonly used with Batch can include:

  • Application InsightsApplication Insights
  • Data FactoryData Factory
  • Azure MonitorAzure Monitor
  • 虚拟网络Virtual Network
  • 包含图形应用程序的 VMVMs with graphics applications

根据在 Batch 解决方案中使用的服务,可能会产生额外的费用。Depending on which services you use with your Batch solution, you may incur additional fees. 请参阅定价计算器来确定每个附加服务的成本。Refer to the Pricing Calculator to determine the cost of each additional service.

池的成本分析和预算Cost analysis and budget for a pool

通过 Azure 门户可以针对 Batch 池或 Batch 帐户创建预算和支出警报。Through the Azure portal, you can create budgets and spending alerts for your Batch pool(s) or Batch account. 存在任何透支风险时,预算和警报可用于通知利益干系人。Budgets and alerts are useful for notifying stakeholders of any risks of overspending. 支出警报可能会有所延迟,并可能存在略微超出预算的情况。It's possible for there to be a delay in spending alerts and to slightly exceed a budget. 在本示例中,我们将查看单个 Batch 池的成本分析。In this example, we'll view cost analysis of an individual Batch pool.

  1. 在 Azure 门户的左侧导航栏中,选择“成本管理 + 计费”。In the Azure portal, select Cost Management + Billing from the left navigation bar.
  2. 在“我的订阅”部分选择你的订阅。Select your subscription from the My subscriptions section
  3. 转到左侧导航栏中“成本管理”部分下的“成本分析”,此时会显示如下所示的视图: Go to Cost analysis under the Cost Management section of the left nav bar, which will show a view like this:
  4. 选择“添加筛选器”。Select Add Filter. 在第一个下拉列表中选择“资源”。选择资源筛选器In the first drop-down, select Resource Select the resource filter
  5. 在第二个下拉列表中选择 Batch 池。In the second drop-down, select the Batch pool. 选择池后,成本分析将类似于以下分析。When the pool is selected, the cost analysis will look similar to the following analysis. 池的成本分析Cost analysis of a pool

生成的成本分析将显示此成本涉及的池和资源的成本。The resulting cost analysis shows the cost of the pool as well as the resources that contribute to this cost. 在本示例中,池中使用的 VM 是成本最高的资源。In this example, the VMs used in the pool are the most costly resource.

若要为池创建预算,请依次选择“预算: 无”、“创建新预算 >”。 To create a budget for the pool select Budget: none, and then select Create new budget >. 现在,使用窗口专门为池配置预算。Now use the window to configure a budget specifically for your pool.


Azure Batch 构建在 Azure 云服务和 Azure 虚拟机技术基础之上。Azure Batch is built on Azure Cloud Services and Azure Virtual Machines technology. 如果选择了“云服务配置”,则要根据云服务定价结构付费。When you choose Cloud Services Configuration, you are charged based on the Cloud Services pricing structure. 如果选择了“虚拟机配置”,则要根据虚拟机定价结构付费。When you choose Virtual Machine Configuration, you are charged based on the Virtual Machines pricing structure. 此页上的示例使用“虚拟机配置”。The example on this page uses the Virtual Machine Configuration.

尽量降低成本Minimize cost

长时间使用多个 VM 和 Azure 服务可能会产生很高的成本。Using several VMs and Azure services for extended periods of time can be costly. 幸运的是,可以借助某些服务来降低支出,并可以使用某些策略来最大程度地提高工作负荷的效率。Fortunately, there are services available to help reduce your spending, as well as strategies for maximizing the efficiency of your workload.

低优先级虚拟机Low-priority virtual machines

低优先级 VM 利用 Azure 中的盈余计算容量来降低 Batch 工作负荷的成本。Low-priority VMs reduce the cost of Batch workloads by taking advantage of surplus computing capacity in Azure. 在池中指定低优先级 VM 时,Batch 将使用此盈余容量来运行工作负荷。When you specify low-priority VMs in your pools, Batch uses this surplus to run your workload. 使用低优先级 VM 代替专用 VM 可以大幅节省成本。There is a substantial cost saving by using low-priority VMs in place of dedicated VMs.

在 Batch 中使用低优先级 VM 详细介绍了如何为工作负荷设置低优先级 VM。Learn more about how to set up low-priority VMs for your workload at Use low-priority VMs with Batch.

虚拟机 OS 磁盘类型Virtual machine OS disk type

有多种 VM OS 磁盘类型There are multiple VM OS disk types. 大多数 VM 系列大小都支持高级和标准存储。Most VM-series have sizes that support both premium and standard storage. 为池选择“s”VM 大小时,Batch 会配置高级 SSD OS 磁盘。When an 's' VM size is selected for a pool, Batch configures premium SSD OS disks. 选择“非 s”VM 大小时,会使用更经济的标准 HDD 磁盘类型。When the 'non-s' VM size is selected, then the cheaper, standard HDD disk type is used. 例如,将高级 SSD OS 磁盘用于 Standard_D2s_v3,将标准 HDD OS 磁盘用于 Standard_D2_v3For example, premium SSD OS disks are used for Standard_D2s_v3 and standard HDD OS disks are used for Standard_D2_v3.

高级 SSD OS 磁盘的成本更高,但性能更高;使用高级磁盘的 VM 的启动速度比使用标准 HDD OS 磁盘的 VM 略快一些。Premium SSD OS disks are more expensive, but have higher performance and VMs with premium disks can start slightly quicker than VMs with standard HDD OS disks. 在 Batch 中,OS 磁盘通常不会频繁使用,因为应用程序和任务文件位于 VM 的临时 SSD 磁盘中。With Batch, the OS disk is often not used much as the applications and task files are located on the VMs temporary SSD disk. 因此,在许多情况下,如果指定了“s”VM 大小,则无需为预配的高级 SSD 支付更高的费用。Therefore in many cases, there's no need to pay the increased cost for the premium SSD that is provisioned when a 's' VM size is specified.

自动缩放Automatic scaling

自动缩放根据当前作业的需求动态缩放 Batch 池中的 VM 数量。Automatic scaling dynamically scales the number of VMs in your Batch pool based on demands of the current job. 自动缩放根据作业的生存期缩放池,确保仅在需要执行某个作业时,才扩展和使用 VM。By scaling the pool based on the lifetime of a job, automatic scaling ensures that VMs scaled up and used only when there is a job to perform. 如果该作业已完成或者没有任何作业,则 VM 会自动缩减以节省计算资源。When the job is complete, or there are no jobs, the VMs are automatically scaled down to save compute resources. 缩放可让你仅使用所需的资源,从而降低 Batch 解决方案的总体成本。Scaling allows you to lower the overall cost of your Batch solution by using only the resources you need.

有关自动缩放的详细信息,请参阅自动缩放 Azure Batch 池中的计算节点For more information about automatic scaling, see Automatically scale compute nodes in an Azure Batch pool.

后续步骤Next steps