Creating an Instance with a Custom Machine Type

Compute Engine offers predefined machine types that you can use when you create an instance. A predefined machine type has a preset number of vCPUs and amount of memory, and are charged at a set price, described in the pricing page.

If predefined machine types do not meet your needs, you can create an instance with custom virtualized hardware settings. Specifically, you can create an instance with a custom number of vCPUs and amount of memory, effectively using a custom machine type.

Custom machine types are ideal for the following scenarios:

  • Workloads that are not a good fit for the predefined machine types that are available to you.
  • Workloads that require more processing power or more memory, but don't need all of the upgrades that are provided by the next machine type level.

Before you begin

Specifications

  • The maximum number of vCPUs allowed for a custom machine type is determined by the zone where the instance will be hosted:

    • Zones that support Broadwell, Haswell, and Ivy Bridge processors can support custom machine types with up to 64 vCPUs.
    • Zones that support Sandy Bridge processors can support custom machine types with up to 16 vCPUs.

    To see which processors are supported in which zones, see the Zones table.

  • Above 1, vCPU count must be even, such as 2, 4, 6, 8, 10, and so on.

  • The memory per vCPU of a custom machine type must be between 0.9 GB and 6.5 GB per vCPU, inclusive.

  • The total memory for a custom machine type must be a multiple of 256 MB. For example, 6.9 GB is not acceptable, but 6.75 GB and 7 GB are acceptable.

  • Instances with custom machine types have the same persistent disk capacity limitations as instances with predefined machine types. However, custom machine types are still limited to 16 individual persistent disk volumes.

For examples of valid and invalid machine types, read the Create an instance section.

Pricing

Google charges for custom machine types based on the number of vCPUs and memory hours that the instance uses. This is different than how predefined machine types are charged, so we recommend you review the pricing page before you create a custom machine type.

Instances running a custom machine type are subject to the same 10-minute minimum charge, but sustained use discounts for custom machine types are calculated differently. For more information, read sustained use discounts for custom machine types.

Create an instance

Before you create an instance, make sure you have read and understood the Specifications for creating a custom machine type. In summary:

  • Only machine types with 1 vCPU or an even number of vCPUs can be created.
  • Memory must be between 0.9 GB per vCPU, up to 6.5 GB per vCPU.
  • The total memory of the instance must be a multiple of 256 MB.
  • The maximum number of vCPUs allowed depends on the zone. Zones supporting Haswell and Broadwell processors can support machine types up to 64 vCPUs, while Ivy Bridge processors can support machine types with up to 32. Zones with Sandy Bridge processors can support machine types up to 16 vCPUs.

Examples of invalid machine types

  • 1 vCPU, 0.6 GB of total memory — Invalid because the total memory is less than the minimum 0.9 GB.
  • 1 vCPU, 0.9 GB of total memory — Invalid because the total memory must be a multiple of 256 MB. For 1 vCPU, use a minimum of 1024 MB memory.

Examples of valid machine types

  • 32 vCPUs, 29 GB of total memory — Valid because the total number of vCPUs is even and the total memory is a multiple of 256 MB. The amount of memory per vCPU is 0.9 GB, which satisfies the minimum requirement.
  • 1 vCPU, 1 GB of total memory — Valid because it has one vCPU, which is the minimum value, and the total memory is a multiple of 256 MB. The amount of memory per vCPU is also between the acceptable range of 0.9 GB to 6.5 GB per vCPU.

Expressing memory in GB or MB

Machine type memory is calculated in gigabytes (GB), where 1GB is 230 bytes. This unit of measurement is also known as a gibibyte (GiB) . When converting memory from GB to MB, 1 GB = 1024 MB.

In the API, you must always provide memory in MB units. If you use the gcloud command line tool, it is possible to provide the total memory for an instance in GB or MB units. However, the gcloud tool expects the memory value to be an integer, so you cannot provide a float value. For example, to express 5.75 GB, convert 5.75 GB into MB instead. In this case, 5.75 GB would be 5888 MB.

Create the instance

Console

  1. Go to the Create instance page.
  2. Under Machine type, click Customize.
  3. Drag the sliders to choose the number of vCPUs and the amount of memory for the instance. The console displays an estimated cost for the instance as you change the number of vCPUs and memory.
  4. Save your changes and continue with the rest of the creation process.

gcloud

Using the gcloud command-line tool, use the instances create subcommand, followed by the --custom-cpu and --custom-memory flags. Specify the total amount of memory in GB or in MB. The property must be an integer, so if you want to specify increments of 0.25 GB for memory, convert that value to MB instead.

For example, the following command would create an instance with 4 vCPUs and 5 GB of total memory:

gcloud compute instances create example-instance --custom-cpu 4 --custom-memory 5

To specify an incremental value, such as 5.25 GB of memory, convert the value to MB and supply the value followed by the MB suffix:

gcloud compute instances create example-instance --custom-cpu 4 --custom-memory 5376MB

API

In the API, create your instance creation request as you would normally, but when specifying a machineType value, use the following format. Replace NUMBER_OF_CPUS with the number of CPUs and AMOUNT_OF_MEMORY with the amount of memory you want. Provide memory in MB units:

zones/[ZONE]/machineTypes/custom-NUMBER_OF_CPUS-AMOUNT_OF_MEMORY

For example, the following URL would create an instance with 4 vCPUs and 5 GB (5120 MB) of memory:

zones/us-central1-f/machineTypes/custom-4-5120

You can also create preemptible instances with a custom machine type, or create groups of instances with a custom machine type by specifying a custom machine type in the formats described above.

Send feedback about...

Compute Engine Documentation