Skip to content
Operate

Managed Redis

Run the engine's Redis on Memorystore with high availability, TLS and AUTH instead of the in-cluster Redis.

On this page

The engine uses Redis for sign-in sessions, rate-limit counters and a short-lived execution status cache. Postgres is the source of truth: Redis never holds message or step data, and every key can be rebuilt. By default the Helm chart runs one Redis pod in the cluster, with a password and a NetworkPolicy that lets only the engine and Medplum connect.

Switch to Memorystore for Redis when you want Redis to survive a zone outage or want Google to patch it. Terraform creates the instance, and the chart turns its own Redis off and connects to Memorystore instead.

flowchart LR
    subgraph YOURS["Your Google Cloud project"]
        direction TB
        ENG["Engine and Medplum\non private GKE"]
        MS[("Memorystore for Redis\nSTANDARD_HA")]
        SM["Secret Manager\nredis-auth"]
        ENG == "TLS (rediss://) + AUTH\nprivate service access" ==> MS
        SM -. "deploy reads the AUTH string" .-> ENG
    end

What Terraform sets up

SettingValue
TierSTANDARD_HA: a replica in another zone with automatic failover
In-transit encryptionOn (server authentication). Clients must use TLS.
AUTHOn. The AUTH string is stored as <secret_prefix>-redis-auth.
NetworkPrivate service access on the module's VPC. No public endpoint.
Encryption at restGoogle-managed keys, or your key when cmek_kms_key is set.
Evictionallkeys-lru, like the in-cluster Redis
MaintenanceSundays from 08:00 UTC

Only the deploy service account can read the AUTH secret, through a grant on that secret. Memorystore adds no project-level IAM, and the engine's service account gets no Memorystore permissions: it only speaks the Redis protocol.

How the engine connects

The deploy passes the chart three things: the instance address, the server CA certificates, and the AUTH string. The engine then gets:

VariableValue
REDIS_URLrediss://<host>:6378. No password in the URL.
REDIS_PASSWORDThe AUTH string, from the chart Secret.
REDIS_TLS_CA_FILEThe mounted server CA. Memorystore uses its own CA, not a public one.

Medplum gets the same address, AUTH string and CA. The chart refuses to render an external Redis without a host or without AUTH, and if REDIS_TLS_CA_FILE is set while REDIS_URL is not rediss://, the engine does not connect to Redis at all and /api/ready fails, instead of falling back to plaintext.

Steps

1. Turn it on

In terraform.tfvars:

hcl
redis                          = "memorystore"
memorystore_tier               = "STANDARD_HA" # or BASIC: one node, no failover
memorystore_memory_size_gb     = 1
memorystore_private_range_cidr = "10.252.0.0/24" # must not overlap your other ranges

2. Apply, then deploy

bash
cd terraform/gke
terraform apply
terraform output -raw memorystore_instance

Then run a normal deploy (Upgrade and roll back). It reads the AUTH string from Secret Manager and the address and CA from the Terraform values.

3. Check the connection

Open Settings → Overview in the engine. The Redis row of the Engine block shows the Memorystore address, and /api/ready returns ready only when Redis answers.

If /api/ready answers 503 with redis not ok, the engine cannot reach or sign in to Memorystore. Check that REDIS_URL is rediss:// on port 6378, that REDIS_TLS_CA_FILE points at the mounted CA, and that the AUTH string in the chart Secret matches the current version of <secret_prefix>-redis-auth. Then deploy again. The engine never falls back to plaintext.

Checklist

  • redis = "memorystore" is applied, and memorystore_private_range_cidr overlaps none of your other ranges.
  • The switch happened in a maintenance window, and people knew they would sign in again.
  • Settings → Overview shows the Memorystore address, and /api/ready is ready on every engine pod.

Using another managed Redis

Outside Terraform, set the chart values yourself:

yaml
externalRedis:
  enabled: true
  host: redis.example.test
  port: 6378
  caCert: |
    -----BEGIN CERTIFICATE-----
    ...
    -----END CERTIFICATE-----
  auth:
    existingSecret: redis-auth # or password: in your secrets values file
    existingSecretKey: auth-string

Leave caCert empty when the server certificate chains to a public CA.

Reference

VariableDefaultWhat it sets
redisin-clusterin-cluster or memorystore.
memorystore_tierSTANDARD_HASTANDARD_HA or BASIC.
memorystore_memory_size_gb1Capacity in GiB, from 1 to 300.
memorystore_redis_versionREDIS_7_2Redis version.
memorystore_private_range_cidr10.252.0.0/24Range for private service access, /24 or more.