Redis or Valkey for Magento Open Source cache and sessions

How to design the in-memory layer for a self-hosted Magento Open Source store: which engine to run, how to split sessions and cache, and what to confirm before you build.

On this page

Why Magento Open Source teams plan Redis or Valkey for cache and sessions

The in-memory layer holds the data a Magento Open Source store needs at request speed: customer sessions, the default cache and, when configured, the page cache. For a self-hosted store, Redis or Valkey is a service you run yourself, so its sizing, persistence and failure behavior become part of your platform design rather than something a default install settles for you. Adobe's system requirements make this explicit: the 2.4.9 requirements list Redis or Valkey 9, and the 2.4.8-p5 requirements list Redis or Valkey 8.1. Adobe supports only the listed combinations, so the version you pick must match the Magento release you are running or plan to run.

Defaults are usually enough for a small store with one web node and modest traffic. A dedicated design becomes worth planning when sessions and cache compete for memory, when several web nodes share state, when the store runs heavy cron or queue work, or when an outage in one cache type should not log out shoppers or empty the rest. Before the build starts, confirm with your Magento version and hosting team which Redis or Valkey major version your target release lists, how many logical stores you need, and whether your managed or on-premises image provides the required version. Ask the vendor or your platform team to confirm any change between 8.1 and 9 that affects your client libraries.

Two decisions follow from that scope. First, decide whether to use Redis or Valkey, since both can serve Magento's cache and session roles but carry different licenses and release lines. Redis 8.0 and later are offered under a choice of RSALv2, SSPLv1 or AGPLv3, while Valkey is licensed under BSD-3-Clause, a difference the Redis licenses page explains in detail and your legal team should review. Second, decide how many instances you need and where each one runs, because that drives the sizing and failover work covered in the rest of this page.

Choosing Redis or Valkey for your Magento stack

Redis has changed license terms more than once, so the first step is to identify which engine family you would actually run. Redis Open Source 8.0 and later can be used under a license of your choice among the Redis Source Available License v2 (RSALv2), the Server Side Public License v1 (SSPLv1) and the GNU AGPLv3. Redis 7.4.x through 7.8.x carried the dual RSALv2 or SSPLv1 terms, which are not OSI-approved. Redis 7.2.x and earlier remain under BSD-3-Clause. Valkey is a BSD-3-Clause fork of the open-source Redis code, maintained as a community project under LF Projects, LLC.

  • Redis 8.0 and later: license choice among RSALv2, SSPLv1 and AGPLv3, effective from the 8.0 general availability release.
  • Redis 7.4 to 7.8: dual RSALv2 or SSPLv1 terms, neither OSI-approved.
  • Redis 7.2 and earlier: BSD-3-Clause.
  • Valkey: BSD-3-Clause, with the Linux Foundation holding the trademarks through LF Projects.
  • Vector optimizations: Intel SVS-VAMANA features in Redis are closed source and usable only under RSALv2. A Magento cache and session layer does not normally need them, so confirm this in your environment.

Check which exact version your package manager or container image provides before assuming a license.

Configuration options and when each fits

This table compares the main layout, persistence and high availability options for the Redis or Valkey layer behind a self-hosted Magento Open Source store. Read each row as a decision: the option, when it fits a store of your shape, and the trade-off you accept. The main takeaway is that separating sessions from cache is usually a cleaner default than one shared instance, and that persistence and HA choices should follow from what you can afford to lose and rebuild.

OptionWhen it fitsTrade-off
One shared instance for sessions, default cache and page cacheSmall test or staging stores where operational simplicity matters more than isolationEviction or a memory spike in one cache type can evict sessions and cause customers to be logged out
Separate instances for sessions, default cache and page cacheProduction stores where cart and login state must survive cache flushes and eviction policies can differ by roleMore instances to size, monitor, patch and back up
Persistence offPure cache workloads where a cold cache after restart is acceptable and the store can rebuild itSessions are lost on restart, so customers may need to sign in again
RDB snapshotsSessions or state where periodic point-in-time recovery is enough and some data loss between snapshots is tolerableSnapshots taken at intervals mean recent writes can be lost after a failure; confirm the interval with your team
AOF persistenceState you want to recover with less loss than snapshots allow, such as sessions for logged-in buyersMore disk and write overhead; check the rewrite and fsync settings against your storage
Standalone with SentinelProduction stores that need automatic failover without a sharded cluster, using a replica promoted to masterSentinel needs at least three Sentinel instances for a robust deployment, so plan for extra hosts
Other HA layouts, such as Redis Cluster or Valkey ClusterVery large data sets that outgrow one node and need partitioning across shardsAdds design and client compatibility work; confirm Magento's Redis or Valkey support for your chosen layout before committing

How sessions, default cache and page cache use memory differently

Sessions, the default cache and the page cache each hold different data, so the same memory pressure has different effects on shoppers. Sessions hold the visitor's login state and related session data. If the instance holding them evicts keys or loses data, shoppers can be signed out or lose in-progress state during checkout. The default cache holds configuration, layout and block data that Magento can regenerate from source files and the database, so evictions there mostly cost speed until entries are rebuilt. Confirm in app/etc/env.php which backend and database each of these pools uses, because the session and cache sections are configured separately and may point at different instances.

The page cache role needs confirmation before you assign it to Redis or Valkey. Adobe documents Varnish as the full-page cache accelerator for self-managed installations, and a Redis-backed page cache is a separate choice configured under the page_cache key. If Varnish serves full pages in your architecture, a Redis page cache may add little and add another instance to size and monitor. If you configure both, evictions in the page cache send more requests to PHP-FPM and the database, so the effect appears as slower responses under load rather than as lost data. Review the Varnish configuration guide with your architect before deciding.

The lazy freeing settings, including lazyfree-lazy-eviction, lazyfree-lazy-expire and lazyfree-lazy-server-del, move the release of memory for large keys to background threads. This can reduce latency spikes when entries are evicted, expired or deleted in bulk, such as after a cache flush. Their defaults differ by server version, so confirm the values in the release you run rather than assuming them. Test them with a load run that includes cache flushes, cron activity and reindexing, and record latency percentiles, memory use and fragmentation before and after each change. Choose the eviction policy for the sessions instance deliberately, because any policy that removes keys under memory pressure will sign shoppers out.

Setting up separate Redis or Valkey instances for Magento

This sequence takes a Magento Open Source store from an engine choice that matches Adobe's requirements to separate, verified in-memory instances for sessions, default cache and page cache, with high availability added only where it is needed.

  1. Confirm the supported engine and version

    The platform engineer checks the Redis or Valkey version against the system requirements for the exact Magento Open Source release in use, since Adobe supports only the listed combinations. For 2.4.9 the requirements list Redis or Valkey 9, while the 2.4.8-p5 requirements list Redis or Valkey 8.1. Record the chosen engine, version and the PHP, OpenSearch and nginx versions it must work with. The step is done when the combination appears in Adobe's list for your release line and the team has written it into the build record.

  2. Choose the license and migration path

    Decide between Redis and Valkey on license terms, not only on features. Redis 8.0 and later can be used under RSALv2, SSPLv1 or AGPLv3 at the user's choice, while Valkey is BSD-3-Clause under the Linux Foundation. Legal or procurement should review the terms against how your organization uses the software. If you are moving an existing store, confirm the current engine version first: Valkey documents a direct upgrade path from Redis OSS 7.2 and earlier, but its guide does not cover migrating from Redis Community Edition 7.4 and later. The step is done when the license decision and migration method are approved in writing.

  3. Deploy instances with separate roles

    The infrastructure team runs one instance each for sessions, default cache and page cache, on separate ports or hosts, so that eviction and persistence settings can differ by role. Sessions should not be evicted under memory pressure, while the page cache and default cache can tolerate eviction. Confirm the memory limit, eviction policy and network placement for each instance with your sizing plan. The step is done when each instance answers a ping from the web nodes and the roles are documented in a single table that operations can read.

  4. Configure cache and session settings in env.php

    The developer edits the cache and session sections of app/etc/env.php so each Magento cache role points to its own instance and database index, and sets the session save handler to Redis or Valkey. Keep credentials out of version control by supplying them through your deployment secrets process. Clear the configuration cache after the change and confirm that the file deploys identically on every web node. The step is done when the configuration is in the release artifact and a cache clean completes without errors on each node.

  5. Set persistence and memory policy

    The platform engineer sets persistence per instance. Sessions usually need persistence so that logged-in customers survive a restart, while a cache can run without it if rebuilding is acceptable. Set a maximum memory value and an eviction policy for each instance, and enable lazy freeing settings where your engine version supports them, so that large key deletions do not block the server. Confirm each choice against the engine's own documentation for your version. The step is done when the configuration file for each instance shows the chosen values and the team has recorded the expected behavior on memory exhaustion.

  6. Enable Sentinel if high availability is required

    If the store needs automatic failover for sessions or cache, the infrastructure team adds Sentinel for high availability when you are not using a cluster. Plan at least three Sentinel instances, as both the Redis and Valkey documentation recommend, and place them on separate hosts. Confirm that the Magento client configuration supports Sentinel for your chosen engine and version before you rely on failover. The step is done when a controlled primary failure promotes a replica and the web nodes reconnect without manual edits.

  7. Verify connections, hit behavior and restarts

    The QA or operations engineer checks that each web node connects to each instance, then confirms that cache hits and misses appear in the instance statistics after warm traffic. Run a restart test on each instance in turn and confirm that sessions survive where persistence was configured and that the storefront recovers without errors in the Magento logs. Record the results with the instance statistics and log excerpts. The step is done when the restart test passes on every instance and the evidence is filed with the release record.

Securing the in-memory layer

The cache and session instances hold customer session identifiers, cart state and rendered pages, so they need the same access discipline as the database. The cards below cover the network, authentication, on-disk data, backups and administrator access that together decide whether the layer stays private.

Network isolation to web and cron nodes

Bind each instance to a private interface and allow connections only from the web nodes, cron hosts and consumer runners that need it. Keep sessions, default cache and page cache on separate listeners so a firewall rule can be scoped per role. Confirm that no instance is reachable from the public internet or from the admin workstation subnet, and test the rules from a host outside the allowed list. Record the port and source list in the deployment runbook so a new node gets the same rules.

Authentication and TLS settings

Require a password or ACL user for every connection, and give Magento a dedicated account with only the commands its cache and session backends use. Confirm the authentication and TLS options for the exact engine and version you run, since Redis 8 and Valkey 9 differ in license and tooling, and the Magento system requirements list the supported engine versions. Enable TLS only if your Magento build and client library support it, and test a failed login so you know the check works.

System requirements

Protecting RDB and AOF files on disk

Snapshot (RDB) and append-only (AOF) files can contain session data and cached content, so they need the same file permissions and encryption as other sensitive data. Run the engine under a service account, restrict the data directory to that account, and decide whether persistence is needed at all for sessions. Keep these files off shared volumes and out of images or artifacts that developers can download. Check that a copy of the data directory cannot be read by other local users.

Backup handling of session data

Backups of the in-memory layer capture active sessions, so treat them as sensitive. Decide with your security team whether these instances are backed up at all, because a restored session store can hand back logged-in sessions that were meant to expire. Set a retention period, encrypt backup storage, and restrict restore rights to named operators. Document how a restore is verified and how sessions are invalidated after one.

Administrator access to the cache layer

Limit who can run administrative commands such as key scans, configuration changes and flushes. A flush of the default cache or page cache is a routine operation, but a flush of the session instance signs out every customer, so separate that permission from general operations access. Use named accounts with an audit trail for administrator sessions, and restrict dangerous commands through the ACL configuration. Review who holds these rights each time staff change roles.

Patching the engine on a schedule

Security releases for the engine arrive on their own cadence, separate from Magento patches. Track the release line you run and plan a maintenance window to apply patch releases, since the Magento requirements name specific engine versions for each Magento release. Confirm the engine version is one Adobe supports for your Magento release before you upgrade, and retest sessions and cache behavior after each change.

Valkey releases

Sizing memory and tuning lazy freeing

Memory sizing for the Redis or Valkey layer follows from three inputs: how many concurrent sessions the store holds, how large the default cache and page cache grow across the catalog, and what the eviction policy does when a memory limit is reached. Size each instance on its own. Sessions should never compete with cache entries for memory, because a cache instance that evicts keys under pressure is acceptable, while evicting sessions logs shoppers out mid-checkout. Confirm the eviction policy you configure for the sessions instance and the cache instances separately, and record the maxmemory value and policy for each. The final numbers for web node, database and cache capacity should come from Adobe's sizing guidance, which ties cache size to traffic and cron load. Ask your Magento partner or Adobe documentation for those ratios rather than extrapolating from a generic guess.

Lazy freeing controls whether large keys are removed in a background thread or on the main thread. The relevant settings are the lazyfree-lazy-eviction, lazyfree-lazy-expire, lazyfree-lazy-server-del and lazyfree-lazy-user-flush keys, and the last one governs what happens when a flush command runs. Enabling lazy freeing for user flushes keeps a large cache flush from blocking every request that talks to the same instance, which matters when the default cache is flushed during a deployment. Confirm the exact key names and defaults against the Redis or Valkey version you run, because the two projects have documented these options across different release lines. Test each setting on a copy of production-sized data, not on an empty instance, since the cost of freeing a large key only shows up with realistic key counts and sizes.

Run the load test with the sessions and cache instances monitored in the same window as the storefront. Measure used memory against maxmemory, the number of evicted keys per instance, the fragmentation ratio, and latency percentiles during a cache flush with lazy freeing on and off. Watch for evictions on the sessions instance, which should be zero under expected load. Record whether memory use returns to baseline after a flush and how long the main thread stalls, if at all. Pair these results with the web node and database metrics from the same test so that cache sizing is judged against real storefront behavior. If the test shows evictions or stalls, adjust memory or the lazy freeing settings and rerun the same scenario before changing production.

Limits to confirm in your environment

Engine support, host operating system, licensing and high availability each limit what you can choose for Magento sessions and cache. Confirm these points with Adobe's requirements, the vendor licenses and your own hosting plan before you fix the design.

Engine line per Magento release

Adobe's system requirements pair each Magento release with specific engine lines. For 2.4.9, the listed engine is Redis or Valkey 9. For 2.4.8-p5, it is Redis or Valkey 8.1. Adobe supports only the listed combinations, so the Magento version you deploy sets the engine line. Confirm the exact pairing for your target patch level before you order hosts or write configuration.

System requirements

Windows hosts need Docker

Redis Open Source runs natively on Linux, macOS, OpenBSD, NetBSD and FreeBSD. On Windows, it runs only through Docker. Magento itself targets Linux x86-64 in Adobe's requirements, so most teams will run the cache on Linux. If your platform team standardizes on Windows servers, confirm how the Docker container will be patched, monitored and kept on the persistence volume you plan.

Install Redis

Redis 7.4 to 7.8 licensing

Redis 7.4.x through 7.8.x, once called Redis Community Edition, are available under RSALv2 or SSPLv1. Neither license is OSI-approved. Redis 7.2.x and earlier remain under BSD-3-Clause, and Redis 8.0 onward adds AGPLv3 as an option. If you run a version in the 7.4 to 7.8 range, have legal review the license and the network-service terms for any modified code before production.

Redis licenses

Sentinel needs three instances

Redis Sentinel provides automatic failover by promoting a replica to master when you do not use Redis Cluster. Redis recommends at least three Sentinel instances for a robust deployment. Plan those three processes on separate failure domains, and confirm that your Magento configuration points at the Sentinel-aware connection settings. A two-node setup with one Sentinel does not give you a reliable failover path.

Redis Sentinel docs

Non-open-source Redis options

Redis Software is a self-managed product with added compliance, reliability and resiliency features. Redis Cloud is a managed service on AWS, Google Cloud and Azure. Neither is open source. If your compliance or support requirements point to one of these, confirm the license terms, data location, support scope and exit path in writing, because the open-source build does not include those features.

Valkey release line support

Valkey maintains several release lines at once. Recent patch releases include 9.1.2, 9.0.6, 8.1.10, 8.0.11 and 7.2.14. Your Magento engine requirement may point to one line, while your patch policy may need another. Confirm which line your hosting image tracks, how quickly security patches arrive for it, and how you will move between lines when Adobe updates its requirements.

Valkey releases

Questions buyers ask before choosing Redis or Valkey for Magento

What does a Redis or Valkey cache and session setup cost, and what drives it?

The software is free to download under the licenses covered on this page, so the cost is the work and the infrastructure. Design work covers separating sessions, default cache and page cache onto their own instances, choosing persistence, sizing memory and setting lazy freeing. Infrastructure cost comes from the number of nodes, replicas and Sentinel instances you run, plus the memory each instance needs. Effort rises with the number of Magento stores sharing the layer, the size of the catalog cache, the presence of Varnish in front of the store, and any high availability requirement. Ask any partner for a written quote that lists the design, build, testing and handover as separate lines, and ask which items recur, such as patching and monitoring.

How long does a migration from Redis to Valkey take?

The duration depends on the Redis version you run, how your data is stored, and how much downtime your store can accept. Valkey's migration guide says Valkey is compatible with Redis OSS 7.2 and earlier, and that moving from Redis OSS 2.x through 7.2.x is effectively an upgrade. Clients connect without code changes, and RDB and AOF files from Redis OSS 7.2 load in Valkey. Duration is driven by the method chosen (RDB snapshot copy, replication with promotion, or key-level MIGRATE), the size of the dataset, the number of environments to test, and the cutover window. Confirm the timeline with your partner against your own staging environment before you commit.

What must our team provide before an implementation starts?

Start with exact versions: the Magento Open Source release you run, the PHP and database versions, and the Redis or Valkey version you plan to use, checked against Adobe's system requirements for your release. Provide current session and cache settings from env.php, the number of web nodes and workers, and the peak traffic profile, including cron and queue activity. Share hosting details: whether you run in your own cloud accounts, data centers or an air-gapped network, the memory available per node, and your backup and monitoring tools. Access to a staging environment that mirrors production is also needed before any cutover is planned.

Can our internal team set this up without a partner?

Yes, if your team already runs Magento in production and has experience operating in-memory data stores. The work involves configuration changes in Magento, instance layout, persistence and memory settings, Sentinel for high availability, and testing failover. Teams without that experience usually need outside help for the design decisions, such as which instances to separate and how to size them, and for failover testing. Ask your own engineers to confirm whether they can run a failover drill and restore from a backup in a non-production environment. Either way, a written scope keeps the responsibilities clear.

Should we migrate from an existing Redis 7.4 or later instance?

Not with the method used for Redis 7.2 or earlier. Valkey's migration guide warns that Redis Community Edition 7.4 and later write data files that are not compatible with Valkey, and it does not cover a method for those versions. Before choosing a path, confirm your exact Redis version and whether you can rebuild the cache and sessions instead of moving them. Sessions can often be cleared during a planned window, which removes the data compatibility question for them. Test whichever path you choose in staging. Your licensing position also matters, so check the Redis licenses page for the license that applies to the version you run.

Which license applies if we stay on Redis, and does it affect us?

The license depends on the Redis version. Redis 7.2.x and earlier remain under BSD-3-Clause. Redis 7.4.x to 7.8.x are under the dual RSALv2 or SSPLv1 license, neither of which is OSI-approved. Redis 8.0 and later can be used under RSALv2, SSPLv1 or AGPLv3 at your choice. Redis's FAQ says teams using unmodified Redis artifacts from 7.2 or earlier see no impact, but teams that offer modified Redis code as a network service must make that modified source available to the service's users. Have your legal or compliance team review the terms before choosing a version, and Valkey is licensed under BSD-3-Clause.

What breaks if we skip high availability or persistence settings?

Without high availability, a failed Redis or Valkey node can log shoppers out or clear carts and cached data until it is restored. Redis Sentinel and Valkey Sentinel provide automatic failover when you are not using a cluster, and both documents recommend at least three Sentinel instances for a robust deployment. Persistence choices decide how much data survives a restart. Sessions and page cache have different tolerance for loss, so they should not share the same settings by default. Test failover and restore in staging, because a configuration that has never been exercised often fails when it matters.

Does DeployOpen plan and build this layer for us?

DeployOpen implements open-source platforms inside your own infrastructure, which includes the cache and session layer for a Magento Open Source store. Most engagements are fixed-scope, so the design, build, testing and handover are agreed in writing before work starts, and a quote follows from that scope. Work can include separating instances, configuring persistence and memory, setting up Sentinel, running failover tests and documenting the runbook. DeployOpen does not publish a price list. Ongoing patching and monitoring can be covered by a retainer if you want it.

How the in-memory layer connects to Magento and its nodes

The diagram starts with the public internet reaching Varnish, which sits in front of the web nodes and serves cached pages. Web nodes, cron and consumer nodes all read and write the three separate Redis or Valkey instances for sessions, default cache and page cache, inside the private data tier. Sentinel nodes watch those instances and promote a replica when a master fails. Check that each instance has its own role, that no public-facing host can reach the data tier directly, and that Sentinel has at least three members.

Traffic path from Varnish to the web and worker nodes, and their links to separate in-memory instances.

How DeployOpen scopes and delivers the cache and session layer

DeployOpen scopes this layer in writing before any work starts. The written scope names each Redis or Valkey instance (sessions, default cache and page cache, if Varnish is not carrying full-page caching), the version line chosen, the persistence setting for each instance, the memory limit and eviction policy, the high availability design (standalone with replication, or Sentinel with at least three Sentinel instances), and the Magento configuration files that will reference each instance. It also lists what is excluded, such as application code changes, Varnish tuning or load testing, so the quote follows from a defined boundary rather than an open-ended estimate. Deliverables and timelines are agreed in that document, and the client confirms the target version line against Adobe's system requirements for their Magento Open Source release before the build begins.

Delivery happens inside the client's own infrastructure, whether that is their cloud account, data center or air-gapped network. The work covers installing the chosen server build, separating the instances onto their own ports or hosts, setting maxmemory and maxmemory-policy per role, configuring persistence, enabling lazy freeing options where the chosen version supports them, and wiring env.php so Magento reads each instance correctly. Verification is part of the scope: failover tests when Sentinel is used, restart and recovery tests for persistence settings, and a check that session data survives an application node restart while cache data behaves as designed. Access controls are reviewed, including network restrictions, authentication on each instance and the absence of exposed management ports.

Hardening and documentation close the delivery. DeployOpen records the topology, the configuration keys, the memory budget per instance, the failover runbook and the rollback steps, so the client's operations team can run the layer without the implementation team. Ongoing work is optional and sits under a retainer, which can cover patch and version upgrades when Adobe's supported combinations change, periodic failover and restore testing, and reviews after traffic or catalog growth. Clients should ask any partner to state in the quote who owns version upgrades, who receives alerts, and what is handed over at the end of the engagement. DeployOpen does not hold partner status with Redis Ltd., the Valkey project or Adobe.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.