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 计费选项包括标准预付费套餐MSDN 订阅 Azure 权益套餐VM billing options include Standard Pay-in-Advance Offer or MSDN Subscriptions Azure Benefit Offer. 这两种支付选项的优势因计算工作负荷而异,而且这两种付款模型对帐单的影响也不同。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

在计算 Batch 帐户的成本时,可能需要考虑不包括 VM 和存储的服务这一因素。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 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.

最大限度地降低成本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.

虚拟机 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