Analyze with AI
Get AI-powered insights from this Mad Devs article:
A Redis deployment can hold both replaceable query results and the sessions that keep users signed in. Losing a cached result triggers another database read; losing a session may interrupt work or require authentication again. Those outcomes need separate acceptance criteria.
If your current Redis-compatible deployment is under review because of cost, support, or operational limits, a Valkey pilot should prove that each role survives failure acceptably. A successful connection is only the starting point. This guide helps you decide whether to move the cache, sessions, both, or neither.
Key takeaways
- Compare exact engine versions, hosting, and client behavior before choosing a migration path.
- Test expiration and writes with uncertain outcomes separately for cache entries and sessions.
- Approve each role independently, including its recovery and rollback conditions.
Compare the engines against current use
A useful Valkey vs Redis comparison starts with what your application actually runs. Record the source and target versions, hosting service, commands, modules, scripts, driver version, TLS/authentication settings, and topology. Include replica reads, Sentinel or cluster discovery, and persistence settings. Replay representative application requests against that exact target.
Valkey's migration guide documents compatibility with Redis OSS 7.2 and earlier, including their RDB/AOF formats. The guide states that Redis 7.4 and later produce data files incompatible with Valkey. RESP compatibility therefore does not establish that a snapshot can move between your chosen versions. Verify module availability and script behavior separately.
| Comparison area | Evidence needed for your decision |
|---|---|
| Engine and extensions | Version pair, required commands, module builds, and script test results |
| Hosting and topology | Failover procedure, persistence configuration, read routing, and recovery ownership |
| Client driver | Pinned release, discovery, reconnect, timeout, and pending-command settings |
| Licensing and service terms | Applicable engine license and separate hosting/support agreement |
Redis's licensing overview distinguishes BSD-3-Clause releases through 7.2, dual-licensed 7.4, and the three license options for Redis 8 onward. Valkey uses BSD-3-Clause. Record the applicable terms rather than treating either name as a complete licensing description.
Securonix's AWS case reports a phased ElastiCache migration with AWS Solutions Architects and a 20% caching-cost reduction. That is evidence for its managed deployment, not a forecast for yours; paid support terms are undisclosed. Topstep's migration also shows why source versions and migration-tool limits matter. Compare the complete deployment change before attributing gains to the engine.
Inventory cache and session obligations
Use one hypothetical application throughout the pilot: a customer portal with a PostgreSQL-backed profile cache and server-side login sessions. The following values are illustrative test inputs, not measured results or recommended defaults. The cache expires after 60 seconds; sessions have a 30-minute idle timeout and an eight-hour absolute lifetime, enforced by the application.
Write down what a missing, stale, or repeated value means before generating load. For this portal, a cache miss can rebuild a profile from PostgreSQL. A session cannot be recreated from a browser cookie alone after its authoritative server-side state disappears.
| Obligation | Rebuildable profile cache | Login session |
|---|---|---|
| TTL | 60 seconds; bounded staleness agreed | 30-minute idle expiry, capped by absolute expiry |
| Write | Replace a derived profile snapshot | Create, refresh, rotate, or revoke identity state |
| Repeated request | Re-read PostgreSQL; limit concurrent rebuilds | Retry only within valid session lifecycle |
| Recovery | Refill from the authoritative database | Restore valid state or require authentication |
| User effect | Slower response during refill | Interrupted workflow and possible loss of unsaved work |
Check how writes preserve or replace expiration. Valkey's EXPIRE documentation explains that overwriting a value with SET clears its existing TTL unless expiration is explicitly retained or supplied. Verify the actual driver calls and middleware rather than assuming every update refreshes the timeout correctly.
Keep revocation and authorization dependencies in the inventory. A profile value used only for display has different obligations from a cached permission used to allow an operation. Mad Devs' GoDee case study documents Redis in its architecture; it does not establish a Mad Devs migration to Valkey.
Test failure and reconnection
Run the same portal build and workload against the Redis baseline and Valkey candidate in an isolated environment. Pin the driver and record configuration differences. Capture request IDs, logical operation IDs, intended expiry deadlines, actual TTLs, write acknowledgments, reconnect events, and user-visible outcomes. Use the production read-routing policy so replica reads are included when applicable.
Scenario 1: Expiration during an outage
Populate the profile and session keys, then interrupt connectivity across their expiration deadlines. After reconnection, request the profile and submit an authenticated request using the old session cookie.
For the cache, the invariant is that an expired entry cannot supply data beyond the application's freshness allowance. A miss should trigger a bounded refill from PostgreSQL. Measure database traffic, concurrent rebuilds, tail latency, and time to recover the hit rate. A correct miss can still overload the database if every waiting request rebuilds independently.
For sessions, the invariant is that an expired identity cannot become valid again because connectivity returned. Verify idle and absolute expiry independently, including refresh requests queued before the outage. The old cookie should follow the application's authentication policy. Record how many test users must sign in again and whether interrupted work is recoverable.
A stale profile read is acceptable only inside the agreed display-data allowance. A stale session or authorization read that permits access after revocation fails this portal's acceptance criteria. Distinguish an expired key from a client holding an older value locally.
Scenario 2: A write succeeds but its reply is lost
Use a controlled network fault to let a write reach the server while withholding its response. Reconnect and observe whether the driver or application replays it. Separately trigger primary failover to test promotion and possible loss of recently acknowledged writes. Valkey replication is asynchronous; acknowledgments alone do not guarantee survival through every failover.
For the profile cache, check whether a delayed retry overwrites a newer profile or restarts its freshness window with old data. Rebuilding from PostgreSQL or rejecting older versions may be necessary even when repeating SET appears harmless.
For sessions, refresh a session, revoke it through another connection, and then release the delayed retry. It must not recreate the revoked session or extend it beyond its absolute deadline. Test session rotation too: an old identifier must stay invalid.
If the driver does not replay the write, deliberately retry at the application layer to test the same uncertain outcome. Inspect the driver's documented queue and replay controls. For example, ioredis documents offline queues and resending unfulfilled commands. Validate your pinned release and settings; reconnection success does not prove that replay is safe.
Decide what moves and what stays
Issue two decisions from the evidence. The cache may pass while sessions remain on Redis. Both may pass, or a shared driver problem may block both. The following is a proposed acceptance worksheet for the portal, not an industry standard or a report of completed tests.
| Role | Approve when | Hold when |
|---|---|---|
| Profile cache | Freshness holds; refill load and recovery meet agreed budgets | Replayed writes serve older data or refill overloads PostgreSQL |
| Sessions | Expiry, revocation, rotation, and reauthentication policy hold through faults | Reconnect resurrects state or unacceptable interruptions occur |
Before running the pilot, replace “agreed budgets” with numerical limits owned by the application team: maximum stale age, database headroom during refill, request timeout, recovery duration, and tolerated authentication interruptions. Separate engine recovery time from the time until the application behaves normally. Evaluate memory and latency at the expected workload, including the outage recovery burst.
Before rollout, record the version and driver pair, test results, numerical budgets, decision owner, and rollback procedure for each role. If only the cache passes, separate its connection configuration and namespace from sessions before production rollout. Confirm session middleware cannot accidentally use the cache endpoint. A key prefix alone does not isolate client pools, memory pressure, or failover behavior.
Plan rollback around writes made after cutover. Returning to an old endpoint can return users to stale sessions, including sessions revoked on the new system. Rehearse write fencing and the selected reconciliation or reauthentication policy. For disposable cache data, rebuilding may be safer than copying it back.
Recheck reverse compatibility whenever an engine version, serializer, module, or data format changes. Load a candidate backup into the intended rollback version in isolation, exercise reads and updates, and verify TTL deadlines. If it cannot load or interpret the data, endpoint reversal is not a tested recovery path.
If the original problem is database saturation, first localize the constraint with database scaling strategies. Changing cache engines should address a demonstrated limit with acceptable new operating costs.
Conclusion
Start with the role whose loss you can explain and recover from. For the demonstration portal, that is the rebuildable profile cache, provided PostgreSQL can absorb refill traffic. Move sessions only after their own fault tests satisfy the authentication policy.
The practical outcome of a Redis to Valkey migration pilot is two recorded decisions with evidence, owners, and rollback conditions. Choose the first role to test, write its invariant, and inject the failure that could break it before changing the production endpoint.
Backend Development Define acceptance for a cache engine switch Mad Devs can audit client and workload dependencies, design a compatibility and failure pilot, and help decide which uses can move first. Discuss your cache migration → |







