memorydb

Redis you are allowed to lose, and Redis you are not

Redis you are allowed to lose, and Redis you are not

The flat already has a key-value store in it. It's a DynamoDB table with a device identifier in the partition key and a few hundred items, and I've never once thought about which availability zones hold it. For a table like that I think that is the correct amount of thought.

So Amazon MemoryDB, which went generally available on the nineteenth of August, has no business being in my flat. I read about it anyway, because it makes a claim about a setup I've built badly before. A Redis sitting in front of a database, and a few hundred lines of code whose only job is to stop the two of them from disagreeing.

The claim

MemoryDB is compatible with Redis 6.2 - the same data types, the same commands, the same clients. Everything lives in memory, so reads are quoted in microseconds. The difference is underneath. Writes go to a transactional log spread across multiple availability zones, and the FAQ puts the consequence in one sentence: only data that has been successfully persisted to that log is visible.

That is an ordering rule and not a persistence setting, and it's different from every durability option Redis ships with. An RDB snapshot loses whatever happened since the last dump. Append-only with everysec loses about a second. Append-only with always is an fsync on one machine, so it survives the process dying but does not survive the machine dying. Replication in ElastiCache is asynchronous, so a failover can drop the tail of the write stream. That's the reason every team I've worked on treats an ElastiCache cluster as something you are allowed to lose and rebuild from the real database.

MemoryDB is the other kind. Writes are acknowledged after they are durable in more than one zone, reads on the primary are strongly consistent, and a replica that's being promoted has to catch up on the log before it starts serving. So AWS is selling it as a primary database and not as a cache.

The trade is on the write path

Reads in microseconds, writes in single-digit milliseconds. Going by the numbers in the announcement, a MemoryDB write is measured in milliseconds where the Redis it is compatible with is measured in microseconds. That gap is the product. You pay the cost of a multi-zone log append on every write, and in exchange the write is still there after a node disappears.

So the useful question is what fraction of my traffic is writes, and whether I care about the tail of the write latency distribution more than the mean.

Some workloads survive this easily. A session store that is read twenty times for every write barely notices, because the reads are still microseconds and the writes are rare. A cache of rendered fragments, same. Others don't survive it at all. A rate limiter doing INCR on the way into every request is nearly pure write traffic, and adding milliseconds to it means adding milliseconds to every request the system serves. A job queue that pushes and pops constantly is in the same category.

Whether pipelining or MULTI amortises the log append across a batch is the obvious follow-up question, and I don't want to guess at the answer. It's the sort of claim I'd want to see on a graph (same client, same payload, same concurrency, one run batched and one not) before believing either version of it.

The replica endpoint became a correctness decision

Reads on the primary are strongly consistent. Reads on a replica are eventually consistent, with the lag published to CloudWatch. Each shard takes a primary and up to five replicas, and a cluster can reach five hundred nodes.

In ElastiCache, sending reads to replicas is a throughput decision, and the worst case is that somebody sees a slightly stale cache entry, which is what a cache is anyway. In MemoryDB the same data is the system of record, and the identical configuration line decides whether a user can read back what they just wrote.

Plenty of client libraries offer this as a performance toggle. READONLY on a cluster connection, or a "read from replicas" flag in the configuration, is one line, and a reasonable engineer turns it on during a load test and never looks at it again.

# MemoryDB clusters are always sharded and always encrypted in transit,
# so the client needs both -c and --tls.
redis-cli -c --tls -h clustercfg.notes.xxxxxx.memorydb.eu-west-1.amazonaws.com -p 6379

> SET note:1 "written at the primary"
OK
> GET note:1
"written at the primary"

That sequence is guaranteed. The same GET issued against a replica isn't, it depends on replication lag at that instant. If I adopted this, the rule I would write down is that reads served from replicas are a named choice made per call site and never a connection-level default, and that anything in a read-after-write path is pinned to the primary.

Getting one, in September

I was surprised to find no infrastructure-as-code path yet. CloudFormation has no AWS::MemoryDB::* resource types, the AWS provider has no aws_memorydb_cluster, and the provider issue asking for the resources has been open since the week of the launch. Three weeks after GA the ways to create a cluster are the console, the CLI, and the SDKs.

So the CLI, and a note in the repository saying this is temporary:

aws memorydb create-subnet-group \
  --subnet-group-name notes-subnets \
  --subnet-ids subnet-0a1b2c3d subnet-4e5f6a7b \
  --description "MemoryDB, private subnets"

aws memorydb create-cluster \
  --cluster-name notes \
  --node-type db.r6g.large \
  --num-shards 1 \
  --num-replicas-per-shard 1 \
  --subnet-group-name notes-subnets \
  --security-group-ids sg-0123456789abcdef0 \
  --acl-name notes-acl \
  --tls-enabled

aws memorydb describe-clusters --cluster-name notes \
  --query 'Clusters[0].[Status,ClusterEndpoint.Address,NumberOfShards]'

Three things in there are not optional, and they're easy to meet for the first time at the wrong moment. A cluster only exists inside a VPC, so there's a subnet group and a security group before there is a database. Authentication is Redis 6 ACLs and not a single auth token, so the ACL and it's user have to exist first. And traffic is encrypted, so every client needs TLS configured. A local redis-cli from a package manager tends to fail on that one, since not every build ships with TLS support.

An existing cluster can come across without a rewrite. You can restore a MemoryDB cluster from an ElastiCache backup, or from an RDB file in S3. Nodes are R6g, so it's Graviton2 underneath.

What it removes, and what it does not

The code it deletes is cache-aside, and that's more code than people remember. The invalidation on every write path. The guard so that a hundred concurrent misses don't all go to the database. The cold-start path for when someone deployed and the cache is empty. The reconciliation job for the entries that drifted anyway. It's all boring code and all of it has bugs, and most of those bugs only show up under load.

What it doesn't remove is the reason the database was there. MemoryDB is Redis, so you get Redis data structures and that's it. No secondary indexes, no joins, no query planner, no ad-hoc reporting. Every access path has to be something you designed a key for in advance. If the answer to "how do we find all the accounts in this state" is currently a WHERE clause, it does not turn into a MemoryDB lookup by wishing.

It doesn't remove the memory bound either. The working set lives in RAM across the shards, same constraint as before, except now it applies to the entire dataset and not just the hot part of it. If the durable store is the in-memory store, you pay for RAM in proportion to the data, permanently.

Pricing, regions and the VPC

The price has three components: on-demand node hours, the volume of data written to the cluster, and snapshot storage. Node hours are a floor, because a node is rented by the hour whether or not anything is talking to it, and you don't pause a durable database overnight. The data-written charge is the one I'd watch. A per-gigabyte charge on data written is an unusual line for anything Redis-shaped, and it's the same story as the latency numbers. Writes are the expensive operation here.

At launch the regions are N. Virginia, Ireland, Mumbai and São Paulo. From Sofia that means Ireland. Frankfurt is not an option yet, and that matters if the rest of the stack is already there.

The VPC requirement has a tail as well. If the callers are Lambda functions they now need to be in the VPC too, and that means elastic network interfaces, subnets with capacity, and either a NAT gateway or a set of VPC endpoints for every other AWS API those functions were happily calling over the internet. That bill isn't on the MemoryDB pricing page.

When Redis is already the source of truth

The test I'd apply is whether Redis is already the source of truth for something while we pretend it is not. Session state that logs everyone out on a failover. A queue whose contents can be reconstructed in theory and never once have been in practice. Counters that back a billing number and get described as approximate in the one meeting where somebody asks. In those cases durability was a requirement all along, it just had never been paid for.

For a cache in front of a real database I would leave ElastiCache alone. I don't see the point of paying log-append latency on every write to protect data you are happy to lose.

And for the flat I don't need any of this. MemoryDB interests me because of an argument I have had more than once, about whether the cache is allowed to be wrong. Here that becomes a property you buy, where before it was a convention somebody had to enforce in review. The flat keeps its DynamoDB table, which costs pennies, survives a zone without my involvement, and doesn't need a rented node or every Lambda dragged into a VPC to reach it.

Deyan Peev

Founding Engineer in Sofia, Bulgaria. Currently at 1club.

© 2026 Deyan Peev