This page describes how to use the Google Cloud console and the Google Cloud CLI to
create and manage Memorystore for Memcached instances.

> [!CAUTION]
> **Caution:** Any network on which you provision a Memorystore for Memcached instance must have a [private services access](https://docs.cloud.google.com/vpc/docs/private-services-access.md.txt) connection. Otherwise, you cannot select that network when creating a Memorystore for Memcached instance. See [Networking](https://docs.cloud.google.com/memorystore/docs/memcached/networking.md.txt) for more details.

See [Best practices for provisioning Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/provisioning.md.txt)
for instance creation guidance.

For a list of the permissions you need to create and manage Memcached instances,
see [Access control and permissions](https://docs.cloud.google.com/memorystore/docs/memcached/access-control.md.txt).

## Creating Memcached instances

> [!IMPORTANT]
> **Important:** You must [establish a private services access connection](https://docs.cloud.google.com/memorystore/docs/memcached/establishing-connection) for a network before you can use it to provision a Memorystore for Memcached instance.

To create a Memcached instance:

### Console

1. Go to the **Memorystore for Memcached** page in the Google Cloud console.

   [Memorystore for Memcached](https://console.cloud.google.com/memorystore/memcached/instances)

2. Click the **Create Instance** button.

3. On the **Create a Memcached instance** page, select the configurations
   for your new instance.

   - Enter an **Instance ID** using only lowercase letters, numbers, and hyphens. Start with a letter.
     - For example, `my-memcached-instance-1`.
   - Optionally, enter a **Display name** for your instance.
   - Choose a region from the **Region** dropdown.
   - Choose `Automatically distribute` or a preferred zone from the **Zone** dropdown.
   - Choose your number of **Nodes**.
   - Choose your **Memory per node**.
   - Choose your **Cores per node**.
   - Choose your **Version**.
   - Select your **Authorized network**.

     > [!NOTE]
     > **Note:** If you see the **Private service connection required** panel, you need to [establish a private services access connection](https://docs.cloud.google.com/memorystore/docs/memcached/establishing-connection).

4. Click **Create**.

### gcloud

1. Set the default project in which to create a Memcached instance. Enter
   the following command, replacing <var translate="no">highlighted-variables</var> with
   appropriate values:

   ```
   gcloud config set core/project project-id
   ```
2. Create a Memcached instance:

   ```
   gcloud memcache instances create instance-id --node-count=number-of-nodes --node-cpu=number-of-cpus --node-memory=memory-per-node --region=region --zones=zone(s) --memcached-version=memcached-version
   ```

   Where:
   - <var translate="no">instance-id</var> is the ID assigned to the instance. Your instance ID must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number.
   - <var translate="no">number-of-nodes</var> is your node count.
   - <var translate="no">number-of-cpus</var> is your vCPU count.
     - Acceptable values: `1` or `2-32` (even values only).
     - Each vCPU requires 0.9GB of node memory, and supports up to 8GB of node memory.
   - <var translate="no">memory-per-node</var> is your memory for each node.

     - Minimum: 1 GB or (0.9GB \* vCPUs per node), whichever is greater.
     - Maximum: 256 GB.

     > [!NOTE]
     > **Note:** Memory per node is constrained by the number of vCPUs that the node has. You can provision up to 8 GB of memory for every vCPU, and must provision at least 0.9GB for every vCPU. Therefore, to reach the maximum memory per node of 256 GB, you must set `--node-cpu=32`.

   - <var translate="no">region</var> is the region in which to create the nodes.

   - <var translate="no">zone(s)</var> are the zones in which to create the nodes.

     - Exclude the `--zones` flag to automatically distribute nodes among zones.
   - <var translate="no">memcached version</var> is your Memcached version for
     your instance. Acceptable values are `1.5` and `1.6.15`.

   For example:

   ```
   gcloud memcache instances create myinstance --node-count=3 --node-cpu=2 --node-memory=2GB --region=us-central1 --zones=us-central1-a,us-central1-b,us-central1-c --memcached-version=1.6.15
   ```

## Creating a Memcached instance that uses a specific IP address range

### Console

1. Follow the instructions at [Creating Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/create-manage-instances.md.txt#creating_memcached_instances) until you reach the **Select IP ranges (optional)** section.

2. Use the **Select IP ranges** drop down menu to select an existing allocated range for your network. For
   instructions on creating and listing IP range allocations for private services access, see [Create an IP allocation](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#procedure) and [List allocated IP address ranges](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#listing_allocated_ip_address_ranges).

### gcloud

Create a Memcached instance:

```
gcloud memcache instances create instance-id --node-count=number-of-nodes --node-cpu=number-of-cpus --node-memory=memory-per-node --region=region --zones=zone(s) --authorized-network=network --reserved-ip-range-id=range-name(s)
```

Replace the following:

- <var translate="no">instance-id</var> is the ID assigned to the instance. Your instance ID must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number.
- <var translate="no">number-of-nodes</var> is your node count.
- <var translate="no">number-of-cpus</var> is your vCPU count.
  - Acceptable values: `1` or `2-32` (even values only).
  - Each vCPU requires 0.9GB of node memory, and supports up to 8GB of node memory.
- <var translate="no">memory-per-node</var> is your memory for each node.

  - Minimum: 1 GB or (0.9GB \* vCPUs per node), whichever is greater.
  - Maximum: 256 GB.

  > [!NOTE]
  > **Note:** Memory per node is constrained by the number of vCPUs that the node has. You can provision up to 8 GB of memory for every vCPU, and must provision at least 0.9GB for every vCPU. Therefore, to reach the maximum memory per node of 256 GB, you must set `--node-cpu=32`.

- <var translate="no">region</var> is the region in which to create the nodes.

- <var translate="no">zone(s)</var> are the zones in which to create the nodes.

  - Exclude the `--zones` flag to automatically distribute nodes among zones.
- <var translate="no">network</var> is the network used to create your instance. It uses
  the format: `projects/NETWORK_PROJECT_ID/global/networks/NETWORK_ID`.
  The network ID used here must match the network ID where the allocated
  IP range is located. Otherwise, the create operation fails.

- <var translate="no">range-name(s)</var> is the name of one or more allocated private
  services access ranges. For instructions on creating and listing IP
  range allocations for private services access, see [Create an IP allocation](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#procedure) and [List allocated IP address ranges](https://docs.cloud.google.com/vpc/docs/configure-private-services-access.md.txt#listing_allocated_ip_address_ranges).

For example:

```
gcloud memcache instances create myinstance --node-count=3 --node-cpu=2 --node-memory=2GB --region=us-central1 --zones=us-central1-a,us-central1-b,us-central1-c --authorized-network=projects/my-project-335118/global/networks/default --reserved-ip-range-id=myrange1,myrange2
```

## Viewing instance information

To view an instance's information:

### Console

1. Go to the **Memorystore for Memcached** page in the Google Cloud console.

   [Memorystore for Memcached](https://console.cloud.google.com/memorystore/memcached/instances)

2. Click the Instance ID to view its information.

### gcloud

1. To view the list of all Memcached instances in a region, enter the
   following command:

   ```
   gcloud memcache instances list --region=region-id
   ```
2. To view the details of an instance, enter the following command:

   ```
   gcloud memcache instances describe instance_id --region=region_id
   ```

## Editing instances

To edit an instance:

### Console

1. Go to the **Memorystore for Memcached** page in the Google Cloud console.

   [Memorystore for Memcached](https://console.cloud.google.com/memorystore/memcached/instances)

2. Click on the **Instance ID** of the instance you'd like to edit.

3. Click the **Edit** button.

   1. From the **Edit Memcached instance** page you can change an
      instance's:

      - Number of nodes -- see [Scaling Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/scaling-instances) for more details.
      - Display name
4. Click the **Save** button.

While your updates are being made, a swirling circle appears next to your
instance on the Memorystore for Memcached home page. When the updates are
finished, the circle becomes a green checkmark.

### gcloud

You can update the following properties after creating an instance:

- Number of nodes -- see [Scaling Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/scaling-instances)
  for more details.

- Memcached configuration -- see [Configuring Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/configuring-memcached)
  for more details.

- Labels

- Display name

For example, enter the following command to update the display name and
labels of an instance, replacing <var translate="no">variables</var> with appropriate
values:

```
gcloud memcache instances update instance-id --region=region-id --display-name=name --labels=key=value
```

## Deleting instances

To delete an instance:

### Console

1. Go to the **Memorystore for Memcached** page in the Google Cloud console.

   [Memorystore for Memcached](https://console.cloud.google.com/memorystore/memcached/instances)

2. Click the instance ID.

3. Click the **Delete** button.

4. Confirm that you want to delete the instance by entering the instance ID,
   and clicking the **Delete** button.

### gcloud

1. To delete an instance enter the following command:

   ```
   gcloud memcache instances delete instance-id --region=region-id
   ```

## What's next

- [Connect to a Memcached instance](https://docs.cloud.google.com/memorystore/docs/memcached/connecting-memcached-instance).

- [Use the Auto Discovery service](https://docs.cloud.google.com/memorystore/docs/memcached/using-auto-discovery).

- [Configure your Memcached instances](https://docs.cloud.google.com/memorystore/docs/memcached/configuring-memcached).