# GCP Memorystore Instance Idle

> Flags Memorystore for Redis instances with no clients and no commands for 30 days, billing provisioned GiB for nothing.

Source: https://zop.dev/integrations/gcp/recommendations/gcp-memorystore-instance-idle

---

## Provisioned GiB bill from the moment of creation

Memorystore for Redis charges for capacity you reserve, not for commands you run. Google's
[Memorystore pricing](https://cloud.google.com/memorystore/docs/redis/pricing) says charges start
when you create the instance and, whether you use it or not, are based on provisioned capacity in
GiB, billed in one-second increments. Price depends on the service tier, the capacity tier the
instance falls into and the region. Standard Tier adds cross-zone replication and failover, and
read replicas add nodes that bill as well.

A cache left behind by a retired service therefore keeps its full hourly charge.

## Measuring client activity yourself

```bash
gcloud redis instances list --region=REGION \
  --format="table(name,tier,memorySizeGb,state)"
```

In Metrics Explorer, chart `redis.googleapis.com/clients/connected` for the instance over 30 days.
A line pinned at zero means no application holds a connection. `redis.googleapis.com/commands/calls`
shows whether any commands ran.

## Two activity measures, one required

1. Connected clients stay below 1 on both average and peak across the window. This measure must
   exist for the instance.
2. Command throughput, when ZopNight has it, also stays below 1 operation per second on average
   and at peak.
3. The measured history spans at least 30 days.
4. The instance has a known monthly cost.

## Signals ZopNight does not treat as activity

CPU is not used as evidence of use: background maintenance and replication can register CPU on
an instance that no application touches, and counting it would hide abandoned caches. When the connection
metric is missing, or history is shorter than 30 days, the rule stays silent. A single client
holding a connection at any point clears the instance.

## What the finding is worth

```text
saving = current monthly instance cost
cost after deletion = 0
```

If the instance must remain for a planned launch, scaling it to a smaller capacity tier is the
partial saving.

## Decommissioning the cache

1. Confirm no application configuration, secret or connection string points at the instance's
   host and port.
2. If the data matters, export it to Cloud Storage as an RDB file:
   `gcloud redis instances export gs://BUCKET/FILE.rdb INSTANCE_ID --region=REGION`.
3. Delete the instance: `gcloud redis instances delete INSTANCE_ID --region=REGION`.
4. Remove the old host and port from secrets and configuration so nothing tries to reconnect.

**Warning**
Deleting a Memorystore instance destroys its data. Export first if anything in it could be needed.
