Why OpenEMR needs Redis session storage behind a load balancer
When you run OpenEMR behind a load balancer across more than one web server, a clinician's login session has to follow them from node to node, or they will be signed out or bounced back to the login page mid-task. The fix is to store sessions in a shared Redis service instead of on each web server's local disk. The OpenEMR Docker image supports two ways to do this. Native Redis mode, set with REDIS_SERVER, is supported from 5.0.2 and fits a single Redis endpoint that your team operates with its own high availability. Predis Sentinel mode, configured with SESSION_STORAGE_MODE, REDIS_SENTINELS and REDIS_MASTER, is supported from 8.1.0 and fits a Redis primary with Sentinel monitoring that can fail over automatically.
Choose between the two on the basis of how your Redis is run, not on the number of web nodes. If a managed or highly available Redis already exposes one stable endpoint, native mode keeps the configuration small. If your team already runs Sentinel, or you need automatic primary failover without a DNS change, Sentinel mode is the better fit, and the Sentinel node addresses and primary name must match your topology exactly. Confirm every variable name, default and behavior against the image tag you pin, because the Docker Hub page for openemr/openemr is the authority for the version in use and the options differ across releases. Redis holds sessions only, so it is not a complete answer for scaling. The uploaded documents directory, the sites configuration, the database and any file storage also have to be shared or consistent across nodes, and those decisions are covered in the sections that follow.
Native Redis or Predis Sentinel: which mode fits your topology
Native Redis mode is the simpler option. OpenEMR's Docker image supports native Redis sessions from version 5.0.2 and uses a single connection target that you point at one Redis endpoint with the REDIS_SERVER variable. This fits a deployment where one managed or self-hosted Redis instance is acceptable as the shared session store, and where your recovery plan for that instance is a documented restore rather than automatic failover. The application nodes behind your load balancer all read and write sessions in that one place, so every web node sees the same login state.
- Configuration: Set
REDIS_SERVERto the endpoint, and addREDIS_TLSorREDIS_X509only if you need encryption or mutual TLS to that endpoint. - What you run: One Redis instance, sized for session data, placed on a network every web node can reach.
- Failure impact: If that instance is unavailable, sessions cannot be read or written across all nodes at once.
- Recovery: Plan a restart or restore procedure and record how long users can expect to be signed out.
- Operations: Monitor memory and connection counts on the single instance, since it carries every session.
Before you choose this mode, confirm with your infrastructure team what availability target the Redis instance can meet and whether your managed service offers a replica that you would still need to promote by hand.
Predis Sentinel mode, available from OpenEMR 8.1.0, points the application at a Redis Sentinel deployment instead of one address. Sentinel monitors a primary and its replicas, and when the primary fails it promotes a replica and tells clients where the new primary is. OpenEMR selects this mode with SESSION_STORAGE_MODE and identifies the Sentinel nodes and the primary name with REDIS_SENTINELS and REDIS_MASTER. This matters when a session outage would interrupt clinical work and you need the session store to survive the loss of one Redis node.
- Configuration: Set
SESSION_STORAGE_MODEto the Sentinel mode, list the Sentinel nodes inREDIS_SENTINELS, and name the primary inREDIS_MASTER. - What you run: A primary, at least one replica, and a Sentinel quorum spread across failure domains, so a single host or zone loss does not remove the quorum.
- Failover: Sentinel promotes a replica automatically, but clients may see a short interruption and some sessions may be lost during the switch, depending on replication timing.
- Scope: Confirm in the Docker Hub documentation which settings apply to your image tag before you copy them into a production file.
- Ownership: Someone must own Sentinel upgrades, quorum health alerts and replica lag monitoring.
Before committing to this mode, ask your platform team who will respond to a Sentinel alert at night and whether they have the skills to run a quorum.
Sentinel's failover is an operational claim you should verify in your own environment, not assume from the architecture diagram. Test it with the same OpenEMR image, network paths, TLS settings and load balancer you will run in production, and record what a signed-in clinician experiences during the switch. The test should cover a primary stop, a replica failure, a Sentinel node failure and a loss of quorum, because each produces a different result for users and for the application.
- Primary loss: Stop the primary and measure how long until a replica is promoted and sessions resume.
- Session continuity: Check whether users stay signed in or must log in again, and whether any unsaved form data is lost.
- Quorum loss: Remove enough Sentinel nodes to break quorum and confirm how OpenEMR behaves, so the runbook covers it.
- Recovery: Bring the old primary back and confirm it rejoins as a replica rather than competing with the new primary.
- Repeatability: Run the test after each Redis, OpenEMR or infrastructure change, and keep the results with your change records.
Record the observed timings and user impact in writing, and ask your vendor or internal team to confirm any figure they expect before you rely on it in a clinical continuity plan.
The right mode depends on how many web nodes you run, how much downtime your clinics tolerate and how much Redis operations your team can support. A single-server or small multi-node setup with a managed Redis service that already provides its own replication may not need Sentinel. A Kubernetes or multi-zone deployment with several replicas and a dedicated platform team usually has the staff to run a quorum, and the Sentinel mode fits that model. Use the decision as a starting point and confirm it against your recovery targets.
- Small multi-node, managed Redis: Native mode may suffice if the provider's replication and restore meet your targets.
- Multi-zone or Kubernetes: Sentinel mode fits when you can place Sentinel nodes across failure domains.
- Air-gapped or constrained networks: Count the extra hosts and ports Sentinel needs before choosing it.
- Team skills: Native mode has fewer components to patch and monitor.
- Change path: Confirm whether switching modes later requires a session flush, so users are not surprised.
Ask your team to write down the availability target for sessions, then check the chosen mode against it during design review.
Redis session configuration options and when each fits
This table lists the Redis session settings in the official OpenEMR Docker image, what each one controls, its default where one is supplied, and the deployment it fits. Read it as a decision aid: pick the storage mode first, then add TLS, mTLS and lock tuning only where your Redis setup requires them. Confirm each variable name against the image tag you pin, because settings can change between releases.
| Setting | Purpose | Default or value | When it applies |
|---|---|---|---|
| SESSION_STORAGE_MODE | Selects how web nodes store sessions, including Predis Sentinel mode | Confirm the default for your tag; Sentinel mode is available from 8.1.0 | Set when you run Redis behind Sentinel and need the Predis Sentinel path |
| REDIS_SERVER | Address of the Redis server used for native Redis sessions | Not supplied; set to your Redis host | Native Redis sessions, available from 5.0.2, for a single Redis endpoint |
| REDIS_SENTINELS | List of Sentinel nodes that Predis uses to find the current primary | Not supplied; set to your Sentinel nodes | Predis Sentinel mode, where failover of the Redis primary must be transparent to web nodes |
| REDIS_MASTER | Name of the primary (master) set that Sentinel monitors | Not supplied; must match your Sentinel configuration | Predis Sentinel mode, paired with REDIS_SENTINELS |
| REDIS_TLS | Turns on TLS for connections from web nodes to Redis | Off unless set; confirm for your tag | When Redis traffic crosses a network segment you do not fully control or policy requires encryption in transit |
| REDIS_X509 | Enables mutual TLS, so Redis also checks the client certificate | Off unless set; confirm for your tag | When Redis is configured to require client certificates, usually alongside REDIS_TLS |
| REDIS_SESSION_LOCK_TTL | How long a session lock is held before it expires | 60 seconds | Raise only if long requests hold locks past the default; lower values reduce stuck-lock time after a crash |
| REDIS_SESSION_LOCK_MAX_WAIT | How long a request waits for a session lock before giving up | 60 seconds | Adjust when concurrent requests from one user contend for the same session; test with your slowest screens |
How to configure shared Redis sessions step by step
This sequence moves OpenEMR from node-local sessions to a shared Redis or Sentinel session store, so any web node can serve a logged-in user. Each step ends with a check you can run before moving on to the next.
Provision the Redis or Sentinel deployment
Your infrastructure or platform team stands up Redis in your own network, either as a single instance for native mode or as a primary, replicas and Sentinel quorum for Sentinel mode. Place it where every OpenEMR web node can reach it on the Redis port, and keep it off public networks. Confirm from one web node, using a Redis client or a simple connection test, that the server answers and that Sentinel reports the expected primary. The step is done when a PING from each web node returns a response and, in Sentinel mode, the sentinels agree on which node is the primary.
Pin the OpenEMR image tag on every node
Choose a dated OpenEMR image tag and use that exact tag on every web node so all replicas run the same code. Native Redis sessions are available from 5.0.2 and Predis Sentinel mode from 8.1.0, so a version older than 8.1.0 rules out Sentinel mode. Record the tag in your deployment manifest or Compose file and confirm that every node reports the same image version on the login or admin footer. The step is done when no node is running a different tag from the others.
Set the session mode and connection variables
On every web node, set the session storage variables in the same way. For native Redis, set REDIS_SERVER to the Redis address. For Sentinel mode, set SESSION_STORAGE_MODE, REDIS_SENTINELS and REDIS_MASTER. Keep these values identical across nodes, and store any secrets through your normal secret mechanism rather than in plain configuration files. Start one node first, then the rest. The step is done when each node starts without errors in its container logs and a test login creates a session entry in Redis.
Enable TLS to Redis
Turn on REDIS_TLS on every web node and confirm that Redis is configured to accept encrypted connections on the port you use. Use certificates issued by your internal certificate authority, and confirm with your Redis and OpenEMR image documentation which certificate files the image expects. Test the change on one node before rolling it to the rest. The step is done when a login succeeds through the encrypted path and the Redis server logs show TLS handshakes from the web nodes rather than plaintext connections.
Enable mTLS only if your policy requires it
If your security team requires each web node to prove its identity to Redis, set REDIS_X509 on every node and provide the client certificate and key the image expects. Your security team decides this, since it adds certificate issuance, distribution and renewal to the operating routine. Confirm that Redis rejects a connection that presents no client certificate, and that the web nodes connect normally with one. The step is done when an unauthenticated client is refused and every OpenEMR node still logs in successfully.
Confirm session lock settings and shared files
Review REDIS_SESSION_LOCK_TTL and REDIS_SESSION_LOCK_MAX_WAIT, both of which default to 60 seconds, and keep them unless your load testing shows a reason to change them. Then confirm that every web node mounts the same sites directory and reaches the same database, since sessions alone do not share uploaded documents, configuration or site data. Check that the sites volume is writable by the web user on each node and that all nodes point to one database endpoint. The step is done when a document uploaded through one node can be opened through another.
Verify login survives a node restart and failover
Log in through the load balancer, then restart one web node and confirm the session still works when the request reaches another node. Next, fail over the Redis primary in Sentinel mode, or restart the single Redis instance in native mode if you can tolerate that outage in a test environment, and confirm the session is retained or cleanly re-established. Record the result, including any forced logouts, and repeat the test after each configuration change. The step is done when a user keeps an active session through a web node restart and the Redis failover test, and you have a written record of the outcome.
Every web node reads sessions from the same Redis store
The diagram starts with a clinician's browser sending HTTPS requests to the load balancer, which spreads them across OpenEMR web nodes. Each node reads and writes its session in the shared Redis store, either a single Redis server or the primary chosen by a Sentinel set. The Redis connection is the hand-off to check first: TLS or mTLS should protect it whenever it crosses hosts. All nodes also share the database and the sites volume, so a session created on one node is valid on another. Everything inside the grouped box sits in the client's infrastructure, which is the trust boundary the security team reviews.
Requests reach any web node, which shares sessions through Redis.
What else must be shared between OpenEMR web nodes
Redis only holds session state. Putting OpenEMR behind a load balancer with Redis sessions does not make the nodes interchangeable on its own, because every web node must also read the same database, the same sites directory and the same configuration. Start by listing everything that lives on local disk in your planned build, then decide for each item whether it is shared, baked into the image, or generated per node. Treat that list as part of the design review, not an afterthought.
The sites directory deserves the most attention. It holds the per-site configuration, the documents tree where uploaded and generated patient files are stored, and the certificates or keys used by features such as the patient portal and FHIR. Every node must see the same contents, with the same permissions, or users will hit missing files, broken uploads or inconsistent behavior depending on which node answers. Confirm how your deployment target provides this: a network file system, a managed shared volume, or an object store behind a custom integration. Do not assume the packaged approach for your target provides it, and check whether it is safe for concurrent writes to the documents tree. Regardless of the storage choice, block direct web access to sites/*/documents as the Securing OpenEMR guide advises, which is a control you must verify on every node.
The database is the other shared dependency, and it is not optional. All nodes must point at one MySQL- or MariaDB-compatible database endpoint, or at a replicated cluster whose write path you have tested, with database SSL settings applied consistently. Confirm which node-level files are regenerated at startup and which are persistent, because a node that rewrites configuration on boot can drift from its peers. Keep the PHP version and extension set identical across nodes, since recent releases require PHP 8.3 or later. Ask your platform team to demonstrate, before go-live, that a change made on one node appears on all others, and that a restarted node rejoins without manual repair.
Securing Redis and sessions in a clinical deployment
Shared sessions move login state out of any single web node, which makes the session store part of your access control path. The six controls below cover the transport, network, secrets, lock behavior, web baseline and monitoring that a security reviewer will ask about before a load-balanced OpenEMR goes live.
TLS and mTLS to Redis
Session data passes between each web node and Redis on every request, so the connection needs protection when it leaves the host. The Docker image exposes REDIS_TLS to enable TLS and REDIS_X509 to enable mutual TLS, where each node presents a client certificate. Confirm which mode your Redis service accepts, how certificates are issued and rotated, and that a plaintext connection is refused rather than silently used. Under the HIPAA technical safeguards, this supports transmission security for ePHI-adjacent data.
Restricting Redis network reachability
Redis should accept connections only from the OpenEMR web nodes and, where used, the Sentinel processes. Place it on a private subnet or internal cluster network with no route from the public internet or the patient portal tier. Verify the rule with a connection test from a host outside the allowed set, and record the firewall or security group configuration as evidence of access restriction. This maps to the technical safeguard for access control and to the transmission security expected for ePHI.
Credentials and secret handling
Redis authentication values and certificate private keys should come from your secrets manager or orchestrator secret store, not from a compose file committed to source control or a shell history. Limit who can read these values, rotate them on staff changes, and make sure container logs and environment dumps do not echo them. Ask your team which identity can read the secret at runtime and how a rotation is applied to running nodes without leaving sessions orphaned.
Session lock timing and concurrency
REDIS_SESSION_LOCK_TTL and REDIS_SESSION_LOCK_MAX_WAIT both default to 60 seconds and control how long a request waits for a session lock. Shorter waits fail fast under contention, while longer values can stack requests behind a stuck lock. Test the values with the concurrent tabs and background calls your users generate, and confirm how a failed lock appears to the clinician so the failure is visible and not mistaken for a successful save.
Securing OpenEMR web baseline
Shared sessions do not remove the web-tier controls in the Securing OpenEMR guide. Allow only HTTPS, consider exposing only port 443, remove setup.php and other admin scripts after installation, and block direct web access to sites/*/documents so uploaded files cannot be fetched by URL. Each node in the pool must receive the same configuration, so check every replica, not only the one you tested. These steps support access control and integrity safeguards.
Logging and monitoring session store failures
A Redis outage, expired certificate or lock timeout can log users out or stall logins, and the cause may sit in the Redis tier rather than in OpenEMR. Collect connection errors, Sentinel failover events, certificate expiry warnings and OpenEMR audit entries in one place with retention set by your policy. Agree on who is alerted and how a session-related incident is reported, since HIPAA security incident procedures expect you to detect and respond to such events.
Questions teams ask before scaling OpenEMR with Redis
Is Redis required for every multi-node OpenEMR setup?
No. Redis is needed when web nodes sit behind a load balancer and a user's session must be readable from any node. A single web server, or a setup where sticky sessions reliably pin each user to one node, does not need a shared session store. The decision depends on how you route traffic, how you handle node failure and whether you expect users to be moved between nodes during a session. Confirm your session behavior in a test environment before you commit to a shared store, because sticky routing that works on day one can break after a node is replaced or a load balancer is reconfigured.
What does the work need from our team?
Your team needs to own the load balancer configuration, the network paths between web nodes and the Redis or Sentinel hosts, and the shared file storage that the nodes use. Someone must also decide where secrets and certificates live and who approves changes to them. On the application side, you need access to the environment variables or deployment manifests that set the session mode, and a staging copy of the system to test a failover. Plan for a named owner who can answer questions about your identity provider, DNS and firewall rules during the build.
How long does a Redis session configuration take?
No supplied duration exists for this work, so no timeline can be quoted from the public facts for this topic. The length depends on how many web nodes you run, whether you use native Redis or Predis Sentinel mode, whether TLS or mTLS is required, how many environments need the same setup, and how much failover testing your change process demands. Ask any provider for a scoped estimate that lists these inputs separately, and ask what each phase includes, including testing and handover.
Can our team configure shared sessions without outside help?
A team with container orchestration, Redis administration and TLS experience can usually handle the configuration itself, provided it has time to test failure cases. The hard part is rarely the environment variables. It is verifying that a user stays logged in when a node is removed, that lock waits do not stall requests and that certificate rotation does not cause an outage. Check whether you have someone who can run these tests, document the results and repeat them after each OpenEMR upgrade. If that skill set is thin, a scoped engagement can cover the build and a handover.
What drives the cost of this work?
Cost comes from four areas. The first is the Redis or Sentinel hosting itself, which you may already run or need to buy, including the number of replicas for high availability. The second is TLS certificate management, which covers issuing, storing, rotating and monitoring certificates for every component that talks to Redis. The third is testing effort, including failover drills, load tests and upgrade rehearsals. The fourth is the surrounding work on shared files, certificates and load balancer rules. Hosting and certificate tooling recur. Build and test work is usually one-time, though retests after upgrades recur. Ask any quote to split these items so you can see what you pay for once and what you pay for every year.
How does mTLS change day-to-day operations?
mTLS adds client certificates on top of server certificates, so both OpenEMR and Redis must present valid credentials. Operationally, this means someone must track certificate expiry dates, rotate client and server certificates without downtime and keep the trust chain current. A certificate that expires can stop every web node from reaching sessions at once, which turns a routine renewal into a full outage. Set up expiry alerts, document the rotation steps and test them on a staging copy. Also confirm who holds the private keys and how they are stored, since these keys grant access to session data.
What else must be shared between web nodes besides sessions?
Session storage is only one shared dependency. Each web node also needs the same site configuration, the same encryption keys for stored items and access to the same documents directory, so uploaded files do not disappear when a request reaches another node. Treat the sites directory as shared state that is backed up and governed. Also check that scheduled jobs run on one node only, not on every replica. Confirm each of these in your own environment before go-live, because a session store alone does not make a multi-node deployment consistent.
Where should I confirm the Redis settings for my OpenEMR version?
Start with the variable reference on the official Docker Hub page for the OpenEMR image, then check the release notes for the version you run. The image documentation covers the native Redis server variable, the Predis Sentinel mode variables, the TLS and mTLS switches and the session lock timeouts. Confirm the defaults for lock time and wait time in your own build, because the lock values control how long a request waits on a session and can change how the system behaves under load. Record the versions you tested so your upgrade plan can repeat the same checks.
How DeployOpen scopes and delivers Redis session storage for OpenEMR
DeployOpen plans and implements OpenEMR inside your own infrastructure, so the choice between native Redis and Predis Sentinel, the TLS and mTLS settings, and the shared storage behind your web nodes are decided against your network and your compliance review. Each engagement starts with a written scope that names the topology, the settings and the evidence your team will receive.
How we scope
- Map your load balancer, web node count, Redis topology and whether Sentinel is required before any build starts.
- Confirm which OpenEMR image tag, PHP version and database engine your environment will run, using the release notes.
- Agree in writing which shared state, including the sites volume, certificates and uploads, is in and out of scope.
How we build
- Configure session storage, TLS or mTLS to Redis and session lock timeouts with the Docker image variables your version supports.
- Verify that a logged-in user keeps their session when requests move between web nodes and when one node is restarted.
- Test failure cases, including a Redis failover and an expired or rejected client certificate, and record the results.
How we hand over
- Deliver a configuration record listing each variable, its value, its source and the owner who approves changes.
- Document the verification steps, test results and the rollback procedure for returning to a single node.
- Walk your operations and security teams through the design so they can review it against your own risk assessment.
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover.
- Plan a retest of session behavior whenever you move to a new OpenEMR release or change your Redis setup.
- Confirm the support boundary, response expectations and upgrade scope in the written agreement before work starts.

