AWS Database Blog

Get started with Amazon MemoryDB for Valkey

Today, Amazon MemoryDB announces support for Valkey version 7.2, with 30% lower instance hour pricing as compared to Amazon MemoryDB for Redis OSS. With MemoryDB for Valkey, there is no charge for data written up to 10 TB per month, and then billed at $0.04/GB for any data written over 10 TB. Valkey is an open source, high performance, key-value datastore stewarded by Linux Foundation backed by 40+ companies. Valkey is a drop in replacement of Redis OSS, developed by long standing Redis OSS contributors and maintainers, and has seen rapid adoption since project inception in March 2024. AWS is actively contributing to the Valkey project. With this launch, customers can benefit from a fully managed experience built on open-source technology while taking advantage of the 13+ years of operational excellence, security, and reliability that ElastiCache provides.

In today’s post, we provide you an overview of MemoryDB for Valkey, its benefits, and how you can upgrade your MemoryDB for Redis OSS database to MemoryDB for Valkey database.

Overview of MemoryDB for Valkey

Amazon MemoryDB is a Valkey and Redis OSS-compatible, durable, in-memory database service that delivers ultra-fast performance. MemoryDB stores data durably across multiple Availability Zones (AZs) using a distributed transactional log to enable fast failover, database recovery, and node restarts. You can use MemoryDB for Valkey for applications requiring durable storage and ultra-fast performance, such as user session data, message streaming, and gaming leaderboards. MemoryDB for Valkey also delivers the fastest vector search performance at the highest recall rates among popular vector databases on AWS. MemoryDB provides high availability and can be scaled at a lower cost with data tiering. By offering Valkey as a managed service through MemoryDB, AWS enables you to benefit from its extensive capabilities without the operational overhead of managing Valkey yourself. MemoryDB for Valkey is now available in all AWS Regions where MemoryDB is supported.

MemoryDB for Valkey offers the following benefits:

  • Lower pricing: You can optimize costs of MemoryDB for Valkey with 30% lower price as compared to MemoryDB for Redis OSS on instance hours and no data written charges upto 10 TB per month. For data written over 10 TB, there is an 80% lower pricing of $0.04 per GB as compared to MemoryDB for Redis OSS.
  • Performance: MemoryDB is built for high-performance applications requiring microsecond response times for reads and low single digit response times for writes.
  • Operational excellence: MemoryDB for Valkey provides a fully managed experience built on open-source technology while leveraging the security, operational excellence, 99.99% availability, and reliability from AWS.
  • API compatibility: MemoryDB for Valkey is compatible with Redis OSS APIs and data formats and customers can migrate their applications without needing to rewrite code or make changes to their architecture.
  • Zero-downtime migrations: Existing users of MemoryDB for Redis OSS can quickly upgrade to MemoryDB for Valkey with zero downtime.
  • Continuous innovation: The commitment from AWS to support Valkey ensures that customers are not only adopting a stable solution but also one that is poised for future growth and innovation. As the Valkey community continues to develop and enhance the project, AWS customers will benefit from ongoing improvements and new features that keep their applications competitive. AWS is also actively contributing to Valkey and you can read more about that on Amazon ElastiCache and Amazon MemoryDB announce support for Valkey.

Solution overview

You can get started with MemoryDB for Valkey with just a few steps:

  1. Create a MemoryDB for Valkey database.
  2. Create an Amazon Elastic Compute Cloud (Amazon EC2) instance.
  3. Download and set up the valkey-cli utility.
  4. Connect to the database from an application.

We walk through these steps in the following sections. Then we demonstrate performing basic operations on the database. We also discuss how to upgrade from MemoryDB for Redis OSS to MemoryDB for Valkey.

Create a MemoryDB for Valkey database

You can create Amazon MemoryDB for Valkey database using the AWS Management Console, AWS Command Line Interface (AWS CLI) or MemoryDB API. The following code is an example of creating MemoryDB for Valkey database using AWS CLI. Ensure that your CLI version is up-to-date to use Valkey resources in MemoryDB.

aws memorydb create-cluster \
    --cluster-name memorydb-valkey-cluster \
    --node-type db.r6g.large \
    --acl-name open-access \
    --subnet-group-name basic-subnet-group \
    --engine valkey \
    --tls-enabled \
    --region us-east-1

You can verify the status of the MemoryDB database creation process using the describe-clusters  command.

aws memorydb describe-clusters \
  --cluster-name memorydb-valkey-cluster \
  --region us-east-1 
{
    "Clusters": [
        {
            "Name": "memorydb-valkey-cluster",
            "Status": "available",
            "NumberOfShards": 1,
            "AvailabilityMode": "MultiAZ",
            "ClusterEndpoint": {
                "Address": "clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com",
                "Port": 6379
            },
            "NodeType": "db.r6g.large",
            "Engine": "valkey",
            "EngineVersion": "7.2",
            "EnginePatchVersion": "7.2.6",
            "ParameterGroupName": "default.memorydb-valkey7",
            "ParameterGroupStatus": "in-sync",
            "SubnetGroupName": "basic-subnet-group",
            "TLSEnabled": true,
            "ARN": "arn:aws:memorydb:xxx:xxx:cluster/memorydb-valkey-cluster",
            "SnapshotRetentionLimit": 0,
            "MaintenanceWindow": "fri:05:00-fri:06:00",
            "SnapshotWindow": "03:00-04:00",
            "ACLName": "open-access",
            "AutoMinorVersionUpgrade": true,
            "DataTiering": "false"
        }
    ]
}

Setting up EC2 for connecting to a MemoryDB for Valkey database

You can access MemoryDB through an EC2 instance either in the same VPC or from an EC2 instance in a different VPC using VPC peering. For instructions to create a EC2 instance, see Get started with Amazon EC2.

MemoryDB for Valkey database uses port 6379. In order to successfully connect and run Valkey commands from your EC2 instance, your security group must allow access to this port as needed.

Download and set up the valkey-cli utility

Connect to your EC2 instance and download the valkey-cli utility by running the following commands.

sudo yum install gcc jemalloc-devel openssl-devel tcl tcl-devel -y 
wget https://github.com/valkey-io/valkey/archive/refs/tags/7.2.7.tar.gz 
tar xvzf 7.2.7.tar.gz 
cd valkey-7.2.7/ 
make BUILD_TLS=yes install

For detailed instructions on using valkey-cli to connect and run commands against the Valkey engine, refer to Valkey CLI.

Connect to MemoryDB for Valkey database

To connect to the MemoryDB for Valkey database, obtain the endpoint for your new database using the describe-clusters AWS CLI command. You can find the memorydb cluster configuration endpoint as follows:

aws memorydb describe-clusters \
--cluster-name memorydb-valkey-cluster \
--region us-east-1
            "ClusterEndpoint": {
                "Address": "clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com",
                "Port": 6379
            }

Connect to MemoryDB for Valkey database using valkey-cli utility 

valkey-cli -h clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com -p 6379 -c --tls
  • -h = hostname
  • -p = port
  • -c = cluster mode
  • –tls = TLS Enabled clusters

Now, you’re ready to run basic GET and SET operations against the MemoryDB for Valkey database. The following is an example of an HSET operation to create a HASH object in Valkey. Valkey hashes are data structures used to store collections of field-value pairs. Hashes are useful when you need to represent objects or store related data in a single entity, such as a user profile with multiple attributes (such as name, age, email).

clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com:6379> hset car:1 make ferrari model sf90spider year 2024 engine "4.0 L V8" horsepower 769hp transmission "8-speed auto" price 580000
(integer) 7
clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com:6379>

The preceding operation creates a HASH object car:1 with attributes such as make, model, year, engine, horsepower, transmission, and price.
Now, you can retrieve individual or all field-value pairs using the HMGET or HGETALL operation.

clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com:6379> HMGET car:1 make model price
1) "ferrari"
2) "sf90spider"
3) "580000"
clustercfg.memorydb-valkey-cluster.xxx.amazonaws.com:6379>

Upgrade from MemoryDB for Redis OSS to MemoryDB for Valkey

With just a few clicks, existing users of MemoryDB for Redis OSS can upgrade to MemoryDB for Valkey with zero downtime. Complete the following steps:

  1. On the MemoryDB console, choose Clusters in the navigation pane.
  2. Choose the MemoryDB for Redis OSS cluster that is ready to be upgraded.
  3. Choose Modify.
  4. For Engine, choose Valkey. Choose Preview changes.

    You can review the summary of the modifications.
  5. Choose Save Changes to confirm your engine change from Redis OSS to Valkey. A notification will appear saying “The cluster was modified successfully.”

Your existing MemoryDB for Redis OSS database will be in Updating status.

Upon a successful upgrade, memorydb-redisoss-cluster will now show the new engine type as Valkey with Active Status.

With minimal application disruption, you have now upgraded your engine from Redis OSS to Valkey.

Cleanup

To maintain the principle of least privilege and avoid incurring future charges, delete the resources you created as part of this post. Delete the MemoryDB cluster (see deleting a cluster for more information) and EC2 instance (delete-instance)

Conclusion

The addition of Valkey support to MemoryDB represents a significant step forward in AWS’s commitment to providing robust, open-source solutions for your applications. If you’re not already signed up, you can select Get started on the MemoryDB page and complete the sign-up process. After you’re signed up, refer to get started with MemoryDB page for Valkey. Then you can create a database cluster in minutes using the MemoryDB Console, AWS CLI, or MemoryDB API.


About the authors

Madelyn Olson is a maintainer of the Valkey project and a Principal Software Development Engineer at Amazon ElastiCache and Amazon MemoryDB, focusing on building secure and highly reliable features for the Valkey engine. In her free time she enjoys taking in the natural beauty of the pacific northwest with long hikes and serene bike rides.

Goumi Viswanathan is a Senior Product Manager in the Amazon In-Memory Databases team. She has over 12 years of product experience and is focused on leading cross functional teams delivering database solutions. Outside of work, she enjoys traveling and spending time outdoors.

Siva Karuturi is a Worldwide Specialist Solutions Architect for In-Memory Databases based out of Dallas, TX. Siva specializes in various database technologies (both Relational & NoSQL) and has been helping customers implement complex architectures and providing leadership for In-Memory Database & analytics solutions including cloud computing, governance, security, architecture, high availability, disaster recovery and performance enhancements. Off work, he likes traveling and tasting various cuisines Anthony Bourdain style!