A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/compute/docs/instances/creating-instance-with-custom-machine-type below:

Create a VM with a custom machine type | Compute Engine Documentation

Skip to main content Create a VM with a custom machine type

Stay organized with collections Save and categorize content based on your preferences.

Compute Engine offers predefined machine types that you can use when you create a VM instance. A predefined machine type has a preset number of vCPUs and amount of memory, and is charged at a set price. If predefined VMs don't meet your needs, you can create a VM instance with custom virtualized hardware settings. Specifically, you can create a VM instance with a custom number of vCPUs and amount of memory, effectively using a custom machine type. Custom machine types are available for the following:

Custom VMs are ideal in the following scenarios:

Before you begin Required roles

To get the permissions that you need to create a VM with a custom machine type, ask your administrator to grant you the Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1) IAM role on the project. For more information about granting roles, see Manage access to projects, folders, and organizations.

This predefined role contains the permissions required to create a VM with a custom machine type. To see the exact permissions that are required, expand the Required permissions section:

Required permissions

The following permissions are required to create a VM with a custom machine type:

You might also be able to get these permissions with custom roles or other predefined roles.

Limitations Custom machine type pricing

Google charges for custom VMs based on the number of vCPUs and memory hours that the VM uses. This is different from how predefined machine types are charged. The on-demand prices for custom machine types include a 5% premium over the on-demand prices for predefined machine types.

See VM instance pricing for information by machine series.

Custom VMs are subject to the same 1-minute minimum charge as any other instance, but sustained use discounts for custom machine types are calculated differently. For more information, see sustained use discounts for custom VMs.

Extended memory pricing

For memory above the default, Compute Engine charges for extended memory based on the machine family extended custom memory pricing. The price for extended memory is different from the price for memory below the default threshold.

Extended memory prices differ depending on the region. Instances running with extended memory are subject to the same 1-minute minimum charge as any other instance. Extended memory also qualifies for sustained use discounts.

Add extended memory to a machine type

Depending on the machine series, each machine type has a specific amount of memory by default. For some workloads, this might not be enough memory. For an extra cost, you can get more memory per vCPU beyond the default limit. This is referred to as extended memory.

With extended memory, you can specify an amount of memory for the custom machine type with no limitation per vCPU. Instead of using the default memory size based on the number of vCPUs specified, you can specify an amount of extended memory, up to the limit of the machine series.

Machine series vCPU limit Memory limit N4 80 640 GB N2 80 864 GB N2D 96 768 GB N1 96 624 GB

If you require more memory, use one of the memory-optimized machine types.

Determine if you need extended memory

Certain workloads need more than the default amount of memory per vCPU to deliver optimum results. Workloads that are based on in-memory high- performance analytics databases, including relational and NoSQL databases such as MS SQL Server, MongoDB, and MemcacheD/Redis, are in this category. The vCPU-based licensing of operating systems and software stacks also makes selecting an optimal VM memory configuration more challenging with predefined machine types. By using extended memory, you can add as much memory as your VMs need for the best price- performance ratio.

Express memory in GB or MB

For Google Cloud tools and documentation, machine type memory is calculated in gigabytes (GB), where 1 GB 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 megabytes. If you use the Google Cloud CLI, you can provide the total memory for a VM in gigabytes or megabytes. However, the gcloud CLI 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 is 5888 MB.

Create a VM with a custom machine type

Before you create a custom VM instance, make sure you read the

custom specifications

for creating this machine type.

Console
  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. In the Machine configuration pane, do the following:

    1. Select the Region and Zone where you want to host the instance.
    2. Select General-purpose or GPUs.
      1. In the Series list, select a machine series.
        • For General-purpose, choose N4, N2, N2D, E2, or N1.
        • For GPUs, choose G2.
      2. In the Machine type section, select Custom.
      3. To specify the number of vCPUs and the amount of memory for the instance, drag the sliders or enter the values in the text boxes. The console displays an estimated cost for the instance as you change the number of vCPUs and memory.
  3. Optional: Specify other configuration options. For more information, see Configuration options during instance creation.

  4. To create and start the instance, click Create.

gcloud

Create a custom machine type using the gcloud compute instances create command with the --machine-type option.

  gcloud compute instances create INSTANCE_NAME \
    --machine-type=MACHINE_TYPE-custom-NUMBER_OF_VCPUS-AMOUNT_OF_MEMORY_MB

Replace the following:

Here's an example using an N2 machine type with 48 vCPUs and 310 GB of memory in zone us-central1-a:

gcloud compute instances create example-instance \
  --zone=us-central1-a --machine-type=n2-custom-48-317440

For supported machine series, such as N2, you can configure extended memory, which lets you specify a higher amount of memory than the maximum ratio of memory to vCPUs. To configure extended memory, increase the value of AMOUNT_OF_MEMORY_MB and append -ext to the machine type name, for example --machine-type=n2-custom-48-720000-ext.

Alternatively, you can specify a custom machine type by using the custom options: --custom-cpu, --custom-memory, --custom-vm-type, and --custom-extensions.

  gcloud compute instances create INSTANCE_NAME \
        --custom-cpu=NUMBER_OF_VCPUS \
        --custom-memory=NUMBER_OF_MB \
        --custom-vm-type=MACHINE_TYPE \
        --custom-extension

Replace the following:

The following example is an N2 custom machine type with 48 vCPUs and 310 GB of memory using the Google Cloud CLI options.

  gcloud compute instances create example-instance \
    --custom-cpu=48 --custom-memory=317440 --custom-extension --custom-vm-type=n2

When using the --custom-memory option, specify the total amount of memory in GB or in MB. The property value must be an integer, so if you want to specify increments of 0.25 GB for memory, use the value 250 MB instead.

For E2 shared-core custom machine types, use the same gcloud compute instances create command and include the shared-core machine size: micro, small, or medium. The vCPU and memory are limited.

  gcloud compute instances create INSTANCE_NAME\
    --machine-type=MACHINE_TYPE-AMOUNT_OF_MEMORY_MB

Replace the following:

The following example is an E2 shared-core small custom machine type with 0.5 vCPU and 2.25 GB of memory.

  gcloud compute instances create example-instance \
    --machine-type=e2-custom-small-2304
Terraform To generate the Terraform code, you can use the Equivalent code component in the Google Cloud console.
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM Instances

  2. Click Create instance.
  3. Specify the parameters you want.
  4. At the top or bottom of the page, click Equivalent code, and then click the Terraform tab to view the Terraform code.
Go

Before trying this sample, follow the Go setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Go API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Java

Before trying this sample, follow the Java setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Java API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Node.js

Before trying this sample, follow the Node.js setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Node.js API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Python

Before trying this sample, follow the Python setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Python API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

REST

Using the instances.insert method, construct an instance creation request and specify the custom machineType values. Provide the memory in MB.

POST https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances

Example request body

      {
    "name": "exampleinstance",
    "machineType": "zones/us-central1-a/machineTypes/n2-custom-16-107520",
    "disks": [
      {
        "boot": true,
        "diskSizeGb": 10,
        "initializeParams": {
          "sourceImage": "projects/debian-cloud/global/images/family/debian-11"
        }
      }
    ],
    "networkInterfaces": [
      {
        "network": "global/networks/default"
      }
    ]
  }
```

You can similarly create preemptible instances and groups of instances with custom machine types.

Add extended memory during instance creation

To create a VM instance with extended memory, do the following:

Console
  1. In the Google Cloud console, go to the Create an instance page.

    Go to Create an instance

  2. In the Machine configuration pane, do the following:

    1. In the Zone list, select the zone where you want to host this VM. The Series list is filtered to include only the machine type families available in the selected zone.
    2. Select General-purpose.
      1. In the Series list, select N4, N2, N2D, N1 to create a custom machine type.
      2. To specify the number of vCPUs drag the Cores slider or enter the value in the field.
      3. To add extended memory, select Extend memory. To specify the amount of memory for the machine type, drag the Memory slider or enter the value in the field. The console displays an estimated cost for the VM as you edit the amount of vCPUs and memory.
  3. Optional: Specify other configuration options. For more information, see Configuration options during instance creation.

  4. To create and start the VM, click Create.

gcloud

Create a custom machine using the gcloud compute instances create command with the --machine-type option.

  gcloud compute instances create  INSTANCE_NAME\
    --machine-type=MACHINE_TYPE-custom-NUMBER_OF_VCPUS-AMOUNT_OF_MEMORY_MB

Replace the following:

Here's an example using an N2 machine type with 48 vCPUs and 310 GB of memory in zone us-central1-a:

  gcloud compute instances create example-instance \
    --zone=us-central1-a --machine-type=n2-custom-48-317440
Go

Before trying this sample, follow the Go setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Go API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Java

Before trying this sample, follow the Java setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Java API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Node.js

Before trying this sample, follow the Node.js setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Node.js API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Python

Before trying this sample, follow the Python setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Python API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

REST

Using the instances.insert method, construct your instance creation request as you would to create an instance with custom memory. Include -ext, which indicates extended memory, when specifying the machineType values:

        zones/ZONE/machineTypes//MACHINE_TYPE-NUMBER_OF_CPUS-AMOUNT_OF_MEMORY-ext

Replace the following:

For example, the following specifies an N2 machine type with 2 vCPUs and 20 GB of memory, note that you must convert the memory to MB:

zones/ZONE/machineTypes/n2-custom-2-20480-ext
Add extended memory to an existing VM instance

To add more memory to an existing instance that uses a custom machine type, you must first

stop the instance

. After the instance stops, complete the following steps to add more memory to the VM.

Console
  1. In the Google Cloud console, go to the VM instances page.

    Go to VM instances

  2. Choose the stopped VM you want to modify from the VM list.

  3. Click Edit at the top of the page.

  4. In Machine configuration, select General-purpose.

  5. In the Machine type section, select Custom.

  6. Select the number of vCPUs you want.

  7. To add extended memory, select Extend memory and then specify the amount of memory you want.

  8. Save your changes.

gcloud

Use the gcloud compute instances stop command to stop the VM. Then use the gcloud compute instances set-machine-type command with the --custom-memory and --custom-extensions options to edit the machine's resources.

Save the changes and restart the VM.

Go

Before trying this sample, follow the Go setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Go API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Java

Before trying this sample, follow the Java setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Java API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Node.js

Before trying this sample, follow the Node.js setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Node.js API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

Python

Before trying this sample, follow the Python setup instructions in the Compute Engine quickstart using client libraries. For more information, see the Compute Engine Python API reference documentation.

To authenticate to Compute Engine, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

REST

Use the instances.stop method then use the instances.setMachineType method to edit the machine type resources.

Once you stop the instance, edit the machineTypes option with your changes.

{

"name": "INSTANCE_NAME", "machineType": "zones/ZONE/machineTypes/MACHINE_TYPE",

... }

Replace the following:

+ INSTANCE_NAME: The name of the VM
+ ZONE: The zone where your VMs reside
+ MACHINE_TYPE: The name of the VM
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-07 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["Compute Engine offers both predefined VM machine types with fixed vCPU and memory configurations, as well as custom machine types that allow for tailored vCPU and memory settings, primarily on N and E series machines."],["Custom VMs provide flexibility for workloads that don't fit into predefined types, offering control over processing power and memory, with memory adjustments in 256 MB increments and with the added ability to optimize software licensing costs."],["Extended memory, available on specific N-series machines (N4, N2, N2D, N1), provides increased memory per vCPU for memory-intensive tasks like in-memory databases and is charged separately, but does qualify for sustained use discounts."],["Creating or modifying custom VMs with or without extended memory can be accomplished through the Console, `gcloud` CLI, Terraform, or various programming languages like Go, Java, Node.js, and Python, utilizing the provided code examples."],["Custom VMs have a 5% premium on pricing over predefined types, and this premium also applies to commitment usage, local SSD disks prevent any CPU or memory changes."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4