This document explains the behavior, restrictions, and billing of placement policies.
By default, you manage the location of your virtual machine (VM) instances only by specifying their zones. Placement policies let you further specify the relative placement of VMs within a zone. Using a placement policy can help reduce network latency across VMs ( compact policy) or improve resiliency against location-specific disruptions ( spread policy).
To learn how create and apply placement policies, see the documentation for using compact placement policies and using spread placement policies .
To learn about other ways of controlling VM placement, see the documentation for sole-tenancy and regional managed instance groups (MIGs) .
About placement policies
Each VM runs on a physical server—a host —that is on a server rack. Each server rack is part of a cluster that is located in a data center for a zone. When you have multiple VMs in the same zone, Compute Engine places these VMs in different hosts by default. This minimizes the impact of potential power failures. However, when you apply a placement policy to VMs in the same zone, you can further control the relative locations of those VMs within the zone based on the needs of your workload.
You can create the following types of placement policies:
-
Compact placement policy. This policy places VMs close to each other within a zone, which reduces network latency among the VMs. This is helpful when your VMs need to communicate often among each other—for example, when running high performance computing (HPC), machine learning (ML), or database server workloads.
To learn more, see About compact placement policies in this document.
-
Spread placement policy. This policy places VMs on separate, distinct hardware, which you can use to increase your workload's reliability. Specifically, spreading VMs helps reduce the number of VMs that are simultaneously impacted by location-specific disruptions, such as hardware errors. Additionally, if you use a spread placement policy to overprovision capacity in multiple locations , you can help ensure that you still have sufficient capacity even when one location is disrupted. For this reason, spread placement policies can also be helpful for large-scale, distributed, and replicated workloads, such as Hadoop Distributed File System (HDFS), Cassandra, or Kafka.
To learn more, see About spread placement policies in this document.
About compact placement policies
When you apply a compact placement policy to VMs, Compute Engine tries to place the VMs as close together as possible, as allowed by the VMs' machine type and zone availability. By default, the compactness of a policy's VMs is only on a best-effort basis. If you require a minimum compactness within a zone—for example, due to network latency requirements—then you must specify a maximum distance value ( Preview ). Lower maximum distance values ensure closer VM placement but reduce the probability of VM availability.
The following table outlines the supported machine series, maximum number of VMs, and host maintenance policy for each maximum distance value:
Maximum distance value | Description | Supported machine series | Maximum number of VMs | Supported host maintenance policy |
---|---|---|---|---|
Unspecified (Not recommended)
|
Compute Engine makes best-effort attempts to place the VMs as close to each other as possible, but with no maximum distance between VMs within the zone. | A2, A3, C2, C3, C4, C2D, C3D, G2, H3, N2, and N2D | 1,500 | Migrate or Terminate |
3
|
The VMs are placed in adjacent clusters for low latency. | A2, A3 * , C2, C3, C4, C2D, C3D, G2, and H3 | 1,500 | Migrate or Terminate |
2
|
The VMs are placed in adjacent racks and experience lower network latency than VMs placed in adjacent clusters. | A2, A3 * , C2, C3, C4, C2D, C3D, G2, and H3 | 150 | Terminate |
1
|
The VMs are placed in the same rack and minimize network latency as much as possible. | A2, A3 * , C2, C3, C4, C2D, C3D, G2, and H3 | 22 | Terminate |
* By default, you can't apply compact placement policies with a max distance value to A3 VMs. To request access to this feature, contact your Technical Account Manager (TAM) or the Sales team .
After you create a compact placement policy and apply it to VMs, you can verify the physical location of the VMs in relation to other VMs that specify the same compact placement policy. For more information, see Verify the physical location of a VM .
About spread placement policies
When creating a spread placement policy, you can specify the number of availability domains —up to eight—to spread its VMs across. Availability domains provide isolated, distinct hardware to minimize the impact of localized disruptions. However, they're still impacted by shared infrastructure failures, such as data center power outages.
To reduce the proportion of your VMs that are impacted whenever an availability domain is disrupted, spread your VMs across at least two availability domains—each additional availability domain further reduces the proportion of your VMs that are impacted. Alternatively, you might spread your VMs across a small number of availability domains to try to limit network latency between those VMs or due to zonal restrictions.
When you apply a spread placement policy to a VM, Compute Engine places the VM in a specific availability domain based on one of the following:
-
Automatic placement. By default, Compute Engine automatically places the VM in a domain based on the number of VMs the placement policy is already applied to:
-
Eight VMs or less: If a spread placement policy is already applied to eight VMs or less, then Compute Engine places your VM in the domain with the fewest VMs.
-
More than eight VMs: If a spread placement policy is already applied to more than eight VMs, then Compute Engine places your VM in a random domain.
-
-
Specific placement. When creating a VM, updating the properties of a VM, or creating an instance template, you can optionally specify the availability domain in which to place your VMs. Distributing VMs across domains is helpful to increase the resiliency of your workload. Placing VMs in the same domain might help reduce network latency among those VMs.
When you apply a spread placement policy to an existing VM, the VM might need to be relocated to a different availability domain. During this process, Compute Engine stops or live migrates the VM based on its host maintenance policy .
Restrictions
The following sections outline the restrictions for placement policies.
Restrictions for all placement policies
For all placement policies, the following restrictions apply:
-
Placement policies are regional resources , and they only work in the region where they are located. For example, if you create a placement policy in region
us-central1
, then you can only apply it to Compute Engine resources located inus-central1
or in a zone inus-central1
. -
You can only apply one placement policy per Compute Engine resource.
-
You can only replace or remove placement policies from VMs. Replacing or removing placement policies from other Compute Engine resources isn't supported.
-
You can only delete a placement policy if it's not applied to any Compute Engine resource.
-
You can't apply placement policies to future reservation requests or to on-demand reservations that Compute Engine creates to fulfill an approved future reservation.
-
You can't apply placement policies to VMs that specify sole-tenant nodes.
Restrictions for compact placement policies
In addition to the restrictions for all placement policies , compact placement policies have the following restrictions:
-
If a compact placement policy specifies a maximum distance value , then this affects the maximum number of VMs that you can apply the placement policy to, as well as the machine series and host maintenance policy that the VMs can use.
-
If you want to apply a compact placement policy to on-demand reservations, then make sure of the following:
-
You can only apply compact placement policies to on-demand, single-project, standalone reservations. Shared reservations and reservations attached to commitments aren't supported.
-
You can't apply compact placement policies that specify a maximum distance value of
1
. -
You can only apply a compact placement policy to one reservation at a time.
-
Restrictions for spread placement policies
In addition to the restrictions for all placement policies , spread placement policies have the following restrictions:
-
You can apply a spread placement policy to 256 VMs maximum.
-
You can't apply spread placement policies to reservations.
Billing
There are no additional costs associated with creating, deleting, or applying placement policies to a VM.
What's next
-
Learn how to create and apply placement policies to VMs: