Deployment of Valkey
The Valkey service in VK Cloud is a high-performance in-memory data store optimized for scenarios that require instant access to information. The service is suitable for implementing caching, managing user sessions, processing task queues, and working with complex data structures in real time.
Valkey is fully compatible with the Redis OSS 7.2 protocol and command-line interface, which allows you to migrate existing solutions or deploy new microservices without changing application code. For more information, see the official Valkey documentation.
This guide will help you deploy the Valkey service on dedicated virtual machines in VK Cloud and configure TLS client connectivity from your application.
By using the Valkey service, you agree to the license agreements of Marketplace VK Cloud and Valkey.
-
Configure the network so that the service is accessible from the Internet:
- Create a network with Internet access if you have not already done so.
- In the subnet settings where the VMs with the deployed service will be located, disable the Private DNS option.
-
In your VK Cloud account, go to the Application Store section.
-
Click the Valkey service card.
If the Valkey service card is not shown on the page, click All solutions and find the card in the catalog.
-
On the service description page, click Connect.
-
In the Tariff plans tab, select the service version from the list.
-
Choose the required tariff:
- Single: one VM with no replication. If the node or its availability zone fails, the service is unavailable until the VM is restored. The connection is made directly to the node address. Suitable for development and testing.
- Sentinel: three or five VMs, or nodes, in different availability zones, one of which becomes the primary node. It handles all requests to create, modify, and delete data, while the other nodes store full copies of the data. If the primary node fails, another node takes over its role. Suitable for caching, sessions, and queues as long as the data fits into the memory of a single VM.
- Cluster: six or nine VMs, or nodes, in different availability zones. If a primary node fails, another node takes over its role. Data is distributed across several servers, or shards. Copies of each shard are stored in other zones. Data placement in the cluster is determined by key. Suitable for storing data that does not fit in the memory of one VM or for horizontal scaling. Applications that work with such a cluster must support a cluster-aware client.
-
Specify the parameters of the VMs on which the service will be deployed:
SingleSentinelCluster- Virtual machine type: select a VM configuration from the list, from
2-8to16-64, where the first number is the number of CPU cores and the second is the RAM size in gigabytes. For development and testing, choose2-8; for production workloads, choose4-16or higher. - Network: select the previously created network with Internet access and a subnet with Private DNS disabled.
- Virtual machine type: select a VM configuration from the list, from
-
Specify the data disk parameters:
- Disk size: specify the required VM disk size in gigabytes. To store data with RDB backups, the disk must be twice the size of the in-memory data volume. If you also need the append-only file log (AOF), the required disk size increases to three times the memory volume. For example, for an
8-32VM type with AOF enabled, you need about 70 GB for a data store or 50 GB for a cache. - Disk type: select one of the disk types. For intensive writes, choose
High-IOPS SSD.
- Disk size: specify the required VM disk size in gigabytes. To store data with RDB backups, the disk must be twice the size of the in-memory data volume. If you also need the append-only file log (AOF), the required disk size increases to three times the memory volume. For example, for an
-
Keep the default system disk parameter values.
-
Click Next step.
-
Configure access parameters:
- Client network: enter
subnetto open the service only from the selected subnet, or specify a network range such as10.20.0.0/16where your applications run. You can view the subnet address in your account. - Single address through the load balancer: for the Sentinel tariff, enable this option if your application code does not support the Sentinel mechanism. The service then has one address that always points to the current primary node. The load balancer for this address is billed separately.
- Client network: enter
-
Configure Valkey parameters:
- Persist to disk: enable this option if you need to store data on disk rather than only in memory. If you plan to use Valkey as a cache, disable this option.
- Operation log: enable this option to minimize the risk of data loss. The log writes every change command to a file and syncs it to disk once per second. If the log is disabled, the system relies only on periodic snapshots, which may be infrequent.
-
Optionally, enable Additional Valkey settings and configure extra memory settings:
-
Memory share for data: specify the share of node RAM reserved for data, for example
70%. The remaining memory is used for connections, replication, and snapshots. If disk persistence is enabled, the disk size must be at least twice this value. -
Eviction policy: choose what the server does when it runs out of memory. Possible values:
noeviction: the service does not delete anything, but rejects new writes, which is suitable for a data store.allkeys-lru: the service deletes least recently used keys, which is suitable for caching.volatilevariants: the service deletes only keys with a configured lifetime, which is suitable for storing important data together with cached data.
For more information about all key management policies, see the official Valkey documentation.
-
Write only when a replica is alive: for the Sentinel tariff, enable this option so that the primary node blocks new writes if it cannot guarantee that replicas will save them.
-
-
Click Next step.
-
Review the infrastructure cost for deploying the service and click Connect tariff.
Cloud infrastructure deployment will start, and the service properties page will open. The process status is also displayed in Application Store → My services.
After successful deployment, messages will be sent to the email address associated with your VK Cloud account:
- a notification with a link to the service instance in your VK Cloud account;
- an email with a one-time link to the access data.
-
Follow the one-time link from the email and save the service access data:
SingleSentinelClusternodes: list of Valkey nodes.endpoint: node address.clusterCA: cluster certificate authority certificate.adminUserandadminPassword: administrator account.appUserandappPassword: application account.monitoringUserandmonitoringPassword: monitoring account.sshUser: login for SSH access to the VM.sshKey: private SSH key. Save this key to a file, for examplevalkey_ssh.pem.
To test the connection, you can use any Linux VM in the client network, for example your application server.
-
Install the
valkey-cliutility on the VM from which you want to connect to the service, if you have not already done so:Ubuntu 24.04 and latersudo apt install -y valkey-tools -
Connect to this VM over SSH.
-
Save the certificate from the email to the
~/valkey-ca.pemfile:cat > ~/valkey-ca.pem <<'EOF'<CERTIFICATE>EOFHere,
<CERTIFICATE>is theclusterCAvalue from the email in full, including theBEGINandENDlines. -
Perform write and read operations in the Valkey service:
SingleSentinelCluster-
Perform a write operation in the Valkey service:
export REDISCLI_AUTH='<APPLICATION_PASSWORD>'valkey-cli --tls --cacert ~/valkey-ca.pem --user <APPLICATION_LOGIN> \-h <NODE_ADDRESS> -p 6379 SET greeting helloHere:
<APPLICATION_PASSWORD>is theappPasswordvalue from the email.<APPLICATION_LOGIN>is theappUservalue from the email.<NODE_ADDRESS>is the IP address without the port from theendpointparameter in the email.SET greeting hellois the Valkey command that stores the valuehellounder thegreetingkey.
Expected result:
OK. -
Perform a read operation from the Valkey service:
valkey-cli --tls --cacert ~/valkey-ca.pem --user <APPLICATION_LOGIN> \-h <NODE_ADDRESS> -p 6379 GET greetingHere:
<APPLICATION_PASSWORD>is theappPasswordvalue from the email.<APPLICATION_LOGIN>is theappUservalue from the email.<NODE_ADDRESS>is the IP address without the port from theendpointparameter in the email.GET greetingis the Valkey command that retrieves the value of thegreetingkey.
Expected result:
"hello".
The
appUseraccount does not have access to administrative commands such asCONFIG,FLUSHALL, andKEYS. UseadminUserandadminPasswordfor them. -
-
Save the
clusterCAvalue to a file on the application server if you have not already done so. -
Pass the Valkey connection parameters to the Valkey client in your application code. The following are examples for Python with the
redislibrary for the selected tariff. In other languages, use a Redis or Valkey client that supports TLS and username-password authentication.SingleSentinel with load balancerSentinel without load balancerClusterimport redisclient = redis.Redis(host="<NODE_ADDRESS>",port=6379,username="<APPLICATION_LOGIN>",password="<APPLICATION_PASSWORD>",ssl=True,ssl_ca_certs="<PATH_TO_CERTIFICATE>",)Here:
<NODE_ADDRESS>is the IP address without the port from theendpointparameter in the email.<APPLICATION_LOGIN>is theappUservalue from the email.<APPLICATION_PASSWORD>is theappPasswordvalue from the email.<PATH_TO_CERTIFICATE>is the full path to the file withclusterCAon your application server, for example/opt/app/valkey-ca.pem.