Skip to main content
U.S. flag

An official website of the United States government

Redis

Note - this service is being deprecated in favor of the aws-elasticache.

cloud.gov offers Redis 3.2 as a service.

Plans

Service Name Plan Name Description
redis32 standard-ha Redis instance with 10 GB storage

Additional Cost: Redis has a limit of 10GB in storage. After 10G, each additional gigabyte will cost $100 per month.

How to create an instance

To create a service instance, run the following command (replace my-redis-service with a name for the service):

cf create-service redis32 standard-ha my-redis-service

HA client configuration

During platform maintenance each Redis instance in the cluster will be temporarily removed while it is being updated. All clients connected to the instance will be disconnected during this process.

To ensure your application stays up during this process, configure your client to use a short (~ 1 second) timeout and to automatically reconnect to Redis when disconnected.

Managing backups

The Redis service does not expose access to files generated by the Redis SAVE command. To back up data from your Redis instance, you can iterate over keys, fetch their values and expiration times using DUMP and TTL, and save them to a file. To restore, use the RESTORE command for each saved key.

Connecting to your Redis service locally

To facilitate backing up your Redis service, cloud.gov offers port forwarding if SSH is enabled for your organization and application. Follow the following instructions to create a service key and use it to set up a SSH tunnel.

Create a service key to access Redis credentials:

cf create-service-key my-redis my-key

Connect to your Redis service using port forwarding (see Using SSH). You’ll need to leave the cf ssh command running and follow the next steps in a different terminal so that you can access the remote Redis instance from your local environment. These steps assume you have jq installed locally.

redis_credentials=$(cf service-key my-redis my-key | tail -n +3)

redis_hostname=$(echo "${redis_credentials}" | jq -r '.hostname')
redis_port=$(echo "${redis_credentials}" | jq -r '.port')
redis_password=$(echo "${redis_credentials}" | jq -r '.password')

cf ssh my-app -L "6379:${redis_hostname}:${redis_port}"

You can now connect to your Redis service from your local machine using port 6379 and the password set to $redis_password, e.g. using the redis command line:

redis-cli -a "${redis_password}" -p 6379

Rotating credentials

You can rotate credentials by creating a new instance and deleting the existing instance. If this is not an option, email cloud.gov support to request rotating the credentials manually.

The broker in GitHub

You can find the broker here: https://github.com/18F/kubernetes-broker.