Key-Value Store (Redis Compatible)
Our Key-Value Store is a Redis compatible in memory key-value database used as a distributed cache and message broker. On-Demand Key-Value Stores offer limited configuration options. If more extensive settings are required, use our Key-Value Stores as a Managed Service.
Getting Started
You can use nctl or Cockpit, our web interface to get started:
- Cockpit
- nctl
- Create a New Service directly in Cockpit to get started. Don't forget to allow your IP to connect to the instance.
- Retrieve the credentials from the overview page. Note the FQDN and token. The user "default" will be used.
- Connect to the newly created instance:
REDISCLI_AUTH="${TOKEN}" redis-cli --tls --insecure -h ${FQDN}
- Ensure you are logged in with
nctl:nctl auth login - Create a
keyvaluestore:nctl create keyvaluestore my-test-kvs --allowed-cidrs=203.0.113.1/32 # replace 203.0.113.1 with your public IP address to allow connections from your system - Connect to the newly created instance:
nctl get keyvaluestore my-test-kvs # note the FQDNnctl get keyvaluestore my-test-kvs --print-token # note the tokenREDISCLI_AUTH="${TOKEN}" redis-cli --tls --insecure -h ${FQDN}
The resource can be managed via Cockpit, our command-line tool nctl or by directly using the API.
Billing is automated based on the resources used. Nine's automated management ensures the smooth operation of the service.
Updates and Maintenance Windows
Security and software updates are performed during the NKE maintenance windows.
Short service interruptions may occur during the maintenance windows without prior notice.
Pricing
| nine-key-value-store-256mb | nine-key-value-store-1gb | nine-key-value-store-2gb | x gb | |
|---|---|---|---|---|
| RAM | 256 MB | 1 GB | 2 GB | x GB |
| Storage space | 512 MB | 2 GB | 4 GB | x * 2 GB |
| Monthly fees | CHF 5.58 | CHF 22.32 | CHF 44.64 | x * CHF 22.32 |
Note that the storage space cannot be decreased and is based on the configured size of RAM.
Pricing for On-Demand Key-Value Stores start at CHF 5.58. Additional charges are based on the resources used.
Configuration options
On-Demand Services come with a sensible base configuration that is suitable for most setups. They also provide the ability to change certain configuration options. Adjusting these configuration options can result in a restart of the instance.
The instance can be customized with the following configuration options:
Name
The name of the instance can be freely chosen, but must be unique. Once created, the name cannot be changed.
Location
Depending on available resources, instances can be created in these locations:
| API / Cockpit Name | Name | Location |
|---|---|---|
| nine-es34 | NTT Zürich 1 | Rümlang |
All locations are physically located in Switzerland — see Datacenter Locations for details.
The location cannot be changed after the resource was created.
Version
The On-Demand Key-Value Store uses Valkey 9.
Valkey is an open-source fork of Redis and remains compatible with Redis in the current version. Redis clients and applications can therefore be used with Valkey without any changes.
Allowed IP addresses
Defines the IPv4 addresses and address ranges that are allowed to establish connections to the service. Access from our Kubernetes products (NKE and GKE) and from Deploio is enabled by default.
The access restriction can be adjusted at any time. Adjustments are made non-disruptively moments after the form is submitted.
maxmemory Policy
The configuration option maxmemory_policy defines what should happen when the available memory is exhausted.
By default, the policy allkeys-lru is used, which keeps the most recently used keys and removes the least recently used (LRU) keys. Adjusting the max-memory policy will cause the instance to restart.
An overview of all policies can be found in the Redis documentation.
RAM (Memory Size)
The amount of memory to configure for the key-value store.
The amount of disk space required increases linearly with this value. Note that reducing the memory size does not reduce the amount of disk space used.
Adjusting the memory size will cause the instance to restart.
Connection
As per Allowed IP Addresses, you may need to allow additional IPs to connect to your instance.
The instances are accessible via the standard Redis port 6379.
User
A user "default" with a password is created for connection authentication when the instance is created. Since "default" is the standard user, only the password is required when connecting. Check the Getting Started section for details on how to retrieve the credentials.
The FLUSHALL command to clear all keys from all databases is prohibited in our Key-Value Store product.
You can use the FLUSHDB command to clear all keys from the currently selected database.
TLS
The CA certificate will not match the hostname of the service. You may need to disable hostname verification explicitly.
The on-demand services only accept connections secured by TLS. Depending on the client or library used, it may be necessary to explicitly enable TLS.
The TLS certificate is self-signed. In addition to enabling TLS transport encryption, you may need to provide the certificate authority used for validation.
You can retrieve the CA either through Cockpit or nctl:
- Cockpit
- nctl
- Open the On-Demand Services overview and select the respective service.
- The CA is available under the resource's
Certificatetab.
- Ensure you are logged in with
nctl:nctl auth login - Retrieve the certificate:nctl get keyvaluestore my-test-keyvaluestore --print-ca-cert
Deploio Environment Variables
When this service is referenced from a Deploio application,
Nine injects connection credentials as environment variables. <NAME> is the target service
resource name uppercased with non-alphanumeric characters replaced by _.
| Variable | Description |
|---|---|
NINE_KVS_<NAME>_FQDN | Hostname. Uses private networking DNS when private networking is configured; otherwise the public hostname. |
NINE_KVS_<NAME>_PORT | Port (always 6379). |
NINE_KVS_<NAME>_USER | Username. |
NINE_KVS_<NAME>_PASSWORD | Password. |
NINE_KVS_<NAME>_CA_CERT | CA certificate. Only injected when a CA certificate is present. |
Backups
Stored keys and values are persisted across instance restarts, but no backups are created.
If you want to create your own backup, RedisShake will allow you to export all keys of a database to a file that you can store separately. Download the release for your platform, then run the commands on your local machine, or on any other system whose IP address is allowed to connect to the instance. See Allowed IP Addresses for details.
A backup file doesn't record which database its keys came from. Back up one database at a time, and restore each file into the database with the same number.
Although dbs accepts several databases, exporting them into a single file will merge all their keys into one database on restore. If a key name exists in more than one database, that data will be lost on import.
Create a Backup
To see which databases contains key / value pairs, run the following command:
REDISCLI_AUTH="${TOKEN}" redis-cli --tls --insecure -h "${FQDN}" INFO keyspace
Create a shake.toml file with the following content. Replace the FQDN and the token with the values of your instance and set dbs to the database you want to back up. Use an absolute path for filepath:
[scan_reader]
address = "${FQDN}:6379"
username = "default"
password = "${TOKEN}"
tls = true
dbs = [0]
count = 100
[file_writer]
filepath = "/path/to/backup-db0.aof"
type = "aof"
The following command creates the backup:
redis-shake shake.toml
Repeat this for every database (dbs) you want to back up. Make sure to adjust the filepath for every backup you create.
Restore a Backup
Restore each file into the database it was exported from. The -n option selects that database:
REDISCLI_AUTH="${TOKEN}" redis-cli \
--tls \
--insecure \
-h "${FQDN}" \
-p 6379 \
-n 0 \
--pipe < /path/to/backup-db0.aof
Restoring does not overwrite keys that already exist in the target database. For each of these keys, the restore fails with BUSYKEY Target key name already exists., keeping its current value.
Clear the database with FLUSHDB first to restore it to exactly the state of the backup, and check that redis-cli reports errors: 0 afterwards.