Google Cloud Platform resources are hosted in multiple locations world-wide. These locations are composed of regions and zones within those regions. Putting resources in different zones in a region provides isolation for many types of infrastructure, hardware, and software failures. Putting resources in different regions provides an even higher degree of failure independence. This allows you to design robust systems with resources spread across different failure domains.
All Compute Engine resources are either global, regional, or zonal. For example, images are a global resource so they can be accessed from all other resources. Static IPs are a regional resource, and only resources that are part of the same region can use the static IPs in that region.
Global resources are accessible by any resource in any zone within the same project. When you create a global resource, you do not need to provide a scope specification. Global resources include:
- Images can be used by any instance or disk resource in the same project as the image. Google provides preconfigured images that you can use to boot your instance, you can customize one of these images, or you can build your own image.
- Persistent disk snapshots are available to all disks within the same project as the snapshot.
- A network can be used by any instance in the same project.
- Firewalls apply to a single network, but are considered a global resource because packets can reach them from other networks.
- Routes allow you to create complicated networking scenarios by letting you manage how traffic destined for a certain IP range should be routed, similar to how a router directs traffic within a local area network. Routes apply to networks within a Google Compute Engine project and are considered a global resource.
- Global operations
Operations are a per-zone resource, a per-region resource, and a global resource. If you are performing an operation on a global resource, the operation is considered a global operation. For example, inserting an image would be considered a global operation, because images are a global resource.
Regional resources are accessible by any resources within the same region. For
example, if you reserve a static external IP address in a specific region, that
static external IP address can only be assigned to instances within that region.
Each region also has one or more zones and you can find out which zone belongs to
which region by performing a
gcloud compute regions describe
$ gcloud compute regions list
Regional resources include:
- The Addresses collection contains any static external IP addresses that you have reserved for your project. Any static external IP addresses you have reserved for your project will remain reserved to your project until you explicitly release the IP address. Static external IP addresses are a regional resource and can only be used by instances that are in the same region as the address.
- Regional operations
Operations are a per-zone resource, a per-region resource, and a global resource. If you are performing an operation on a resource that lives within a region, the operation is considered a per-region operation. For example, reserving an address is considered regional operation, because the operation is being performed on a region-specific resource, an address.
A zone is an independent entity in a specific geographical location where you
can run your resources. For example, a zone named
us-central1-a indicates a
location in the central United States. Choosing a zone is important for several
- Handling failures
- It is important to distribute your resources across multiple zones to plan for scheduled or unscheduled zone outages. Since each zone is an independent entity, zone failures should not affect other zones. If a zone becomes unavailable, you can transfer traffic to another zone, allowing your services to remain running in the face of failures. For more information about distributing your resources and designing a robust system, see Designing Robust Systems.
- Decreased latency
- To decrease latency, you may want to choose a zone that is close to your point of service. For example, if you mostly have customers on the West Coast of the US, then you may want to choose a zone that is close to that area, in order to decrease latency between your virtual machine instances and your customers.
Resources that are hosted in a zone are called per-zone resources. Zone-specific resources, or per-zone resources, are unique to that zone and are only usable by other resources in the same zone. For example, an instance is a per-zone resource. When you create an instance, you must provide the zone where the instance should live. The instance can access other resources within the same zone, and can access global resources, but it cannot access other per-zone resources in a different zone, such as a Disk resource.
You can see a list of available zones using
$ gcloud compute zones list
Per-zone resources include:
- A virtual machine instance must reside within a zone and can access global resources or resources within the same zone.
- A Disk resource can only be accessed by other instances within the same zone. For example, you can only attach a disk in the same zone as the instance; you cannot attach a disk to an instance in another zone.
- Machine types
- Machine types are per-zone resources. Instances and disks can only uses machine types that are in the same zone.
- Per-zone operations
Operations are a per-zone resource, a per-region resource, and a global resource. If you are performing an operation on a resource that lives within a zone, the operation is considered a per-zone operation. For example, inserting an instance is considered a per-zone operation, because the operation is being performed on a zone-specific resource, an instance.
By default, list requests to resource collections return a list of resources in a particular control plane. For example, when you query the API for a list of instances, you must provide the zone for which you want to list instances. To list resources across all zones or regions, you can perform an aggregate list query. Each per-region and per-zone resource has an aggregate list URI that can be queried to list all resources of that type. For example, to list all instances across all zones, you can make a request to the following URI:
Similarly, to list all addresses across all regions, make a request to the following URI:
For more information, review the
method for that resource.