Key value stores

Redis 7 on one of your project's machines, for caches, sessions and job queues.

A key value store runs Redis 7 on one of your project's machines. Use it for caching, sessions, rate limits and background job queues. Any Redis client library works with it.

Create a key value store

  1. On the project's Services page, click Add next to Key Value Stores.
  2. Fill in the form:
    • Name
    • Machine: which of the project's machines it runs on, when the project has more than one. See Machines.
    • Memory: see Memory.
    • Connect: the web services, workers and cron jobs that should get REDIS_URL. Shown when the project has any.
  3. Click Create key value store.

The form shows the monthly fee under Price. The store's Overview shows Running when it is ready.

Connect your services

Connecting a service adds a REDIS_URL variable to it, with the password included. Your code reads it like any other environment variable.

  • When you create the store, pick services under Connect. They get the variable once the store is ready, and redeploy to pick it up.
  • Later, open the store's Settings, choose services under Connect to your services, and click Update and redeploy. Turning a service off removes the variable and redeploys it.
  • When you create a web service, you can pick the store under Connect key value store.

REDIS_URL appears on the project's Environment page as a managed variable. See Managed variables.

Connection details

Once the store is running, its Overview shows its Host, Port and the Internal (Appentic services) connection string. Click the eye icon to show the password in the string.

A key value store is never open to the internet. Services in the same project can connect to it, and so can your own computer over private access. Every connection needs the password.

Services on any of the project's machines, in any zone, connect with the same details.

Memory

The Memory slider sets the store's share of its machine. See Memory and sizing.

Redis can hold data up to 80% of the store's memory. The rest is headroom for Redis itself. When the data reaches that limit, Redis refuses writes that need more memory and returns an error. It never evicts keys to make room. If you use the store as a cache, set expiry times on your keys, or give the store more memory.

To change the memory, open Settings, move the slider under Scaling and click Update and redeploy. Connections may drop briefly.

Persistence

The store writes every change to an append-only file on the machine's disk. Its data survives restarts, and its machine being stopped and started.

The data isn't backed up. If you delete the store, or the machine's disk is lost without a standby, the data is gone. Don't keep anything in a key value store that you can't rebuild.

Standby

A standby is a copy of the store on another machine in the same zone. If the store's machine is down for more than a minute, the standby takes over at the same address. The last writes before the machine went down may be lost. There's no fee for a standby. It uses the same memory and disk on its machine as the store does on its own.

The project needs a second machine in the store's zone. Then:

  1. Open the store's Settings.
  2. Under Standby, pick a Machine.
  3. Click Add standby.

The standby holds the same memory and disk on its machine as the store, so that machine needs room for it. A machine that can't hold it is listed with the reason.

When the standby takes over, the store's Events page says so and you get a notification. The store then runs on the standby's machine, with its standby on the old one. While the standby's machine is running, the store keeps serving when its own machine is stopped or changed.

To remove the standby, click Remove under Standby and confirm. Without it, the store goes down whenever its machine does.

Limits:

  • You can't remove a machine that holds a standby.
  • While the standby's machine isn't running, you can't change the store's memory. Start that machine or remove the standby first.

Stopped machines

When the store's machine is stopped, the store shows Stopped, unless a standby on a running machine keeps it serving. It comes back when you start the machine. See Stopping and starting.

Metrics

The store's Metrics page charts CPU and memory usage over the last 24 hours. Connected clients and operations per second aren't collected yet. See Metrics.

Rename

In Settings, under General, change the Name and click Update. Only the name shown in the dashboard changes.

Delete a key value store

In Settings, under Danger Zone, click Delete key value store and confirm. This deletes the store and all its data, and can't be undone.